Can anybody help?
#1

Can anyone add a timer to this command because i am new at scripting and dont how to do it
Reply
#2

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
Reply
#3

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.
Reply
#4

that's easy , i must go out right now but when i comeback i'll help u .
Reply
#5

ok thank you
Reply
#6

https://sampwiki.blast.hk/wiki/SetTimer
Reply
#7

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
Reply
#8

works fine thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)