Command time limited
#1

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;
}
Reply
#2

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

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

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

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!
Reply
#6

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

thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)