set time for cmd
#1

I have a script like this, it works fine.
Код:
        if(!strcmp("/eat", cmdtext,true))
    {
        if(!IsPlayerInRangeOfPoint(playerid, 2.0, 240.1804,1117.3380,1080.9922))return SendClientMessage(playerid, 0xFF9900AA,"You are not in /eat checkpoint.");
        {
        ApplyAnimation(playerid, "FOOD", "EAT_Burger", 3.0, 0, 0, 0, 0, 0,1);
        new Float:health;
		GetPlayerHealth(playerid,health);
		SetPlayerHealth(playerid, health+20);
        return 1;
        }
but how could i make that after player writes /eat he needs to wait 3 seconds to write /eat again (so that "FOOD", "EAT_Burger" animation finishes)
Reply
#2

SetTimerEx or under some global 1 sec timer add CanEat[playerid]--; and in cmd CanEat[playerid] = 3;
Reply
#3

like, wtf... i tryed something... and like failed... could you make me an example? please
u could need this i think
Код:
forward eattimer();
Reply
#4

pawn Код:
new abletoeat[MAX_PLAYERS] = 1;
if(!strcmp("/eat", cmdtext,true))
    {
if(abletoeat[playerid] == 0) return SendClientMessage(playerid, 0xFF9900AA,"You can't eat that fast again! try again later!");
if(!IsPlayerInRangeOfPoint(playerid, 2.0, 240.1804,1117.3380,1080.9922))return SendClientMessage(playerid, 0xFF9900AA,"You are not in /eat checkpoint.");
        {
        ApplyAnimation(playerid, "FOOD", "EAT_Burger", 3.0, 0, 0, 0, 0, 0,1);
        new Float:health;
        GetPlayerHealth(playerid,health);
        SetPlayerHealth(playerid, health+20);
abletoeat[playerid] = 0;
SetTimerEx("eatagain","i",playerid,60*1000,false);
 return 1;
        }
pawn Код:
forward eatagain(playerid);
public eatagain(playerid)
{
abletoeat[playerid] = 1;
return 1;
}
have fun
Reply
#5

That is just a dumb solution. Use gettime() and PVars for things like this! http://pastebin.com/X9VRXJ5A
Reply
#6

Seven: I get a error 035: argument type mismatch (argument 2) at
Код:
SetTimerEx("eatagain","i",playerid,60*1000,false);
Luka P.: i get a warning 225: unreachable code
Код:
SetPVarInt(playerid, "Last Time Used", gettime());
EDIT: https://sampwiki.blast.hk/wiki/SetTimerEx

whats that "i" for anyway?
Reply
#7

Quote:
Originally Posted by nejc001
Посмотреть сообщение
Seven: I get a error 035: argument type mismatch (argument 2) at
Код:
SetTimerEx("eatagain","i",playerid,60*1000,false);
Luka P.: i get a warning 225: unreachable code
Код:
SetPVarInt(playerid, "Last Time Used", gettime());
EDIT: https://sampwiki.blast.hk/wiki/SetTimerEx

whats that "i" for anyway?
pawn Код:
SetTimerEx( "eatagain",60*1000,false,"i",playerid);
"i" is representing "integer", which means that the following value is an integer.
Reply
#8

Try now, updated (same link), forgot to move the return.
Reply
#9

still same error
Reply
#10

Err... it seems pastebin didn't update my post but I've updated it :X New link: http://pastebin.com/S4PAZ58z
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)