Wing Posted August 16, 2009 Author Share Posted August 16, 2009 I have this code put in scripted npc```Case 0If GetVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0) End IfIf GetVar("Scripts\QuestCharacters\" & GetPlayerName &".ini","QUESTS", "Quest1") = 0 Then Call PlayerMsg(Index, "Can you get me a carrot?", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 1) ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 1Then If CanTake(Index, 1, 1) Call TakeItem(Index, 1, 1) Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 2) Else Call PlayerMsg(Index, "Please hurry!", RED)ElseIf GetVar("Scripts\charextras\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 2Then If CanTake(Index, 2, 1) Call TakeItem(Index, 2, 1) Call GiveCurrency(Index, 3, 100) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 3) Call PlayerMsg(Index, "Please accept 100 coins in exchange for your services.", RED) Else Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED)ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 3Then Call PlayerMsg(Index, "Thanks again!", YELLOW)End IfExit Sub```When i attack the npc, nothing happens. What is the reason? Link to comment Share on other sites More sharing options...
Owen F Posted August 16, 2009 Share Posted August 16, 2009 lets see what i can do with my magic fingers (probably not alot)```Case 0If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0) EndIfIf GetVar("Scripts\QuestCharacters\" & GetPlayerName &".ini","QUESTS", "Quest1") = 0 Then Call PlayerMsg(Index, "Can you get me a carrot?", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 1)ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 1 Then If CanTake(Index, 1, 1) Call TakeItem(Index, 1, 1) Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 2) Else Call PlayerMsg(Index, "Please hurry!", RED)ElseIf GetVar("Scripts\charextras\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 2 Then If CanTake(Index, 2, 1) Call TakeItem(Index, 2, 1) Call GiveCurrency(Index, 3, 100) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 3) Call PlayerMsg(Index, "Please accept 100 coins in exchange for your services.", RED) Else Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED)ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 3 Then Call PlayerMsg(Index, "Thanks again!", YELLOW)EndIfExit Sub```These are some minor fixes ive done. It may/may not work now. Link to comment Share on other sites More sharing options...
Wing Posted August 16, 2009 Author Share Posted August 16, 2009 It still doesn't work. And i can't see what you changed. IT would be nice if someone could fix it and tell me what i did wrong. Link to comment Share on other sites More sharing options...
Owen F Posted August 16, 2009 Share Posted August 16, 2009 alright so some of your if-then's had the THEN on the next line and your EndIf's were two words.now, you've forgotten to end the if's after it changes the variables etc. Let me see.```Case 0If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0) EndIfIf GetVar("Scripts\QuestCharacters\" & GetPlayerName &".ini","QUESTS", "Quest1") = 0 Then Call PlayerMsg(Index, "Can you get me a carrot?", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 1)EndIfElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 1 Then If CanTake(Index, 1, 1) Call TakeItem(Index, 1, 1) Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 2)EndIf Else Call PlayerMsg(Index, "Please hurry!", RED)ElseIf GetVar("Scripts\charextras\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 2 Then If CanTake(Index, 2, 1) Then Call TakeItem(Index, 2, 1) Call GiveCurrency(Index, 3, 100) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 3) Call PlayerMsg(Index, "Please accept 100 coins in exchange for your services.", RED)End If Else Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED)ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 3 Then Call PlayerMsg(Index, "Thanks again!", YELLOW)EndIfExit Sub```I'm unsure that this will work either i'm slowly fixing the minor errors i can see no major ones. Yet. Link to comment Share on other sites More sharing options...
Bobosk Posted August 16, 2009 Share Posted August 16, 2009 ```Case 0If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0) EndIfIf GetVar("Scripts\QuestCharacters\" & GetPlayerName &".ini","QUESTS", "Quest1") = 0 Then Call PlayerMsg(Index, "Can you get me a carrot?", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 1)ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 1 Then If CanTake(Index, 1, 1) Call TakeItem(Index, 1, 1) Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 2) Else Call PlayerMsg(Index, "Please hurry!", RED)ElseIf GetVar("Scripts\charextras\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 2 Then If CanTake(Index, 2, 1) Call TakeItem(Index, 2, 1) Call GiveCurrency(Index, 3, 100) Call PutVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 3) Call PlayerMsg(Index, "Please accept 100 coins in exchange for your services.", RED) Else Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED)ElseIf GetVar("Scripts\QuestCharacters\ & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 3 Then Call PlayerMsg(Index, "Thanks again!", YELLOW)EndIfExit Sub```^^^OLD^^^vvvNEWvvv```Case 0If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0) End IfIf GetVar("Scripts\QuestCharacters\" & GetPlayerName &".ini","QUESTS", "Quest1") = 0 Then Call PlayerMsg(Index, "Can you get me a carrot?", RED) Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 1)ElseIf GetVar("Scripts\QuestCharacters\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 1 Then If CanTake(Index, 1, 1) = True Then Call TakeItem(Index, 1, 1) Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED) Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 2) Else Call PlayerMsg(Index, "Please hurry!", RED) End IfElseIf GetVar("Scripts\charextras\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 2 Then If CanTake(Index, 2, 1) = True Then Call TakeItem(Index, 2, 1) Call GiveCurrency(Index, 3, 100) Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1", 3) Call PlayerMsg(Index, "Please accept 100 coins in exchange for your services.", RED) Else Call PlayerMsg(Index, "I forgot my son wanted a toy train! Can you go buy one from the store??", RED) End IfElseIf GetVar("Scripts\QuestCharacters\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 3 Then Call PlayerMsg(Index, "Thanks again!", YELLOW)End If```in summary, from owen's first "fix".You were missing quotes at the end of Scripts\QuestCharacters\Missing End If's before your ElseIf GetVarsAnd it's "End If", not "EndIf"oh, and "= True/False" is a good measure when using cantake, despite what people may say Link to comment Share on other sites More sharing options...
Wing Posted August 16, 2009 Author Share Posted August 16, 2009 I think theres a bigger problem, it still doesn't work. Link to comment Share on other sites More sharing options...
Owen F Posted August 16, 2009 Share Posted August 16, 2009 why does the first getvar say if "blah" = ""anddoes the variable even exist. Link to comment Share on other sites More sharing options...
Wing Posted August 16, 2009 Author Share Posted August 16, 2009 It means if there is none, then it will create one. Is that wrong?```If GetVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0) End If``` Link to comment Share on other sites More sharing options...
Owen F Posted August 16, 2009 Share Posted August 16, 2009 it should just put the Variable the first time cause the other times it automatically checks if the variable is higher.. im not sure about this one though. Bobosk might know though. Link to comment Share on other sites More sharing options...
Wing Posted August 16, 2009 Author Share Posted August 16, 2009 Im just going to redo this. Maybe ill learn something new. This is one of my first tries at sad script so i didn't expect it to workEDIT: I put this together real fast because i have to go. Can someone test this and tell me if it works?```Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 1) Call PlayerMsg(Index, "Hello! Can you help me get 5 slime remains? You can get them from killing slimes!", RED)ElseIf GetVar("Scripts\QuestCharacters\" & GetPlayerName(index) & ".ini", "QUESTS", "Quest1") = 1 Then If CanTake(Index, 10, 5) = True Then Call PlayerMsg(Index, "Thanks! please accept these coins as your reward!", RED) Call TakeItem(Index, 10, 5) Call GiveCurrency(Index, 3, 50)Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 2) Else Call PlayerMsg(Index, "I still need 5 slime!", RED)``` Link to comment Share on other sites More sharing options...
Bobosk Posted August 16, 2009 Share Posted August 16, 2009 I would have to suggest, that you read some of the tutorials in the Scripting Tutorials section of this board(Godlord's are your best bet) because you don't seem to have the general structure down…Also, make sure you have scripting enabled..(on) and that you're reloading your scripts(If you're editing your main.txt while the server is running).@Owen:> it should just put the Variable the first time cause the other times it automatically checks if the variable is higher.. im not sure about this one though. Bobosk might know though.Either way works… but it's generally best to have a loop in the onjoin with checks for that [Example]```If GetVar(Blahity blah blah) = "" Thenx = 1Do While x < # of QuestsCall PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest" & x, 0)x = x + 1LoopEnd If``` 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