Help Add CMD limit in this system
#1

how to add time limit for this system so player must wait 1 second for use this system again

Код:
//-----------[barrel trap]----------------//
	if (newkeys == KEY_SUBMISSION)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new
				Float:x,
				Float:y,
				Float:z;
			{
		  	  if(GetPlayerMoney(playerid) >= 2000)
 	 			{
            		GetPlayerPos(playerid, x, y, z);
					CreateObject(1225,x,y,z, 0.00, 0.00, 0.00);
                    SendClientMessage(playerid,purple,"You have put a trap");
					GivePlayerMoney(playerid, -2000);
				}
   				else
				{
					SendClientMessage(playerid,purple,"You Dont Have Enough Money");
				}
			}
		
		}
		return 1;
SORRY MY BAD ENGLISH
Reply
#2

There are several ways you can do this, all require you to create a variable to store the time when the player used the system last or if the player has used it. The first method is using a timer, when the command is successfully performed, set a player variable to 1 and SetTimerEx for the desired amount of time to reset the variable. You can then write a conditional statement before to check if the variable equals 0, if not, don't do anything.

The second and third methods are closely related. Instead of a boolean, you need to store the current tick count using GetTickCount or a unix timestamp using gettime when the command is successfully performed, then evaluate the variable against the count / time when the command is next performed.

I'm sure someone will come along and script the entire thing for you but I just wanted to encourage you to learn to do things by yourself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)