help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help (
/showthread.php?tid=132939)
help -
jamesbond007 - 10.03.2010
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;
}
Re: help -
Deat_Itself - 10.03.2010
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 Код:
forward etc(playerid);
public etc(playerid)
{
if(nos[playerid] == 1) nos[playerid] = 0;
}
Didnt tested but it should work
Re: help -
jamesbond007 - 10.03.2010
works your the best
Re: help -
Correlli - 10.03.2010
_Saif_'s code will work only for player with ID 0 because he's using SetTimer for playerid function (
etc).
Re: help -
Kyosaur - 10.03.2010
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 Код:
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
Re: help -
Deat_Itself - 10.03.2010
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;
}
}