SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/12/2011, 07:34 AM   #1
MustangV10
Huge Clucker
 
Join Date: Dec 2011
Posts: 252
Reputation: 11
Default Mute / Unmute

Hi,

Would it be possible to make /mute [ID] mute a player (as it already does), and then allow an admin to use /mute [ID] to unmute the player. So if the player isn't muted, then /mute will simply mute, if the player is muted, then /mute will unmute.

Wow, I said mute a lot.

Mute:
Code:
dcmd_mute(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 1) {
        if(PlayerInfo[playerid][Level] >= 3) {
            new tmp[256], tmp2[256], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /mute [playerid] [reason]");
            new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
                if(PlayerInfo[player1][Muted] == 0) {
                    GetPlayerName(player1, playername, sizeof(playername));     GetPlayerName(playerid, adminname, sizeof(adminname));
                    CMDMessageToAdmins(playerid,"MUTE");
                    PlayerPlaySound(player1,1057,0.0,0.0,0.0);  PlayerInfo[player1][Muted] = 1; PlayerInfo[player1][MuteWarnings] = 0;

                    if(strlen(tmp2)) {
                        format(string,sizeof(string),"You've been muted by Administrator %s [reason: %s]",adminname,params[2]); SendClientMessage(player1,blue,string);
                        format(string,sizeof(string),"You've muted %s [reason: %s]", playername,params[2]); return SendClientMessage(playerid,blue,string);
                    }
                    else {
                        format(string,sizeof(string),"You've been muted by Administrator %s",adminname); SendClientMessage(player1,blue,string);
                        format(string,sizeof(string),"You've muted %s", playername); return SendClientMessage(playerid,blue,string);
                    }
                } else return SendClientMessage(playerid, red, "Player is already muted");
            } else return SendClientMessage(playerid, red, "Player is not connected or is the highest level admin");
        } else return SendClientMessage(playerid,red,"ERROR: You need to be staff (or a higher level of staff) to use this command.");
    } else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}

Unmute:
Code:
dcmd_unmute(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 1) {
        if(PlayerInfo[playerid][Level] >= 3) {
            if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /unmute [playerid]");
            new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(params);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
                if(PlayerInfo[player1][Muted] == 1) {
                    GetPlayerName(player1, playername, sizeof(playername));     GetPlayerName(playerid, adminname, sizeof(adminname));
                    CMDMessageToAdmins(playerid,"UNMUTE");
                    PlayerPlaySound(player1,1057,0.0,0.0,0.0);  PlayerInfo[player1][Muted] = 0; PlayerInfo[player1][MuteWarnings] = 0;
                    format(string,sizeof(string),"You've been unmuted by Administrator %s",adminname); SendClientMessage(player1,blue,string);
                    format(string,sizeof(string),"You've unmuted %s", playername); return SendClientMessage(playerid,blue,string);
                } else return SendClientMessage(playerid, red, "Player is not muted");
            } else return SendClientMessage(playerid, red, "Player is not connected or is the highest level admin");
        } else return SendClientMessage(playerid,red,"ERROR: You need to be staff (or a higher level of staff) to use this command.");
    } else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}

Any ideas would be great.

Cheers.
MustangV10 is offline   Reply With Quote
Old 18/12/2011, 07:56 AM   #2
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,942
Reputation: 360
Default Re: Mute / Unmute

REMOVED.WRONG.
vassilis is offline   Reply With Quote
Old 18/12/2011, 08:44 AM   #3
Gazmull
Huge Clucker
 
Gazmull's Avatar
 
Join Date: Mar 2011
Posts: 206
Reputation: 4
Default Re: Mute / Unmute

You want to make a /mute toggle or /mute [On/Off]?
__________________
Not Funny-1.txt
Gazmull is offline   Reply With Quote
Old 18/12/2011, 08:53 AM   #4
MustangV10
Huge Clucker
 
Join Date: Dec 2011
Posts: 252
Reputation: 11
Default Re: Mute / Unmute

Quote:
Originally Posted by Gazmull View Post
You want to make a /mute toggle or /mute [On/Off]?
Yes, but for individual players, not globally.
MustangV10 is offline   Reply With Quote
Old 18/12/2011, 09:43 AM   #5
Mean
High-roller
 
Mean's Avatar
 
Join Date: Jul 2010
Location: 14th annual lemon party
Posts: 2,848
Reputation: 229
Default Re: Mute / Unmute

You can. Just use simple variables you have. Add this into your command:

Code:
if(PlayerInfo[player1][Muted] == 0) {
    // mute code here
} else {
    // unmute code here
}
__________________
Redirect_Left has the best puns.
Quote:
<Redirect_Left>: <Mean> i accidentally cut off my dick
<Redirect_Left>: <Mean> and put it in the microwave
<Redirect_Left>: pls what
<Redirect_Left>: that is a major cockup
<Redirect_Left>: get it?
<Redirect_Left>: cock up?
<Redirect_Left>: HAHAHA
[FS]KILLER COW
[FS]DontDropTheSoap
Mean is offline   Reply With Quote
Old 18/12/2011, 09:43 AM   #6
Gazmull
Huge Clucker
 
Gazmull's Avatar
 
Join Date: Mar 2011
Posts: 206
Reputation: 4
Default Re: Mute / Unmute

