SA-MP Forums Archive
showing lotto ticket only for 1st player (ID 0) - 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: showing lotto ticket only for 1st player (ID 0) (/showthread.php?tid=263617)



showing lotto ticket only for 1st player (ID 0) - lvlaid - 22.06.2011

me again with ID 0

when ID other then ID 0 buys a ticket,it shows up on textdraw and everythings seems ok, BUT when ID 0 buys ticket, it changes to HIS number so if I bought number 24 and ID 0 is buying after me number 7, the number 7 will replace my number on textdraw

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);

    if(IsPlayerInRangeOfPoint(playerid, 2.0, -2161.1206,640.3578,1052.3817))
    if (strcmp(cmd, "/buyticket", true) == 0) //so I buy ticket
    {
            new dir[256];
            dir = strtok(cmdtext, idx);
                if (!strlen(dir))
                {
                    SendClientMessage(playerid, COLOR_RED, "USE: /buyticket [number]");
                    return 1;
                }
            new number = strval(dir);
            new interior = GetPlayerInterior(playerid);
            if (interior == 1)
            {
                if (LottoParticipant[playerid] == 1)
                {
                    SendClientMessage(playerid, COLOR_RED, "U alrdy took ticket!");
                }
                else
                {
                    if (GetPlayerMoney(playerid) >= LOTTO_PRICE)
                    {
                        if (number > 0 && number < 100)
                        {
                            if (NumberUsed[number] == 0)
                            {
                                new string[256];
                                format(string, sizeof(string), "~y~Ticket number: ~r~%d", number);
                                                                TextDrawSetString(listic, string);
                                TextDrawShowForPlayer(playerid, listic);     //so text draw show up,and if player ID is other the 0,it shows correct number until player which has ID number 0 buy ticket,then all other players see only his ticket number?

                                PlayerLottoGuess[playerid] = number;
                                LottoParticipant[playerid] = 1;
                                GivePlayerMoney(playerid, -LOTTO_PRICE);
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_RED, "Alrdy bought.");
                            }

                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_RED, "Wrong number.");
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "No money.");
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Only buy at lottery.");
            }

    return 1;
    }

    return 0;
}



Re: showing lotto ticket only for 1st player (ID 0) - lvlaid - 27.06.2011

anyone?


Re: showing lotto ticket only for 1st player (ID 0) - Unknown_Killer - 27.06.2011

|
|
|
\/


Re: showing lotto ticket only for 1st player (ID 0) - Vince - 27.06.2011

Quote:
Originally Posted by Unknown_Killer
Посмотреть сообщение
u should make a loop for each player
Wrong. You need to make a textdraw for each player.

new Text:listic[MAX_PLAYERS]


Re: showing lotto ticket only for 1st player (ID 0) - lvlaid - 10.07.2011

finally made it,thank you man

I added [MAX_PLAYERS] to textdraw like you said and used this code where need it:

for(new playerid; playerid<MAX_PLAYERS; playerid++)
{
// your script here
}

ty