04.02.2014, 18:41
Hello,
I have been busy trying to make a /mute command with a time parameter using sscanf. I saw alot of examples and gladly used them...BUT somehow it isnt working (otherwise i wont write here duh XD).
I'll try to explain what happens:
Ingame enter' /mute 0 5 ' ( 0 for playerid and 5 for seconds )
but somehow the timer that i use responds faster then that and i always get the message ;
You have been muted by 'playername' for 0 seconds! You cant talk!
it always does...even when i enter 9 or 50 seconds i get this message right away.
I thought it was just sscanf being old or something so i decided to try zcmd.
Without any luck and the exact same problem..here is the code i left the variables out for now
i always check with messages first.
I have been busy trying to make a /mute command with a time parameter using sscanf. I saw alot of examples and gladly used them...BUT somehow it isnt working (otherwise i wont write here duh XD).
I'll try to explain what happens:
Ingame enter' /mute 0 5 ' ( 0 for playerid and 5 for seconds )
but somehow the timer that i use responds faster then that and i always get the message ;
You have been muted by 'playername' for 0 seconds! You cant talk!
it always does...even when i enter 9 or 50 seconds i get this message right away.
I thought it was just sscanf being old or something so i decided to try zcmd.
Without any luck and the exact same problem..here is the code i left the variables out for now
i always check with messages first.
pawn Код:
COMMAND:mute(playerid,params[])
{
new Target, seconds;
if(!sscanf(params, "ui", Target, seconds))
{
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
if(seconds != 0)
{
new tname[MAX_PLAYER_NAME];
GetPlayerName(Target,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new tstring[256];
new pstring[256];
format(tstring,sizeof(tstring),"You have been muted by %s! You cant talk!",pname);
format(pstring,sizeof(pstring),"You have muted player %s(%d)",tname,Target);
SendClientMessage(Target,COLOR_RED,tstring);
SendClientMessage(playerid,COLOR_GREEN,pstring);
}
else if(seconds >= 0)
{
new tname[MAX_PLAYER_NAME];
GetPlayerName(Target,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new tstring[256];
new pstring[256];
format(tstring,sizeof(tstring),"You have been muted by %s for %d seconds! You cant talk!",pname, seconds);
format(pstring,sizeof(pstring),"You have muted player %s(%d) for %d seconds",tname,Target,seconds);
SendClientMessage(Target,COLOR_RED,tstring);
SendClientMessage(playerid,COLOR_GREEN,pstring);
SetTimerEx("UnmutePlayer", seconds * 1000, false, "d", Target);
}
}
else SendClientMessage(playerid,COLOR_YELLOW,"USAGE: /mute <playerid> <seconds-optional>");
return 1;
}
forward UnmutePlayer(playerid);
public UnmutePlayer(playerid)
{
SendClientMessage(playerid,COLOR_GREEN,"[AUTO-UNMUTE]: You are now unmuted and able to talk!");
}