SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/01/2015, 06:31 PM   #1
nezo2001
Gangsta
 
Join Date: Nov 2014
Location: Cairo, Egypt
Posts: 684
Reputation: 26
Default Mute & Unmute commands

Hello here is another tutorial to help newbies make other admins commad

Mute & Unmute

first the includes
PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2> 
I think no need for explain here !

a color !
PHP Code:
#define COLOR_RED 0xFF0000AA 
Now for the.....
Mute !!

first we need a bool on the top of the script to check if the player muted or not
(bool is something in samp that can be set to true or false only !)
PHP Code:
new bool:muted[MAX_PLAYERS]; 
now for the command
PHP Code:
CMD:mute(playeridparams[])

Then ....
PHP Code:
new targetidminutesreason[128], string[128]; 
Here we define the targetid that will mute and reason and string
PHP Code:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_RED"Player is not connected to the server"); 
Here we check if the targetid that the player wrote is connected to the server or not
PHP Code:
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_RED"Command not found on server! /help"); 
Here we check if the player is admin check it to your Variables !
PHP Code:
if(muted[targetid] == true) return SendClientMessage(playeridCOLOR_RED"Player is already muted"); 
As i said we check if the bool equal true (Means if the player is muted) Send a message and stop !
PHP Code:
if(sscanf(params,"uis[128]"targetidminutesreason)) return SendClientMessage(playeridCOLOR_RED"Mute: /mute (id) (minutes) (reason)"); 
And here we check if the player typed the command full with his params or not
PHP Code:
    format(stringsizeof(string), "Administrator %s muted %s for %d minutes: %s"PlayerName(playerid),         PlayerName(targetid), minutesreason);
    
SendClientMessageToAll(COLOR_REDstring); 
And this is for messages (Do in it what do you want !)
PHP Code:
SetTimerEx("Unmute"minutes*60000false"i"targetid); 
Here,You set a timer that we will do later and multiply the minutes that the player write with 60000 because the timer is set with millisecond and set this timer for thr targetid
PHP Code:
muted[targetid] = true
Here we set the bool true means that the player is muted !
PHP Code:
return 1;

Then end......

Now for the timer
PHP Code:
forward Unmute(playerid); 
make forward to make public (The timer)
PHP Code:
public Unmute(playerid)

The public
PHP Code:
muted[playerid] = false
Set the player mute to false (Player unmuted) after the time end.
PHP Code:
SendClientMessage(playeridCOLOR_RED"You have been unmuted automatically by server"); 
And send a message to the player after he umnuted
PHP Code:
return 1;

End of the timer.

And now for.....
Unmute !!
PHP Code:
CMD:unmute(playeridparams[])

The command.....
PHP Code:
new targetidstring[128];
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_RED"Player is not connected to the server");
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_RED"Command not found on server! /help");
    if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"Cancel player mute: /unmute (id)");
    
format(stringsizeof(string), "Your mute has been canceled by administrator %s"PlayerName(playerid));
    
SendClientMessage(targetidCOLOR_REDstring);
    
format(stringsizeof(string), "Administrator %s has canceled %s's mute"PlayerName(playerid), PlayerName(targetid));
    
SendToAdmins(COLOR_REDstring); 
All these as i explained before (I am lazy :P !)
PHP Code:
KillTimer(Unmute(playerid)); 
The timer will killed because we will stop it and will unmute the player
PHP Code:
muted[targetid] = false
Set the player mute to false (Unmuted !)
PHP Code:
return 1;

End of the command..

End of the tutorial and this is for newbies because sure there are some people who are still learning

Basic code by : Axey (I was having exams -_-)
Edited by : Me (After i finished )

Hope it will help you .
Ahmed_Nezoo
__________________
Quote:
Originally Posted by Human
When im met u, u were nub at scripting xD.

But now, i'm impressed. Good job.
Don't look at my history. Everyone started somewhere
nezo2001 is offline   Reply With Quote
Old 14/01/2015, 06:33 PM   #2
www
Gangsta
 
www's Avatar
 
Join Date: Aug 2014
Location: cd /var/log/
Posts: 599
Reputation: 35
Default Re: Mute & Unmute commands

Nice! + rep
www is offline   Reply With Quote
Old 14/01/2015, 06:39 PM   #3
nezo2001
Gangsta
 
Join Date: Nov 2014
Location: Cairo, Egypt
Posts: 684
Reputation: 26
Default Re: Mute & Unmute commands

Thanks
__________________
Quote:
Originally Posted by Human
When im met u, u were nub at scripting xD.

But now, i'm impressed. Good job.
Don't look at my history. Everyone started somewhere
nezo2001 is offline   Reply With Quote
Old 03/05/2018, 03:29 PM   #4
antixgaming
Little Clucker
 
antixgaming's Avatar
 
Join Date: Apr 2018
Posts: 7
Reputation: 0
Default Re: Mute & Unmute commands

Quote:
C:\Users\Antix\Desktop\MyServer\filterscripts\mute .pwn(59) : error 017: undefined symbol "PlayerName"
Can you tell me what to do?
antixgaming is offline   Reply With Quote
Old 03/05/2018, 06:41 PM   #5
CrystalGamer
Banned
 
Join Date: Apr 2018
Posts: 52
Reputation: 2
Default Re: Mute & Unmute commands

Quote:
Originally Posted by antixgaming View Post
Can you tell me what to do?
Code:
PlayerName(playerid)
{
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid, name, MAX_PLAYER_NAME);
 return name;
}
maybe this help u
CrystalGamer is offline   Reply With Quote
Old 03/05/2018, 06:43 PM   #6
CrystalGamer
Banned
 
Join Date: Apr 2018
Posts: 52
Reputation: 2
Default Re: Mute & Unmute commands

nezo you must killtimer on public unmute, otherwise timer wont make u unmute

EDIT: like

Code:
forward Unmute(playerid);
public Unmute(playerid)
{
muted[playerid] = false; 
KillTimer(Unmute(playerid));
SendClientMessage(playerid, color, "Server unmuted you automatically");
return 1;
}
CrystalGamer is offline   Reply With Quote
Old 03/05/2018, 09:49 PM   #7
Stev
Big Clucker
 
Join Date: Oct 2013
Location: United Kingdom
Posts: 143
Reputation: 15
Default Re: Mute & Unmute commands

You are missing a callback, all that part of the tutorial is I just creating the commands. It does mute the player from the chat without OnPlayerText.
Stev is offline   Reply With Quote
Old 04/05/2018, 10:52 AM   #8
CrystalGamer
Banned
 
Join Date: Apr 2018
Posts: 52
Reputation: 2
Default Re: Mute & Unmute commands

you must add OnPlayerText
because if you are muted then you can chat if you didnot added the code on callback OnPlayerText
CrystalGamer 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 and /unmute mittukuttan Scripting Help 4 25/02/2013 08:43 AM
/mute /unmute Cmd Blackazur Scripting Help 6 13/10/2012 06:23 PM
Mute / Unmute MustangV10 Scripting Help 14 18/12/2011 12:22 PM
[FilterScript] [FS] Simple Mute and Unmute Oxside Filterscripts 15 18/02/2011 08:24 PM
Mute and Unmute in dcmd Dolph Help Archive 11 17/04/2010 11:54 AM


All times are GMT. The time now is 04:26 PM.


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