SA-MP Forums Archive
Command time limited - 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: Command time limited (/showthread.php?tid=426912)



Command time limited - elitesae - 30.03.2013

Please help, how to make it a player can use it only once every 5 sec, when you type /buygun it says ''Please wait 5 sec''

Код:
CMD:buygun(playerid, params[])
{
    if(!IsAtAmmu(playerid))
	{
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a Ammunation Shop");
        return 1;
    }
    else
    {
        ShowPlayerDialog(playerid, 30001, DIALOG_STYLE_LIST, "Ammunation Shop", "Shotgun (5000)\nMp5 (20000)\nDeagle (35000)\nM4 (75000)\nFullVest (3000)", "Buy", "Cancel");
	}
	return 1;
}



Re: Command time limited - zombieking - 30.03.2013

Use a timer.
There are some tutorials out there too:
https://sampforum.blast.hk/showthread.php?tid=245358



Re: Command time limited - elitesae - 30.03.2013

Quote:
Originally Posted by zombieking
Посмотреть сообщение
Use a timer.
There are some tutorials out there too:
https://sampforum.blast.hk/showthread.php?tid=245358
it wont work, i have no idea


Re: Command time limited - zombieking - 30.03.2013

Follow a tutorial then? Giving you the raw code won't help you understand it.

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 74 seconds.

^ It's killing me slowly.


Re: Command time limited - elitesae - 30.03.2013

Quote:
Originally Posted by zombieking
Посмотреть сообщение
Follow a tutorial then? Giving you the raw code won't help you understand it.


^ It's killing me slowly.
I have followed some tutorials but them just wont work, I know you can help please i know you are great!


Re: Command time limited - Pawnie - 30.03.2013

Here you go
Код:
//top of the script
new GunBuyCD;

forward GunBuyCD(playerid);
public GunBuyCD(playerid) 
{
        //Add here what do you want of the script to do after 5 seconds expire
	GunBuyCD = 0; //After the cooldown is over we are setting it to 0
	SendClientMessage(playerid, COLOR, "<!>You can now use /buygun!");
	return 1;
}

CMD:buygun(playerid, params[])
{
	if(GunBuyCD == 0) //If doesnt have cooldown
	{
	    SetTimerEx("GunBuyCD", 5000, false, "i", playerid); //Setting 5 sec cooldown
	    GunBuyCD = 1; //Setting the cooldown to 1
		//GivePlayerWeapon or whatver you want to add here
		return 1;
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "<!>On a cooldown!"); //Sending message if he/she is on a cooldown
	}
	return 1;
}
Edit: if(GunBuyCD == 0)


Re: Command time limited - elitesae - 30.03.2013

thanks!