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

Help!


RawrIWin
 Share

Recommended Posts

I have a part of code I'm trying to add to my script but it won't work.  I've narrowed down the source of the problem to a certain line.

```
Case "/vote"
If GetVar("towers.ini", "Peasants", "Vote")=1 Then
                  If GetVar("voted.ini", Getplayername(index), "votepoint")=1 Then
Voteplayer = TextSay(1)
Call PutVar("voted.ini", GetPlayerName(Index), "votepoint", 0)
Call PlayerMsg(Index, "Thank you for voting for " & Voteplayer & "!", YELLOW)
Call PutVar("voted.ini", Voteplayer, "tally", GetVar("voted.ini", Voteplayer, "tally") + 1)
Call AdminMsg("TEST COMPLETE", RED)
    End If
              End If
        Exit Sub
```
The only part that doesn't work is:

```
Call PutVar("voted.ini", Voteplayer, "tally", GetVar("voted.ini", Voteplayer, "tally") + 1)
```
And it is only because of the "Voteplayer" position.  I tried putting both Voteplayer and TextSay(1), but neither made the code run properly.  When I replace them with a specific name, the command works and does everything its supposed to.

Its supposed to give every player one vote, and count how many times people voted for them.  Does anyone have any ideas?

(Btw if this is in the wrong place you can move this, I didn't know where to put it)
Link to comment
Share on other sites

Did you declare Voteplayer?
I think this is required for Sadscript - not sure though cause i haven't used in like a year.

try:
```
Case "/vote"
      Dim Voteplayer
      If GetVar("towers.ini", "Peasants", "Vote")=1 Then
                      If GetVar("voted.ini", Getplayername(index), "votepoint")=1 Then
        Voteplayer = TextSay(1)
        Call PutVar("voted.ini", GetPlayerName(Index), "votepoint", 0)
        Call PlayerMsg(Index, "Thank you for voting for " & Voteplayer & "!", YELLOW)
        Call PutVar("voted.ini", Voteplayer, "tally", GetVar("voted.ini", Voteplayer, "tally") + 1)
        Call AdminMsg("TEST COMPLETE", RED)
          End If
                  End If
          Exit Sub
```
Link to comment
Share on other sites

Yeah haha, forgot to write that.  I declared it above, at the beginning of sub commands (where the other "declarations" are).

*Edit:  I figured out what was wrong.  I put a set of quotes and the & symbol before Voteplayer:

```
Call PutVar("voted.ini", "" & Voteplayer, "tally", GetVar("voted.ini", "" & Voteplayer, "tally") + 1)
```
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...