Command /mute -
FL3GM4 - 14.12.2012
I tried to make command mute, but i dont know how to make it with timer..
i want to mute players on some time..but here is only for mute, and i need to unmute player if he wanna talk again, but i want that mute gone alone, when time go out
Код:
CMD:mute(playerid, params[])
{
new id, string[128];
if(PlayerInfo[playerid][pAdmin] < 1)return NisiAdmin(playerid);
else if(sscanf(params, "u", id))return Koristi(playerid, "/mute [ime/ID]");
else if(id == INVALID_PLAYER_ID) return PogresanID(playerid);
SetPVarInt(id, "Mutan", 1);
format(string, sizeof(string), ""#COL_YELLOW"Mute|Utisao si igraca %s!",PlayerName(id));
SendClientMessage(playerid,-1, string);
format(string, sizeof(string), ""#COL_YELLOW"Mute|Mutan si od Admina %s!",PlayerName(playerid));
SendClientMessage(id,-1, string);
return 1;
}
Re: Command /mute -
LarzI - 14.12.2012
You just add a new parameter and use SetTimerEx to set an individual timer for each player, like so:
First make a global variable to store the timer-id:
pawn Код:
new
gMuteTimer[ MAX_PLAYERS ];
pawn Код:
if(sscanf(params, "ui", id, time))
pawn Код:
gMuteTimer[ playerid ] = SetTimerEx( "muteTimer", time*1000, false, "i", playerid );
//whatever you input as "time" in the command will be number of seconds. If you want minutes, simply do time*60*1000 instead.
Now here's the timer-function:
pawn Код:
forward muteTimer(playerid);
public muteTimer(playerid)
{
SetPVarInt( playerid, "Mutan", 0 );
return true;
}
Now for the unmute command, you would simply have to do the exact same as the muteTimer function does:
pawn Код:
SetPVarInt( id, "Mutan", 0 );
And additionally you would have to kill the timer - this is why we made a global variable to store its ID:
pawn Код:
KillTimer( gMuteTimer[ id ] );
I hope I've been helpful.
Re: Command /mute -
FL3GM4 - 14.12.2012
Код:
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(4235) : error 017: undefined symbol "time"
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(4237) : error 017: undefined symbol "time"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: Command /mute -
maramizo - 14.12.2012
pawn Код:
CMD:mute(playerid, params[])
{
new id, string[128], time;
if(PlayerInfo[playerid][pAdmin] < 1)return NisiAdmin(playerid);
else if(sscanf(params, "ui", id, time))return Koristi(playerid, "/mute [ime/ID] [Time in seconds]");
if(time < 0) return SendClientMessage(playerid, -1, "Time cannot be lower than 0");
else if(id == INVALID_PLAYER_ID) return PogresanID(playerid);
SetPVarInt(id, "Mutan", 1);
format(string, sizeof(string), ""#COL_YELLOW"Mute|Utisao si igraca %s!",PlayerName(id));
SendClientMessage(playerid,-1, string);
format(string, sizeof(string), ""#COL_YELLOW"Mute|Mutan si od Admina %s!",PlayerName(playerid));
SendClientMessage(id,-1, string);
SetTimerEx("unmute", time, 0, "i", id);
return 1;
}
forward unmute(p);
public unmute(p)
{
SetPVarInt(p, "Mutan", 0);
SendClientMessage(p, -1, "You have been automatically unmuted.");
return 1;
}
edit:
Didn't notice you want an unmute command, sec.
Re: Command /mute -
FL3GM4 - 14.12.2012
thank you marazmizo
Re: Command /mute -
maramizo - 14.12.2012
pawn Код:
new pMutedTimer[MAX_PLAYERS];
CMD:mute(playerid, params[])
{
new id, string[128], time;
if(PlayerInfo[playerid][pAdmin] < 1)return NisiAdmin(playerid);
else if(sscanf(params, "ui", id, time))return Koristi(playerid, "/mute [ime/ID] [Time in seconds]");
if(time < 0) return SendClientMessage(playerid, -1, "Time cannot be lower than 0");
else if(id == INVALID_PLAYER_ID) return PogresanID(playerid);
SetPVarInt(id, "Mutan", 1);
format(string, sizeof(string), ""#COL_YELLOW"Mute|Utisao si igraca %s!",PlayerName(id));
SendClientMessage(playerid,-1, string);
format(string, sizeof(string), ""#COL_YELLOW"Mute|Mutan si od Admina %s!",PlayerName(playerid));
SendClientMessage(id,-1, string);
pMutedTimer[id] = SetTimerEx("unmute", time, 0, "ii", id, 0);
return 1;
}
forward unmutef(p, f);
public unmutef(p, f)
{
KillTimer(pMutedTimer(p));
SetPVarInt(p, "Mutan", 0);
if(!f)
{
SendClientMessage(p, -1, "You have been automatically unmuted.");
}
return 1;
}
CMD:unmute(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return NisiAdmin(playerid);
extract params -> new player:a; else return SendClientMessage(playerid, -1, "/unmute [ime/ID]")
if(!GetPVarInt(a, "Mutan")) return SendClientMessage(playerid, -1, "That player is not muted.");
unmutef(a, 1);
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(a, name, MAX_PLAYER_NAME);
format(string, 128, "You have unmuted %s(%i).", name, a);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, 128, "Administrator %s(%i) has unmuted you.", name, playerid);
SendClientMessage(a, -1, string);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(GetPVarInt(playerid, "Mutan"))
{
unmutef(playerid, 1);
}
//code
return 1;
}
edit:
lol late, again.
Re: Command /mute -
FL3GM4 - 14.12.2012
Код:
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(48) : error 012: invalid function call, not a valid address
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(48) : warning 215: expression has no effect
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(48) : error 001: expected token: ";", but found ")"
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(48) : error 029: invalid expression, assumed zero
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(48) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Код:
forward unmutef(p, f);
public unmutef(p, f)
{
KillTimer(pMutedTimer(p)); --> line 48
SetPVarInt(p, "Mutan", 0);
if(!f)
{
SendClientMessage(p, -1, "You have been automatically unmuted.");
}
return 1;
}
Re: Command /mute -
FL3GM4 - 14.12.2012
You didn't understnd me.. i want /mute command (with timer) which after time automatically unmute player
and that admins are imune of /mute command..