Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Question


Wing
 Share

Recommended Posts

I have this code put in scripted npc

```
Case 0
If GetVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then
      Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0)
  End If
If 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)
End If
Exit Sub

```
When i attack the npc, nothing happens. What is the reason?
Link to comment
Share on other sites

lets see what i can do with my magic fingers (probably not alot)
```
Case 0
If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then
      Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0)
  EndIf
If 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)
EndIf
Exit Sub
```These are some minor fixes ive done. It may/may not work now.
Link to comment
Share on other sites

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 0
If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then
      Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0)
  EndIf
If 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)
EndIf
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)
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)
EndIf
Exit 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

```
Case 0
If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then
      Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0)
  EndIf
If 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)
EndIf
Exit Sub
```^^^OLD^^^
vvvNEWvvv
```
Case 0
If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1") = "" Then
      Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest1", 0)
  End If
If 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 If
ElseIf 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 If
ElseIf 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 GetVars
And 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

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

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 work

EDIT: 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

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) = "" Then
x = 1
Do While x < # of Quests
Call PutVar("Scripts\QuestCharacters\" & GetPlayerName(Index) & ".ini", "QUESTS", "Quest" & x, 0)
x = x + 1
Loop
End If
```
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...