[HELP]Enter Code
#1

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.");
Reply
#2

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.");
Reply
#3

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)