Full tutorial how to put a timer on a command! - 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)
+--- Thread: Full tutorial how to put a timer on a command! (
/showthread.php?tid=327572)
Full tutorial how to put a timer on a command! -
TheCow - 21.03.2012
Hello.
I need a full tutorial of how can I put a timer on a command.
I want the player who used command /assist wait 5 min before he can use that cmd again.
Please fast help, and sorry for my crappy english.
pawn Код:
COMMAND:assist(playerid, params[])
{
// Setup local variables
new bool:AssistOnline = false, Msg[128], Name[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/assist", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Get the player's name
GetPlayerName(playerid, Name, sizeof(Name));
// Preset the message that needs to be sent to assistance players
format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} needs assistance, go help him", Name);
// Check if there is at least one assistance player online
for (new i; i < MAX_PLAYERS; i++)
{
// Check if this player is connected
if (IsPlayerConnected(i))
{
// Check if this player is assistance class
if (APlayerData[i][PlayerClass] == ClassAssistance)
{
// Set the flag to indicate that at least one assistance player is online
AssistOnline = true;
// Send the assistance player a message to inform him who needs assistance
SendClientMessage(i, 0xFFFFFFFF, Msg);
}
}
}
// Check if there is at least one assistance player online
if (AssistOnline == true)
{
// Set yourself as "AssistanceNeeded"
APlayerData[playerid][AssistanceNeeded] = true;
// Let the player know he called for assistance
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've called for assistance");
}
else // No assistance is online
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Fully repair the vehicle (damage value and bodywork)
RepairVehicle(GetPlayerVehicleID(playerid));
// Also re-fuel the vehicle
AVehicleData[GetPlayerVehicleID(playerid)][Fuel] = MaxFuel;
// Let the player pay for the repairs and refuel (default $2000)
RewardPlayer(playerid, -2000, 0);
// Let the player know he spent $2000 for auto-repair because there were no assistance players online
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Your vehicle has been auto-repaired and refuelled for $2000");
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}because there is no assistance player online");
}
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Im using PPC_Trucking GM!
Re: Full tutorial how to put a timer on a command! -
Blunt - 21.03.2012
You should just forward a timer, stock it, then use SetTimerEx with either a enum changing function.
Re: Full tutorial how to put a timer on a command! -
TheCow - 21.03.2012
I said im using PPC_Trucking, I dont understand anything that is written there.
There is everything seperated, Commands, defines and shit. All in different includes
Just say me the code too.