PDA

View Full Version : /Mute timer


Axey187
12/01/2015, 01:19 PM
CMD:mute(playerid, params[])
{
new targetid, minutes, reason[128], string[128];
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "Mute: /mute (id) (minutes) (reason)");
format(string, sizeof(string), "Administrator %s muted %s for %d minutes (%s)", PlayerName(playerid), PlayerName(targetid), minutes, reason);
SendClientMessageToAll(COLOR_RED, string);
SetTimer("Unmute", minutes*60000, 0);
return 1;
}
forward Unmute(playerid);
public Unmute(playerid)
{
SendClientMessage(playerid, COLOR_RED, "You have been unmuted automatically by server");
return 1;
}

The timer is not working, It should have sent a client message informing that im unmuted, but no message was sent.

rickisme
12/01/2015, 01:22 PM
because playerid is invalid

use SetTimerEx instead SetTimer ( http://wiki.sa-mp.com/wiki/SetTimerEx ) or just use YSI for simple timer :)

HY
12/01/2015, 01:25 PM
SetTimerEx("Unmute", minutes*1000, false, "i", playerid);

forward Unmute(playerid);
public Unmute(playerid)
{
SendClientMessage(playerid, COLOR_RED, "You have been unmuted automatically by server");
return 1;
}

Axey187
12/01/2015, 01:30 PM
Thank you all for helping. It worked.