SA-MP Forums Archive
[HELP]Enter Code - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Enter Code (/showthread.php?tid=166339)



[HELP]Enter Code - Lorrden - 08.08.2010

So I just want to know how i can fix so that; You enter a 4-digit code and you get $1000.
(This is what I'm going to use for another system but I don't want to post that here on forums. That's why this example code is a bit messy)

The code is saved as PlayerInfo[playerid][pCode]
and all players get a random one (This has already been fixed by me)

The problem is:
pawn Код:
//Part of the onplayertext
new code[4];
if(sscanf(text, "d", code))
{
    return SendClientMessage(playerid, RED,"Enter Your code!");
}
if(code[PlayerInfo[playerid][pCode]])
{
    return GivePlayerCash(playerid, 1000);
}
return SendClientMessage(playerid, GREY,"Bank: Wrong Code.");



Re: [HELP]Enter Code - Simon - 08.08.2010

This should fix 'er if I've made the correct assumption and everything else is working.

pawn Код:
//Part of the onplayertext
new code;

if(sscanf(text, "d", code))
{
    return SendClientMessage(playerid, RED,"Enter Your code!");
}
if(PlayerInfo[playerid][pCode] == code) // pCode is simply a number I assume. code is also a number from sscanf.
{
    return GivePlayerCash(playerid, 1000);
}
return SendClientMessage(playerid, GREY,"Bank: Wrong Code.");



Re: [HELP]Enter Code - Lorrden - 08.08.2010

Thanks, It didn't work at first (I've also tried this before) but when i controlled my save file there was something wrong with it so the code was set to 5 and not the four numbers i thought it was..
Thank You!