SetTimer on a /mute command - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetTimer on a /mute command (
/showthread.php?tid=169522)
SetTimer on a /mute command -
mrcoolballs - 19.08.2010
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?
Re: SetTimer on a /mute command -
Backwardsman97 - 20.08.2010
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);
Re: SetTimer on a /mute command -
mrcoolballs - 20.08.2010
yes thankyou it worked your my hero