SA-MP Forums Archive
Wrong value seen? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wrong value seen? (/showthread.php?tid=409592)



Wrong value seen? - Mado - 22.01.2013

Hello,

I'm making something, but at some if/elseif statement there seems to be a little problem.

First the player types a command and "pGambleProgress" is set to 1. After some other dialogs he comes to a point where a draw is done, and one extra pGameProgress is added. That's in this code:

pawn Код:
PlayerInfo[playerid][pGambleProgress] += 1;
            if(PlayerInfo[playerid][pGambleProgress] < 4)
            {
                format(add, sizeof(add), "{DEF7E4}Slot 1: %s\n{DEF7E4}Slot 2: %s\n{DEF7E4}Slot 3: %s\n{DEF7E4}Slot 4: %s", slot1, slot2, slot3, slot4);
                strcat(dialog, add);
                ShowPlayerDialog(playerid, GAMBLE_LOCK, DIALOG_STYLE_LIST, "Slot Machine", dialog, "Lock", "Don't lock");
            }
            else //END OF GAMBLE
            {
                SendClientMessageEx(playerid, COLOR_YELLOW, "else statement triggered");
            }

Now 1 + 1 = 2, but in the script it's seen as "above 4" as the else statement is triggered. How...?


Re: Wrong value seen? - antonio112 - 22.01.2013

Well, you need to set the PlayerInfo[playerid][pGambleProgress] variable to 0 somewhere... You just add + 1 to it ... but I can't see where you set it to 0.


Re: Wrong value seen? - Mado - 22.01.2013

Upon entering the command /gamble:
pawn Код:
PlayerInfo[playerid][pGambleProgress] = 0;
And then at the next dialog it's
pawn Код:
PlayerInfo[playerid][pGambleProgress] = 1;



Re: Wrong value seen? - antonio112 - 22.01.2013

I can't seem to figure out the problem from the code posted by you ... How about posting the 'some other dialogs' too ? Post the whole dialogs please.