SetTimer 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)
+--- Thread: SetTimer Help (
/showthread.php?tid=467536)
SetTimer Help -
efrim123 - 03.10.2013
Hello
i have a problem with making the settimer for my command
can you put it there for me
and i want that it will send a message for the player that has already used the command
"You need to wait before using this command agian!"
pawn Код:
CMD:gunpack1(playerid,params[])
{
if(pInfo[playerid][Scores] >= 300)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have succesfully used gunpack1!");
GivePlayerWeapon(playerid, 11, 0);
GivePlayerWeapon(playerid, 22, 250);
GivePlayerWeapon(playerid, 29, 350);
GivePlayerWeapon(playerid, 30, 400);
}
else return SendClientMessage(playerid, COLOR_RED, "You need 300 score to use this command!");
return 1;
}
Re: SetTimer Help -
DanishHaq - 03.10.2013
There are probably simpler ways to do this, but this'd work too I think:
pawn Код:
new gunpack1var[MAX_PLAYERS];
public OnGameModeInit();
{
SetTimer("SecondTimer", 1000, true);
return 1;
}
CMD:gunpack1(playerid,params[])
{
if(gunpack1var[playerid] >= 1)
{
new string[100];
format(string, sizeof(string), "You cannot use this command for another %d seconds.", gunpack1var[playerid]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
if(pInfo[playerid][Scores] >= 300)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have succesfully used gunpack1!");
GivePlayerWeapon(playerid, 11, 0);
GivePlayerWeapon(playerid, 22, 250);
GivePlayerWeapon(playerid, 29, 350);
GivePlayerWeapon(playerid, 30, 400);
gunpack1var[playerid] = 30;
}
else return SendClientMessage(playerid, COLOR_RED, "You need 300 score to use this command!");
return 1;
}
forward SecondTimer();
public SecondTimer()
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(gunpack1var[i] > 1)
{
gunpack1var[i] --;
}
if(gunpack1var[i] == 1)
{
gunpack1var[i] = 0;
SendClientMessage(i, COLOR_LIGHTBLUE, "You can now use the /gunpack1 command again.");
}
}
return 1;
}
Re: SetTimer Help -
efrim123 - 03.10.2013
Thank you it worked !!! 1+ REP
Re: SetTimer Help -
efrim123 - 03.10.2013
Sorry for double post
but i tested it and it compiled in pawn fine
but when i use my command twice it dosent show me the message that needs to be shown and it gives me the
weapons always too
Re: SetTimer Help -
-Prodigy- - 03.10.2013
pawn Код:
new waitTime[MAX_PLAYERS];
CMD:gunpack1(playerid,params[])
{
if(waitTime[playerid] - gettime() > 0)
{
new str[128];
format(str, sizeof(str), "Please wait %d seconds to use this command again", waitTime[playerid] - gettime());
return SendClientMessage(playerid, -1, str);
}
if(pInfo[playerid][Scores] >= 300)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have succesfully used gunpack1!");
GivePlayerWeapon(playerid, 11, 0);
GivePlayerWeapon(playerid, 22, 250);
GivePlayerWeapon(playerid, 29, 350);
GivePlayerWeapon(playerid, 30, 400);
waitTime[playerid] = gettime() + 20; // 20 second wait
}
else return SendClientMessage(playerid, COLOR_RED, "You need 300 score to use this command!");
return 1;
}
Re: SetTimer Help -
efrim123 - 03.10.2013
Thanks i tested it and it worked +1 REP
Re: SetTimer Help -
Blueflash123 - 04.10.2013
Congrats on getting it working