timer -
GeneralAref - 03.12.2015
i need timer for command.this timer.
you must wait 20 sec to use this command.
you must wait 19 sec to use this command.
you must wait 18 sec to use this command.
you must wait 17 sec to use this command.
you must wait 16 sec to use this command.
you must wait 15 sec to use this command.
you must wait 14 sec to use this command.
Re: timer -
Lenon - 03.12.2015
You can make it like this:
Top of your script:
Код:
new commandTimer[MAX_PLAYERS];
Put this in command that you want to limit by timer:
Код:
commandTimer[playerid] = gettime() + 20; // player can use command every 20 seconds
Put this in top of command e.g using ycmd:
Код:
YCMD:command(playerid, params[], help) {
new timeLeft = gettime() - commandTimer[playerid], string[60];
if(gettime() < commandTimer[playerid]) {
format(string, sizeof(string), "You must wait %d seconds to use this command!", timeLeft);
SendClientMessage(playerid, -1, string);
return 1;
}
// rest of your code
return 1;
}
}
Re: timer -
GeneralAref - 03.12.2015
not works.
Re: timer -
Lenon - 03.12.2015
Post command.
Re: timer -
GeneralAref - 03.12.2015
Код:
CMD:ar(playerid, params[])
{
if(GetPVarInt(playerid,"AirReconOnline"))return SendClientMessage(playerid,COLOR_RED,"ERROR: You have already set the Air Recon Online!");
if(gTeam[playerid] != TEAM_Internationalforces && TEAM_America) return SendClientMessage(playerid,COLOR_RED,"ERROR: Your team dosent have Satellite!");
if(gTeam[playerid] == TEAM_Internationalforces && TEAM_America)
{
new playerState = GetPlayerState(playerid);
if(playerState != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,COLOR_RED,"ERROR: you must on foot to use this command!");
if(playerState == PLAYER_STATE_ONFOOT)
{
if(GetPlayerMoney(playerid) < 90000) return SendClientMessage(playerid,0xFF0000FF,"You dont have money to use Satellite!");
SendClientMessage(playerid,COLOR_BLUE,"i need air recon online!");
SendClientMessage(playerid,COLOR_BLUE,"copy that we are coming to your position in 2 sec!");
SendClientMessage(playerid,COLOR_RED,"You lost $90000 for air recon.");
TogglePlayerControllable(playerid, 0);
new Float:v, Float:c, Float:r;
GetPlayerPos(playerid, v, c, r);
SetPlayerCameraPos(playerid, v, c, r+30);
SetPlayerCameraLookAt(playerid, v, c, r);
SetTimer("endar", 60000, false);
GivePlayerMoney(playerid, -90000);
SetPVarInt(playerid,"AirReconOnline",true);
return SendClientMessage(playerid,COLOR_BLUE,"We are in your position you can use Satellite!");
}
}
return 1;
}
Re: timer -
Lenon - 03.12.2015
Tutorial:
https://sampforum.blast.hk/showthread.php?tid=583234
Re: timer -
GeneralAref - 04.12.2015
Quote:
Originally Posted by Lenon
|
not works.
Re: timer -
StR_MaRy - 04.12.2015
same is not working i tested , i have the same problem GeneralAref with a timer command cause i have /getgift and i can't get a timer for this cmd