why wont this /mute time work
#1

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.

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!");


}
Reply


Messages In This Thread
why wont this /mute time work - by AIped - 04.02.2014, 18:41
Re: why wont this /mute time work - by Borg - 04.02.2014, 19:19
Re: why wont this /mute time work - by AIped - 04.02.2014, 19:52
Re: why wont this /mute time work - by Borg - 04.02.2014, 19:58
Re: why wont this /mute time work - by AIped - 04.02.2014, 20:14

Forum Jump:


Users browsing this thread: 2 Guest(s)