SA-MP Forums Archive
Need some help for logic - 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: Need some help for logic (/showthread.php?tid=409796)



Need some help for logic - maverape - 23.01.2013

Well, I have a textdraw login system on my server.

I have 5 buttons on this textdraw, each button has two numbers (random).
My question is, if my password is 123
how I'll put the numbers (the numbers that are in the buttons) in order?

Didn't get? Here's a photo just to try to explain better.


I'll click on the first box, and then on the second box and then on the third box

bot each box has two numbers, how can I do it to detect each number belongs to my password?


Re: Need some help for logic - Jefff - 23.01.2013

Something like that
pawn Код:
new numbers[MAX_PLAYERS][MAX_BUTTONS][MAX_NUMBERS_LENGHT];
new Text:textbox[MAX_PLAYERS][MAX_BUTTONS];
for(new d; d < sizeof(numbers[]); d++)
    valstr(numbers[playerid][d],(random(100)+1));
then

pawn Код:
http://wiki.sa-mp.com/wiki/OnPlayerClickTextDraw
+

pawn Код:
for(new d; d < sizeof(numbers[]); d++)
    TextDrawSetString(textbox[playerid][d],numbers[playerid][d]);
+

pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(textbox[playerid][0] <= clickedid <= textbox[playerid][4])
    {
        new num = (_:clickedid - _:textbox[playerid][0]);
        strcat(password_array[playerid],numbers[playerid][num],sizeof(password_array[]));
    }
    return 1;
}