SA-MP Forums Archive
my system only for 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: my system only for id 0? (/showthread.php?tid=154310)



my system only for id 0? - iStarzz - 13.06.2010

Only id 0 can gamble, when a higher ID try's to gamble it will say: you can only gamble once in the 30 seconds. :S

pawn Код:
dcmd_gamble(playerid, params[])
{
    #pragma unused params
    new string[128];
    if((allowgamble[playerid] == 1) && UserUD[playerid][cookies] > 50)
    {
    switch(random(9))
    {
    case 0:format(string, sizeof(string), "[GAMBLE] %s(id: %d) has gambled 5 cookies. Reward: $2000", UserUD[playerid][accname],playerid);
    }
  SendClientMessageToAll(rankupdate, string);
  allowgamble[playerid] = 0;
  SetTimerEx("gambleon", 30000, false, "i", playerid);
    }
    else if(allowgamble[playerid] == 0)
    {
    SendClientMessage(playerid,red,"Error: You can only gamble once in the 30 seconds!");
    }
    else
    {
    SendClientMessage(playerid,red,"Error: You need to have atleast 50 cookies to gamble!");
    }
    return 1;
}


public gambleon(playerid)
{
  allowgamble[playerid] = 1;
    return 1;
}



Re: my system only for id 0? - Dark_Kostas - 13.06.2010

Do you have allowgamble[playerid] = 1; at OnPlayerConnect? Also this code looks better
What will happen if the random is not 0? it will print nothing and you will have to wait 30secs for nothing lol. Also now you cant get the cash...
pawn Код:
dcmd_gamble(playerid, params[])
{
    #pragma unused params
    if(allowgamble[playerid] == 0) return SendClientMessage(playerid,red,"Error: You can only gamble once in the 30 seconds!");
    if(UserUD[playerid][cookies] < 50) return SendClientMessage(playerid,red,"Error: You need to have atleast 50 cookies to gamble!");
    new string[128];
    switch(random(9))
    {
        case 0:format(string, sizeof(string), "[GAMBLE] %s(id: %d) has gambled 5 cookies. Reward: $2000", UserUD[playerid][accname],playerid);
    }
    SendClientMessageToAll(rankupdate, string);
    allowgamble[playerid] = 0;
    SetTimerEx("gambleon", 30000, false, "i", playerid);
    return 1;
}


public gambleon(playerid)
{
    allowgamble[playerid] = 1;
    return 1;
}



Re: my system only for id 0? - TheInnocentOne - 13.06.2010

You are probably settings allowgamble[playerid] = 1; for ID 0 only.


Re: my system only for id 0? - iStarzz - 13.06.2010

i have this:
Код:
new allowgamble[MAX_PLAYERS] = 1;



Re: my system only for id 0? - MadeMan - 13.06.2010

Quote:
Originally Posted by FuTuRe`
i have this:
Код:
new allowgamble[MAX_PLAYERS] = 1;
This is it.

It only saves 1 to ID 0.


Re: my system only for id 0? - iStarzz - 13.06.2010

I already fixed it, i had to put under: OnPlayerConnect allowgamle =1 xD