Mute Command Problem
#1

Hello all i have a problem with my mute command its working fine but some times when i try to mute anyone for 2 minutes then it will show you That guy is muted for 200 minutes instead of 2 minutes but this problem is not happen every time there is the code of mute please check it and see any problem in it.

PHP код:
CMD:mute(playeridparams[])
{
    new 
giveplayeridgiveplayer[25], playername[25], strings1[140], strings2[140], strings3[140], strings4[140], string[140], moneys1tmp3[25];
    if (
adlvl[playerid] < 1) return 0;
    if (
sscanf(params"ud"giveplayeridmoneys1)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /mute [playerid] [time] [reason]");
    if (!
IsPlayerConnected2(giveplayerid)) return SendClientMessage2(playeridCOLOR_RED"Error: Inactive player id!");
    if (
moneys1 || moneys1 60) return SendClientMessage2(playeridCOLOR_WHITE"Error: Select a time between 1-60 minutes.");
    if (
giveplayerid == playerid) return SendClientMessage2(playeridCOLOR_RED"Error: You can't mute yourself!");
    
GetPlayerName(giveplayeridgiveplayerMAX_PLAYER_NAME);
    if (
adlvl[giveplayerid] >= adlvl[playerid] && adminuc[giveplayerid] == 0) return SendPlayerFormattedText(playeridCOLOR_RED"Error: You cannot mute %s."giveplayer"");
    if (
mutedtime[giveplayerid] != 0) return SendPlayerFormattedText(playeridCOLOR_RED"Error: %s is already muted."giveplayer"");
    if (
moneys1 || moneys1 60) return SendClientMessage2(playeridCOLOR_WHITE"Error: Select a time between 1-60 minutes.");
    
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
    
//mtimer[giveplayerid] = SetTimerEx("unmute", moneys1*60000, 0, "d", giveplayerid);
    
mutedtime[giveplayerid] = moneys1 60;
    if (
sscanf(params"uds[128]"giveplayeridmoneys1tmp3))
    {
        
format(strings1sizeof(strings1), "~ You have been muted by an admin for %d minute(s)."moneys1);
        
SendClientMessage2(giveplayeridCOLOR_REDstrings1);
        
format(strings2sizeof(strings2), "~ %s has been muted by an admin for %d minute(s)."giveplayermoneys1);
        
SendClientMessageToAll(COLOR_REDstrings2);
    }
    else
    {
        
format(strings3sizeof(strings3), "~ You have been muted by an admin for %d minute(s) for '%s'."moneys1,tmp3);
        
SendClientMessage2(giveplayeridCOLOR_REDstrings3);
        
format(strings4sizeof(strings4), "~ %s has been muted by an admin for %d minute(s) for '%s'."giveplayermoneys1,tmp3);
        
SendClientMessageToAll(COLOR_REDstrings4);
    }
    
SendPlayerFormattedText(playeridCOLOR_RED"You have muted %s."giveplayer"");
    if (
adminuc[playerid] == 0)
    {
        if (!
strlen(tmp3)) format(string128"Admin Log: %s has muted player %s (Id%d) for %d minute(s)."playernamegiveplayergiveplayeridmoneys1);
        else 
format(string128"Admin Log: %s has muted player %s (Id%d) for %d minute(s) for %s."playernamegiveplayergiveplayeridmoneys1tmp3);
        
SendMessageToAdmins(COLOR_ADMINstring);
    }
    
printf("[muted] %s has muted player %s (Id%d) for %d minutes."playernamegiveplayergiveplayeridmoneys1);
    return 
1;

Timer

PHP код:
//OnGameModInt
SetTimer("TimeUpdate"10001);
forward TimeUpdate();
public 
TimeUpdate()
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if (
mutedtime[i] != 0)
        {
                
mutedtime[i] --;
                if (
mutedtime[i] == 0)
                {
                    
GetPlayerName(istring1MAX_PLAYER_NAME);
                    
dini_Unset(AddDirFile(dir_userfilesstring1), "mutetime");
                       
SendClientMessage2(iCOLOR_ORANGE"You have been unmuted after serving the duration.");
                }
        }
    }

Reply
#2

Show the code of the command which gives that error and the code of the timer that reduces the mute time.
Reply
#3

Maybe because of your first sscanf line, you use 2 specifiers yet your usage has 3, I suggest you to add a reason (s[]) specifier.
Reply
#4

Problem solved

it was having issue on
PHP код:
mutedtime[giveplayerid] = moneys1 60
i was sending message after multiply jailtime with 60 seconds so it was showing message in 100 amount now i've put that code at last of code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)