SA-MP Forums Archive
adding variable to cmd so u cant use it.. again - 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: adding variable to cmd so u cant use it.. again (/showthread.php?tid=114142)



adding variable to cmd so u cant use it.. again - DiddyBop - 17.12.2009

How do i add a variable to this script witch gives them an else "you can only try once!" ?

Here is script..

pawn Код:
if (strcmp("/lotto", cmd, true) == 0)
    {
        new tmp[256], cmdid, string[256], pname[MAX_PLAYER_NAME];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, red, "USAGE: /Lotto (number)");
        cmdid = strval(tmp);

        if(cmdid < answer || cmdid > answer)
        {
            SendClientMessage(playerid, red, "Not a winner! bummer! 15000$ Has been taken for the lotto ticket!");
            GivePlayerMoney(playerid, -15000);
        }
       
        if(cmdid == answer && answered == 0)
        {
        new RandomCash = random(125000)+25000;
        new month, day, year;
        getdate(year, month, day);
        GetPlayerName(playerid, pname, sizeof(pname));
        format(string, sizeof(string), "%s has won $%d from the lottery! Winning Number: %d !", pname,GetPlayersOnline() + RandomCash,cmdid);
        SendClientMessageToAll(green, string);
        print(string);
        new File:mw = fopen("lottowins.txt", io_append);
        format(string, sizeof string, "%s Has won $%d On %d/%d/%d from lotto! Winning Number: %d--\r\n",pname,GetPlayersOnline() + RandomCash,month,day,year,score,cmdid);
        fwrite(mw, string);
        fclose(mw);

            answered = 1;
            SetPlayerScore(playerid, GetPlayerScore(playerid) + score);
            GivePlayerMoney(playerid, GetPlayersOnline() + RandomCash);
            score = 0;
            //money = 0;
            return 1;
        }
        else if(cmdid == answer && answered == 1)
        {
            SendClientMessage(playerid, red, "Lotto has already been won!");
        }
        return 1;
    }
Trying to make a lotto script!

But i dont want them guessing the lotto number spamming the command like..

/lotto 1
/lotto 2
/lotto 3

and so on..


Re: adding variable to cmd so u cant use it.. again - BLAbla93 - 17.12.2009

could u add a timer or disable the command for so long...
or even better when they use the command it disables it.
then when the lotto goes off it re in ables it ...

as a idea.


Re: adding variable to cmd so u cant use it.. again - DiddyBop - 17.12.2009

yes.. i want it to disable the command for them untill it re-calls the lotto..


Re: adding variable to cmd so u cant use it.. again - BLAbla93 - 17.12.2009

then use a enum or something >.>

then when they use the command have it set it to = 1
and when the lotto goes off have it set it for everyplayer connected = 0
and if the player has it set to = 1 then have it return something
Ex return SendClientMessage(playerid, COLOR, "Error: you can only use the lotto once per round");


Re: adding variable to cmd so u cant use it.. again - DiddyBop - 18.12.2009

thx blabla i got it workin


Re: adding variable to cmd so u cant use it.. again - BLAbla93 - 18.12.2009

no problem

im a small clucker but im not and idiot xD