[HELP] Mute Command -
TwiiKzz - 15.01.2016
Hi everyone,
How can i change my /mute command for admins so i can use it /mute <ID> <Time/Minutes> <Reason> ?
My /mute command Auto mute for 60seconds, How can i change it ?
Код:
#define AUTO_MUTE_TIME 60
Код:
CMD:mute(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new id, reason[50];
if(isnull(params)) return SendClientMessage(playerid, yellow, "Usage: /mute <Player ID> <Reason>");
sscanf(params, "us[50]", id, reason);
if(IsPlayerConnected(id))
{
if(pInfo[id][Muted] == 1) return SendClientMessage(playerid,red,"This player is already muted. see /muted");
if(pInfo[playerid][pLevel] < pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
if(!isnull(reason))
format(Jstring,sizeof(Jstring),"Administrator %s has muted player '%s' | Reason: %s",GetName(playerid),GetName(id),reason);
else format(Jstring,sizeof(Jstring),"Administrator %s has muted '%s'",GetName(playerid),GetName(id));
SendClientMessageToAll(red,Jstring);
pInfo[id][Muted] = 1;
CommandToAdmins(playerid,"mute");
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}
Re: [HELP] Mute Command -
Sjn - 15.01.2016
PHP код:
// Top of your script
new
g_MuteTimer[MAX_PLAYERS],
g_MuteCounter[MAX_PLAYERS];
// On cnnect callback
public OnPlayerConnect(playerid)
{
g_MuteCounter[playerid] = 0;
g_MuteTimer[playerid] = -1;
return 1;
}
// On disconnect callback
public OnPlayerDisconnect(playerid, reason)
{
if (g_MuteTimer[playerid] != -1)
{
KillTimer(g_MuteTimer[playerid]);
}
return 1;
}
// Put this anywhere in your script
forward UnmutePlayer(playerid);
public UnmutePlayer(playerid)
{
if (g_MuteTimer[playerid] != -1)
{
if (g_MuteCounter[playerid] <= 0)
{
SendClientMessage(playerid, -1, "You have been un-muted.");
pInfo[playerid][Muted] = 0;
KillTimer(g_MuteTimer[playerid]);
g_MuteTimer[playerid] = -1;
}
else
g_MuteCounter[playerid]--;
}
}
CMD:mute(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new id, reason[50], time;
if(sscanf(params, "uis[50]", id, time, reason) return SendClientMessage(playerid, yellow, "Usage: /mute <Player ID> <Minutes> <Reason>");
if(IsPlayerConnected(id))
{
if(pInfo[id][Muted] == 1) return SendClientMessage(playerid,red,"This player is already muted. see /muted");
if(pInfo[playerid][pLevel] < pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
if(!isnull(reason))
format(Jstring,sizeof(Jstring),"Administrator %s has muted player '%s' | Reason: %s",GetName(playerid),GetName(id),reason);
else format(Jstring,sizeof(Jstring),"Administrator %s has muted '%s'",GetName(playerid),GetName(id));
SendClientMessageToAll(red,Jstring);
pInfo[id][Muted] = 1;
g_MuteCounter[id] = time * 60;
g_MuteTimer[id] = SetTimerEx("UnmutePlayer", 1000, true, "i", id);
CommandToAdmins(playerid,"mute");
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}
Not tested, should work tho.
Re: [HELP] Mute Command -
Crayder - 15.01.2016
If it were me, I'd use pInfo[id][Muted] to store the un-mute time.
Example:
pawn Код:
CMD:mute(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new id, time, reason[50];
if(isnull(params)) return SendClientMessage(playerid, yellow, "Usage: /mute <Player ID> <Time in seconds> <Reason>");
sscanf(params, "uus[50]", id, time, reason);
if(IsPlayerConnected(id))
{
if(pInfo[playerid][pLevel] < pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
if(!isnull(reason))
format(Jstring,sizeof(Jstring),"Administrator %s has muted player '%s' | Reason: %s",GetName(playerid),GetName(id),reason);
else
format(Jstring,sizeof(Jstring),"Administrator %s has muted '%s'",GetName(playerid),GetName(id));
SendClientMessageToAll(red, Jstring);
pInfo[id][Muted] = gettime() + (time * 1000);
CommandToAdmins(playerid,"mute");
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}
CMD:unmute:
pInfo[id][Muted] = 0;
OnPlayerText:
if(pInfo[id][Muted] > gettime())
return 0;
This is WAY better than using timers.
Re: [HELP] Mute Command -
TwiiKzz - 15.01.2016
Works!
Thank you