adr990 Posted December 29, 2009 Author Share Posted December 29, 2009 Hello everyone,I've been struggling with this for a while now.I can't get my NPC's to work if they are Scripted:```End Sub' Executes whenever a scripted NPC does an action.Sub ScriptedNPC(Index, Script) Select Case Script Case 0 Call PlayerMsg(Index, "This scripted NPC has no apparent use.", WHITE) Exit Sub Case Else Call PlayerMsg(Index, "No NPC script found. Please contact an admin to solve this problem.", WHITE) Case 1 Call PlayerMsg (Index, "Hello " & GetPlayerName(Index) & ", how are you?", WHITE) Case 2 Dim Words Words=Rand(27,1) Call playermsg(index, GetVar("Words.ini", "Words", ""& Words &""), 14) Exit Sub End SelectEnd Sub' Executed whenever a slash command is sent to the server.```Case 0 = Script 0Case 1 = Script 1 -Etc, right?Words.ini is in the Sever folder Root. by the way.If I put the NPC on Friendly and put some text into Speak, they do work. (Have things set to 1 instead of 0, as supposed to get them to work as Friendly.)Now, can anyone see what's wrong with the scripts?If I need to post my whole Main.txt, that's no problem.Thanks in advance,Adr990 Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloI have had a quick look at your script, I haven't had a chance to test this, I just fixed some obvious mistakes``` Sub ScriptedNPC(ByVal Index, ByVal Script) Select Case Script Case 0 Call PlayerMsg(Index, "This scripted NPC has no apparent use.", WHITE) Exit Sub Case 1 Call PlayerMsg(Index, "Hello " & GetPlayerName(Index) & ", how are you?", WHITE) Exit Sub Case 2 Dim Words Words = Rand(27, 1) Call playermsg(index, GetVar("Words.ini", "Words", "" & Words & ""), 14) Exit Sub Case Else Call PlayerMsg(Index, "No NPC script found. Please contact an admin to solve this problem.", WHITE) Exit Sub End Select End Sub```You had missed out several "Exit Sub" terminators and you also had your "Case Else" statement before your other cases. The "Case Else" statement must be the last case statement in your "Select case" statement. This is because the "Case Else" statement is called if none of the other case statements conditions are met.Please let me know if this works!Yours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
adr990 Posted December 29, 2009 Author Share Posted December 29, 2009 Ah, that clears up a lot already.Thanks a lot!I'm gonna test it right away. Link to comment Share on other sites More sharing options...
cloudwolf00 Posted December 29, 2009 Share Posted December 29, 2009 HelloGlad that I could help!Yours sincerelycloudwolf00 Link to comment Share on other sites More sharing options...
adr990 Posted December 29, 2009 Author Share Posted December 29, 2009 Hah, it's working! This is great.Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now