Variable will not change from 0

So basically my variable keeps saying it’s zero. It USED to say it was a nil value until I did this:

[lua]
if !votesyes or votesyes == nil then votesyes = 0 end
votesyes = votesyes + 1
[/lua]

And so basically now it keeps thinking it’s nil every time it goes to add 1 to the variable, therefore resetting it to 0. But why won’t it say 1? It sets it to 0 then sets it to itself + 1. Shouldn’t it keep it at 1 if it thinks it’s nil?

Full Code:

[editline]14th February 2012[/editline]

I did some testing and it does appear to be adding the votes… (Tested it by doing this:)

[lua]
concommand.Add( “EV_VoteYes”, function( ply, cmd, args )
if !votesyes or votesyes == nil then
votesyes = 0
evolve:Notify( ply, evolve.colors.red, “Votes 0” )
end
votesyes = votesyes + 1
evolve:Notify( evolve.colors.red, "Votes: " … votesyes )

end )
–Returns:
–Votes 0
–Votes: 1
[/lua]

So now the issue is why isn’t my other function receiving the value in the variable? NONE of it is local and NONE of it is in the client side.

[lua]
function PLUGIN:VoteKickEnd( targetpl2 )
yes = votesyes
no = votesno

evolve:Notify( evolve.colors.blue, "Votekick for ", evolve.colors.red, targetpl2, evolve.colors.white, “Yes ( " … yes … " ) and No ( " … no … " ).” )
–Returns:
–Votekick for Bot01 Yes( 0 ) and No( 0 ).
end
[/lua]

Try this:
[lua]if SERVER then
concommand.Add( “EVVoteYes”, function( ply, cmd, args )
if !votesyes or votesyes == nil then votesyes = 0 end
votesyes = votesyes + 1
end )
concommand.Add( “EVVoteNo”, function( ply, cmd, args )
if !votesno or votesno == nil then votesno = 0 end
votesno = votesno + 1
end )
end[/lua]

(I removed the undesrcores, because for some reason I always have trouble with server-side concommands with underscores, if you do it too you’ll have to edit the client side buttons :p)
When I tested your script, it was only running the command client-side, which explains why the server didn’t see any changes

Also, you might want a [lua]local votesyes, votesno[/lua] at the start of the script, before the functions

If you check my Full Code you’ll see that in the PLUGIN:Call it will set votesyes and votesno to 0. :slight_smile:

Anyways, I’ll test that right now and get back to you ASAP.

[editline]15th February 2012[/editline]

So if I put it in the if SERVER then check, the command comes up as unknown. The EV_VoteYes I mean.

:wink:

Edit: Also, setting it to 0 doesn’t make it local, it’s a completely different thing :stuck_out_tongue:

Oh, I thought you meant to make sure it’s actually defined :stuck_out_tongue:

[editline]15th February 2012[/editline]

Ooooh myyyyy goooood. That fixed it. FML.