SetTimer on a /mute command
#1

Okay I have made my mute command, it works alright but I dont want to have to type /unmute I want there to be a timer, so I added a timer but I cant get it to work can you help please

Код:
if(strcmp(cmd,"/mute",true) == 0)
{
	new tmp[256];
	new id;
	tmp = strtok(cmdtext, idx);
	if(PlayerInfo[playerid][Level] <= 1)
	{
		SendClientMessage(playerid,RED,"You have to be Level 2 to use this command!");
		return 1;
	}
	if(Logged[playerid] == 0)
	{
		SendClientMessage(playerid,BRIGHTRED,"Please login before you use this command!");
		return 1;
	}
	if(!strlen(tmp))
	{
		SendClientMessage(playerid,WHITE,"SERVER: /mute [id]");
		return 1;
	}
	id = strval(tmp);
	if(!IsPlayerConnected(id))
	{
		SendClientMessage(playerid,WHITE,"SERVER: Invalid ID.");
   		return 1;
	}

	tmp = strtok(cmdtext, idx);
	new string[128];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	new nname[MAX_PLAYER_NAME];
	GetPlayerName(id,nname,sizeof(nname));
	format(string,sizeof(string)," * You have muted %s *",nname);
	SendClientMessage(playerid,YELLOW,string);
	format(string,sizeof(string)," * you have been muted by %s. dont try to speak because you are muted!",name);
	SendClientMessage(id,BRIGHTRED,string);
	SetTimerEx("MuteTimer", 6000, false, "i", nname);
	PlayerInfo[id][Muted] = 1;
	return 1;
}
and then the timer is
Код:
public MuteTimer(playerid)
{
	PlayerInfo[playerid][Muted] = 0;
	SendClientMessage(playerid,BRIGHTRED,"You have been unmuted");
	return 1;
}
I try testing it on myself, it mutes me and then i wait like 5 minutes and it still doesnt unmute me, if this helps here is the onplayertext thing

Код:
public OnPlayerText(playerid, text[])
{
if(PlayerInfo[playerid][Muted] == 1)
{
	return 0;
}
return 1;
}
anyone tell me why it isnt unmuting me?
Reply
#2

You need to be using the variable "id" instead of "nname" because you set the parameter of "i" for the SetTimerEx which stands for integer.

SetTimerEx("MuteTimer", 6000, false, "i", id);
Reply
#3

yes thankyou it worked your my hero
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)