REMOVED
__________________
Not Funny-1.txt

Last edited by Gazmull; 18/12/2011 at 09:51 AM. Reason: Lame post
Gazmull is offline   Reply With Quote
Old 18/12/2011, 09:45 AM   #7
Mean
High-roller
 
Mean's Avatar
 
Join Date: Jul 2010
Location: 14th annual lemon party
Posts: 2,848
Reputation: 229
Default Re: Mute / Unmute

Quote:
Originally Posted by Gazmull View Post
I haven't tested this, sorry it looks like "noobish" code:
Code:
CMD:mute(playerid, params[])
{
	for(new i; i < MAX_PLAYERS; i++) {
		new targetname[MAX_PLAYER_NAME];
		GetPlayerName(i, targetname, sizeof(targetname));
		if(IsPlayerMuted[i] == 0) {
			new player, admin[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME], reason[32], string[128], string2[128];
			GetPlayerName(player, playername, sizeof(playername));
			GetPlayerName(playerid, admin, sizeof(admin));
	
			if(sscanf(params, "uz", player, reason)) return SendClientMessage(playerid, -1, "{FF0000}Usage: /mute [playerid] [reason]");
			else if(!IsPlayerConnected(player)) return SendClientMessage(playerid, -1, "{FF0000} Player is disconnected/invalid player.");
			else if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}You're not administrator to use this command.");
			else {
				IsPlayerMuted[player] = 1;
				format(string, sizeof(string), "{FF00FF}You have been muted by Adminitrator %s, reason: %s", admin, reason);
				format(string2, sizeof(string2), "{FFFF00}You have muted player %s, reason: %s", playername, reason);
				SendClientMessage(player, -1, string);
				SendClientMessage(playerid, -1, string2);
			}
		}
		else {
		    new player, playername[MAX_PLAYER_NAME], admin[MAX_PLAYER_NAME], string[64], string2[128];
			format(string, sizeof(string), "{FFFF00}You unmuted %s", playername);
			format(string2, sizeof(string2), "{FF00FF}You have been unmuted by Administrator %s", admin);
			SendClientMessage(playerid, -1, string);
			SendClientMessage(player, -1, string2);
			IsPlayerMuted[player] = 0;
		}
	}
	return 1;
}
Switch those "IsPlayerAdmin" to PlayerInfo[playerid][Level] >= 3
That won't work for him. He doesn't have all those variables nor defines, such as colors, etc. Also, why are you using a loop? You are getting everyone's name.
__________________
Redirect_Left has the best puns.
Quote:
<Redirect_Left>: <Mean> i accidentally cut off my dick
<Redirect_Left>: <Mean> and put it in the microwave
<Redirect_Left>: pls what
<Redirect_Left>: that is a major cockup
<Redirect_Left>: get it?
<Redirect_Left>: cock up?
<Redirect_Left>: HAHAHA
[FS]KILLER COW
[FS]DontDropTheSoap
Mean is offline   Reply With Quote
Old 18/12/2011, 09:52 AM   #8
Gazmull
Huge Clucker
 
Gazmull's Avatar
 
Join Date: Mar 2011
Posts: 206
Reputation: 4
Default Re: Mute / Unmute

Quote:
Originally Posted by Mean View Post
That won't work for him. He doesn't have all those variables nor defines, such as colors, etc. Also, why are you using a loop? You are getting everyone's name.
Ok, sorry. Removed and you already posted the solution.
__________________
Not Funny-1.txt
Gazmull is offline   Reply With Quote
Old 18/12/2011, 10:30 AM   #9
MustangV10
Huge Clucker
 
Join Date: Dec 2011
Posts: 252
Reputation: 11
Default Re: Mute / Unmute

Quote:
Originally Posted by Mean View Post
You can. Just use simple variables you have. Add this into your command:

Code:
if(PlayerInfo[player1][Muted] == 0) {
    // mute code here
} else {
    // unmute code here
}
Tried that, but I couldn't get it to work. Can you post the finished command here if possible please?
MustangV10 is offline   Reply With Quote
Old 18/12/2011, 10:37 AM   #10
[ABK]Antonio
High-roller
 
[ABK]Antonio's Avatar
 
Join Date: Sep 2011
Location: ID, USA
Posts: 1,239
Reputation: 185
Default Re: Mute / Unmute

Code:
switch(PlayerInfo[player1][Muted])
{
	case 0:
	{
		PlayerInfo[player1][Muted] = 1
		//Then add the rest of your messages and stuff...
	}
	case 1:
	{
		PlayerInfo[player1][Muted] = 0
		//Then add the rest of your messages and stuff..
	}
}

Add all of your checks and stuff too..
__________________

ABKClan.com
[ABK]Antonio is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mute OnPlayerRequestClass And Unmute OnPlayerSpawn lyrics Help Archive 2 13/08/2011 11:14 AM
[FilterScript] [FS] Simple Mute and Unmute Oxside Filterscripts 15 18/02/2011 08:24 PM
[HELP] Mute, Unmute, Who is muted Larsey123IsMe Help Archive 0 13/12/2010 05:21 PM
Mute unmute script FireCat Help Archive 3 21/07/2010 04:11 PM
Mute and Unmute in dcmd Dolph Help Archive 11 17/04/2010 11:54 AM


All times are GMT. The time now is 05:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.