how to make 'Please wait before use command' -
MWhite_005 - 14.07.2011
hey guys im basically new to scripting and i was wonder,how to add a timer to make before using a command again
here is my script :
dcmd_ad (playerid, params[])
{
#pragma unused params
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 100)
{
SetPlayerHealth(playerid, health +100);
SendClientMessage(playerid, 0x00FF00AA, "adrenaline pill has been utilised");
}
return 1;
}
Re: how to make 'Please wait before use command' - [L3th4l] - 14.07.2011
No need for timers on something like this. I suggest you read this topic:
https://sampforum.blast.hk/showthread.php?tid=254915
It explains how to create temporary systems. What would you do is create a variable for all players. Add the temp time to gettime() and store it onto the variable. If you still need help post back.
Re: how to make 'Please wait before use command' -
Ricop522 - 14.07.2011
new usable[MAX_PLAYERS];
//command
usable[playerid] = gettime() + 5;
if(usable[playerid] < gettime()) return SendClientMessage(playerid, -1, "You already use this command !");
is this? =p
Re: how to make 'Please wait before use command' -
grand.Theft.Otto - 14.07.2011
Under your command
pawn Код:
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Using Another Adrenaline Pill.");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+10000); // every 10 secs
Re: how to make 'Please wait before use command' -
MWhite_005 - 14.07.2011
TY sooo much guys,it compiled and everything but its doing both teh msg and the command
dcmd_ad (playerid, params[])
{
#pragma unused params
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 100)
{
SetPlayerHealth(playerid, health +100);
SendClientMessage(playerid, 0x00FF00AA, "Adrenaline pill has been utilised");
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Using Another Adrenaline Pill.");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+6000 0);
}
return 1;
}
Re: how to make 'Please wait before use command' -
MWhite_005 - 14.07.2011
TY sooooooooooooo much guys,i got it

yall are all so good at this

.
i basically just rearranged it
:
dcmd_ad (playerid, params[])
{
#pragma unused params
new Float:health;
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Using Another Adrenaline Pill.");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+6000 0);
GetPlayerHealth(playerid,health);
if (health < 100)
{
SetPlayerHealth(playerid, health +100);
SendClientMessage(playerid, 0x00FF00AA, "Adrenaline pill has been utilised");
}
return 1;
}
Re: how to make 'Please wait before use command' - [L3th4l] - 14.07.2011
No need for that. You can use Unixtime stamps:
pawn Код:
new
iCanUse[MAX_PLAYERS];
dcmd_ad(playerid, params[])
{
#pragma unused params
if(iCanUse[playerid]-gettime() > 0) return SendClientMessage(playerid, 0xFF0000AA, "Please wait before using another Adrenaline Pill!");
new
Float:iHealth;
GetPlayerHealth(playerid, iHealth);
if(iHealth < 100)
{
SetPlayerHealth(playerid, iHealth + 100);
SendClientMessage(playerid, 0x00FF00AA, "Adrenaline Pill has been utilized!");
iCanUse[playerid] = gettime() + 60; // 60 seconds
}
return 1;
}
Re: how to make 'Please wait before use command' -
hulitubolies - 14.07.2012
And thoes aerros occured
Код:
D:\Documents and Settings\ScOuT3221\Desktop\SAMPSERVER\gamemodes\ZRP.pwn(6589) : warning 225: unreachable code
D:\Documents and Settings\ScOuT3221\Desktop\SAMPSERVER\gamemodes\ZRP.pwn(6611) : warning 225: unreachable code
Re: how to make 'Please wait before use command' -
hulitubolies - 14.07.2012
How can i add Script that it says how mutch time is left before can use it agen ??