Can anybody 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: Can anybody help? (
/showthread.php?tid=381737)
Can anybody help? -
sl!x - 30.09.2012
Can anyone add a timer to this command because i am new at scripting and dont how to do it
Re : Can anybody help? -
Amine_Mejrhirrou - 30.09.2012
explain what are you looking for by the script and what are u expecting from us to do , cause adding a timer is simple and it takes less than 20 seconds ... give more infos
Re: Can anybody help? -
sl!x - 30.09.2012
ok sry for bad english and bad explanation
If you could add a timer to the script so that when you press /sniper you have to wait 1 minute to type it again.
Or if you could when a player connect he can use the command and then he cant use it again until he dies so after his death he can type the command again.
Re : Can anybody help? -
Amine_Mejrhirrou - 30.09.2012
that's easy , i must go out right now but when i comeback i'll help u .
Re: Can anybody help? -
sl!x - 30.09.2012
ok thank you
Re: Can anybody help? -
trapstar2020 - 30.09.2012
https://sampwiki.blast.hk/wiki/SetTimer
Re : Can anybody help? -
Amine_Mejrhirrou - 30.09.2012
Ok so i'm gonna try to Explain the script
(i'm not apro scripter but this should work)
First let put this in the top of the FS / GM
Код:
forward inf2(playerid);//this will be the timer (public)
new inf[MAX_PLAYERS];//this is related to the timer for the player
new blabla[ MAX_PLAYERS ];//and this will be usefull to defind when a player can use the CMD again
ok now let's take a look to the timer
at OnPlayerSpawn you gonna set your a counter for the player to make him use the /sniper CMD
Код:
blabla[ playerid ] = 0;// 0 is when the player can use the CMD, 1 is when he can't
Now Let's go to the CMD that u called /sniper
so when the player use /sniper the script will check if he have acces to it or not
we said befor that 1 is when he can't and 0 is when he can
Код:
if(!strcmp(cmdtext,"/sniper",true, 6))
{
if( blabla[ playerid ] == 1)return GameTextForPlayer(playerid, "~w~You can't use this Command for now", 3000, 4);
inf[playerid] = SetTimerEx("inf2", 60000, false, "i", playerid);// start the timer for the player !
blabla[ playerid ] = 1;//The player is using /sniper cmd, so he can't use it again for 1min
//add what u want like resetplayerweaons, giveplayerweapon ects ...
}
Right, now let's see what we gonna put in when the timer is over
remeber that the timer name is inf2
Код:
public inf2(playerid)
{
if( blabla[ playerid ] == 1)
{
blabla[ playerid ] = 0;// 1min is passed so now he can use /sniper again
GameTextForPlayer(playerid, "~w~You can use /sniper again", 3000, 4);
KillTimer(inf[playerid]);//kill the timer for the player
}
return 1;
}
hope it works
Re: Can anybody help? -
sl!x - 01.10.2012
works fine thank you.