Limit a command
#1

Hello everybody, I am making this post so that someone could help me. I have a command and i would like to add something that makes it only usable per player per ten seconds , im doing this because players abuse of the command and i would whant to add something that can make the command only usable once every ten seconds or so.

the command looks like this:

Код:
	if(strcmp(cmd, "/sync", true) == 0) {
	  if(IsPlayerInAnyVehicle(playerid)){
	  SendClientMessage(playerid, COLOR_YELLOW, "Canot use this while in veh");
	  return 1;
	  }
		SpawnPlayer(playerid);
		return 1;
	}
Reply
#2

Try using a timer for it
Reply
#3

on top of script

Код:
new time[MAX_PLAYERS], timetimer;
forward 10sec(playerid);
Код:
if(strcmp(cmd, "/sync", true) == 0) 
{
if(time[playerid] == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "You have to wait 10 secounds before use this cmd again");
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_YELLOW, "Canot use this while in veh");
return 1;
}
SpawnPlayer(playerid);
timetimer = SetTimer("10sec", 10*1000, 0);
time[playerid] = 1;
return 1;
}

public 10sec(playerid)
{
time[playerid] = 0;
}
meh dont tested hope it works... xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)