SA-MP Forums Archive
How can i create a cmd that can be used once in a while - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: How can i create a cmd that can be used once in a while (/showthread.php?tid=552304)



How can i create a cmd that can be used once in a while - RTRSorin - 23.12.2014

So, i want to create a command that can only be used, once a day. like:
/givememoney - give player 1000 dollars
*after used and try to use again:
/givememoney - " you already used this command today, try next after 24 hours "
a command that can be used once in a while.
any support please ?


Re: How can i create a cmd that can be used once in a while - Abagail - 23.12.2014

You can do something like this:

pawn Код:
CMD:giveallmoney(playerid, params[])
{
    if(IsPlayerAdmin(playerid)))
    {
        if(LastGiveAllMoney > gettime())
        {
               foreach(new i: Player)
               {
                    GivePlayerCash(i, 1000);
               }
               LastGiveAllMoney = gettime()+86400;
        }
        else return SendClientMessage(playerid, -1, "you can only do this every 24 hours !");
  }
   return 0;
}



Re: How can i create a cmd that can be used once in a while - RTRSorin - 23.12.2014

Quote:
Originally Posted by Abagail
Посмотреть сообщение
You can do something like this:

[pawn]
CMD:giveallmoney(playerid, params[])
{
i want players to use it, not me giving them money. but thank you for trying to help me.


Re: How can i create a cmd that can be used once in a while - Abagail - 23.12.2014

Something like this then:

pawn Код:
CMD:givememoney(playerid, params[])
{
     if(PlayerData[playerid][pLastCashGet] >= gettime())
     {
           GivePlayerCash(playerid, 1000);
           PlayerData[playerid][pLastCashGet] = gettime()+86400;
     }
     else return SendClientMessage(playerid, -1, "You have already used this command today. Try again tommorow.");
}



Re: How can i create a cmd that can be used once in a while - RTRSorin - 23.12.2014

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Something like this then:

pawn Код:
CMD:givememoney(playerid, params[])
{
     if(PlayerData[playerid][pLastCashGet] >= gettime())
     {
           GivePlayerCash(playerid, 1000);
           PlayerData[playerid][pLastCashGet] = gettime()+86400;
     }
     else return SendClientMessage(playerid, -1, "You have already used this command today. Try again tommorow.");
}
Thank you, +1 rep!