#1

how can i set a timer so you can use it only once in 10 seconds?

if(!strcmp(cmdtext,"/nitro",true))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF641AFF, "SERVER: You need to be in a vehicle to use /nitro.");
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, 0xFF641AFF, "SERVER: You have added nitro and repaired your vehicle.");
return 1;
}
Reply
#2

Use an array in your nos vehicle
pawn Код:
new nos[MAX_PLAYERS];//Global variable
pawn Код:
if(!strcmp(cmdtext,"/nitro",true))
  {
   if(nos[playerid] == 1) return SendClientMessage(playerid, COLOR, "You have to wait 10 seconds to use this command again.");
   else
   if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF641AFF, "SERVER: You need to be in a vehicle to use /nitro.");
   AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
   PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
   RepairVehicle(GetPlayerVehicleID(playerid));
   SendClientMessage(playerid, 0xFF641AFF, "SERVER: You have added nitro and repaired your vehicle.");
   nos[playerid] = 1;
   SetTimer("etc" 10000, false);
   return 1;
  }
Onplayerconnect
pawn Код:
nos[playerid] = 0;
pawn Код:
forward etc(playerid);
public etc(playerid)
{
if(nos[playerid] == 1) nos[playerid] = 0;
}
Didnt tested but it should work
Reply
#3

works your the best
Reply
#4

_Saif_'s code will work only for player with ID 0 because he's using SetTimer for playerid function (etc).
Reply
#5

Quote:
Originally Posted by _Saif_
Use an array in your nos vehicle
pawn Код:
new nos[MAX_PLAYERS];//Global variable
pawn Код:
if(!strcmp(cmdtext,"/nitro",true))
  {
   if(nos[playerid] == 1) return SendClientMessage(playerid, COLOR, "You have to wait 10 seconds to use this command again.");
   else
   if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF641AFF, "SERVER: You need to be in a vehicle to use /nitro.");
   AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
   PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
   RepairVehicle(GetPlayerVehicleID(playerid));
   SendClientMessage(playerid, 0xFF641AFF, "SERVER: You have added nitro and repaired your vehicle.");
   nos[playerid] = 1;
   SetTimer("etc" 10000, false);
   return 1;
  }
Onplayerconnect
pawn Код:
nos[playerid] = 0;
pawn Код:
forward etc(playerid);
public etc(playerid)
{
if(nos[playerid] == 1) nos[playerid] = 0;
}
Didnt tested but it should work

ehh, i'd check to see if they're in a legal nos vehicle first of all (dont want any client crashes).

Hmm also use SetTimerEx for public functions with parameters
Reply
#6

ok then try this one

pawn Код:
forward etc();
public etc()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(nos[i] == 1) nos[i] = 0;
}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)