How to set TIMER for 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: How to set TIMER for a command? (
/showthread.php?tid=552905)
How to set TIMER for a command? -
davidstyle1125 - 27.12.2014
Hello, I have got this command:
pawn Код:
CMD:parkourprize(playerid, params[]) {
if(IsPlayerInRangeOfPoint(playerid, 3, -136.100921, 2145.677246, 292.571868)) {
SetPlayerPos(playerid, 1756.725952, -1770.319335, 17.227943);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerHealth(playerid, 100);
StopAudioStreamForPlayer(playerid);
new giveplayerid;
new value = random(4);
if(value == 0)
{
PlayerInfo[giveplayerid][pCash] += 10000;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 10,000$!");
}
else if(value == 1)
{
PlayerInfo[giveplayerid][pCrack] += 50;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 50 grams of crack!");
}
else if(value == 2)
{
PlayerInfo[giveplayerid][pMats] += 10000;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 10,000 materials!");
}
else if(value == 3)
{
PlayerInfo[giveplayerid][pPot] += 100;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 100 grams of pot!");
}
return 1;
}
}
I want that players will be able to use this command once a hour/paycheck... could you please assist me ?
Re: How to set TIMER for a command? -
Eyce - 27.12.2014
Try this out:
pawn Код:
forward ResetPrize(playerid)
public ResetPrize(playerid)
{
Player[playerid][pResetPrize] = 0;
}
// MAKE A PLAYER VARIABLE FOR THE PRIZE (WHERE YOU ALSO SAVE YOUR PLAYER'S STATS)
CMD:parkourprize(playerid, params[])
{
if(Player[playerid][pResetPrize] != 0)
{
SendClientMessage(playerid, -1, "Please wait for your reload time before collecting another prize"); // ERROR MESSAGE
return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 3, -136.100921, 2145.677246, 292.571868)) {
SetPlayerPos(playerid, 1756.725952, -1770.319335, 17.227943);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerHealth(playerid, 100);
StopAudioStreamForPlayer(playerid);
SetTimerEx("ResetPrize", 3600000, false, "i", playerid); // SET TIMER TO 1 HOUR TO CLEAR
Player[playerid][pResetPrize] = 1;
new giveplayerid;
new value = random(4);
if(value == 0)
{
PlayerInfo[giveplayerid][pCash] += 10000;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 10,000$!");
}
else if(value == 1)
{
PlayerInfo[giveplayerid][pCrack] += 50;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 50 grams of crack!");
}
else if(value == 2)
{
PlayerInfo[giveplayerid][pMats] += 10000;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 10,000 materials!");
}
else if(value == 3)
{
PlayerInfo[giveplayerid][pPot] += 100;
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations, you won 100 grams of pot!");
}
return 1;
}
}