01.01.2016, 12:25
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.
Timer
PHP код:
CMD:mute(playerid, params[])
{
new giveplayerid, giveplayer[25], playername[25], strings1[140], strings2[140], strings3[140], strings4[140], string[140], moneys1, tmp3[25];
if (adlvl[playerid] < 1) return 0;
if (sscanf(params, "ud", giveplayerid, moneys1)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /mute [playerid] [time] [reason]");
if (!IsPlayerConnected2(giveplayerid)) return SendClientMessage2(playerid, COLOR_RED, "Error: Inactive player id!");
if (moneys1 < 1 || moneys1 > 60) return SendClientMessage2(playerid, COLOR_WHITE, "Error: Select a time between 1-60 minutes.");
if (giveplayerid == playerid) return SendClientMessage2(playerid, COLOR_RED, "Error: You can't mute yourself!");
GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
if (adlvl[giveplayerid] >= adlvl[playerid] && adminuc[giveplayerid] == 0) return SendPlayerFormattedText(playerid, COLOR_RED, "Error: You cannot mute %s.", giveplayer, "");
if (mutedtime[giveplayerid] != 0) return SendPlayerFormattedText(playerid, COLOR_RED, "Error: %s is already muted.", giveplayer, "");
if (moneys1 < 1 || moneys1 > 60) return SendClientMessage2(playerid, COLOR_WHITE, "Error: Select a time between 1-60 minutes.");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
//mtimer[giveplayerid] = SetTimerEx("unmute", moneys1*60000, 0, "d", giveplayerid);
mutedtime[giveplayerid] = moneys1 * 60;
if (sscanf(params, "uds[128]", giveplayerid, moneys1, tmp3))
{
format(strings1, sizeof(strings1), "~ You have been muted by an admin for %d minute(s).", moneys1);
SendClientMessage2(giveplayerid, COLOR_RED, strings1);
format(strings2, sizeof(strings2), "~ %s has been muted by an admin for %d minute(s).", giveplayer, moneys1);
SendClientMessageToAll(COLOR_RED, strings2);
}
else
{
format(strings3, sizeof(strings3), "~ You have been muted by an admin for %d minute(s) for '%s'.", moneys1,tmp3);
SendClientMessage2(giveplayerid, COLOR_RED, strings3);
format(strings4, sizeof(strings4), "~ %s has been muted by an admin for %d minute(s) for '%s'.", giveplayer, moneys1,tmp3);
SendClientMessageToAll(COLOR_RED, strings4);
}
SendPlayerFormattedText(playerid, COLOR_RED, "You have muted %s.", giveplayer, "");
if (adminuc[playerid] == 0)
{
if (!strlen(tmp3)) format(string, 128, "Admin Log: %s has muted player %s (Id%d) for %d minute(s).", playername, giveplayer, giveplayerid, moneys1);
else format(string, 128, "Admin Log: %s has muted player %s (Id%d) for %d minute(s) for %s.", playername, giveplayer, giveplayerid, moneys1, tmp3);
SendMessageToAdmins(COLOR_ADMIN, string);
}
printf("[muted] %s has muted player %s (Id%d) for %d minutes.", playername, giveplayer, giveplayerid, moneys1);
return 1;
}
PHP код:
//OnGameModInt
SetTimer("TimeUpdate", 1000, 1);
forward TimeUpdate();
public TimeUpdate()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if (mutedtime[i] != 0)
{
mutedtime[i] --;
if (mutedtime[i] == 0)
{
GetPlayerName(i, string1, MAX_PLAYER_NAME);
dini_Unset(AddDirFile(dir_userfiles, string1), "mutetime");
SendClientMessage2(i, COLOR_ORANGE, "You have been unmuted after serving the duration.");
}
}
}
}