Members
Total Members: 27
Latest: shahrukh New This Month: 0 New This Week: 0 New Today: 0
Stats
Total Posts: 188
Total Topics: 56
Most Online Today: 6
Most Online Ever: 140
(February 02, 2023, 11:46:57 pm)
Users Online Members: 0 Guests: 3 Total: 3
|
|
Forum > Tutorials
How to create muteme command.
(1/1)
Kalroz:
How to create muteme command.
Introduction This tutorial will help you to create a mute command. After a player using this command,he will be muted till he quits.
Difficulty: Easy
Requirements:ZCMD include. I've used ZCMD to make it more easier.
First you must include a_samp and zcmd at top of your script.
--- Code: ---#include <a_samp> #include <zcmd>
--- End code ---
Now we need a color to give message to player. So lets define a color. Here I'll define red's hex code.
--- Code: ---#define red 0xFF0000
--- End code ---
Next step is to make new function to change the stats of player.
--- Code: ---new pMuted[MAX_PLAYERS];
--- End code ---
Now lets start with making command.
--- Code: ---CMD:muteme(playerid,params []) { #pragma unused params pMuted[playerid]=1; //player's stats gets changed here. SendClientMessage(playerid,red,''You're muted and cannot talk anymore.'');//Gives a message to player when he/she uses the cmd. return 1; } --- End code ---
Now we are done with making mute command,but we need to make the player muted. So we must call the function on player chat.
--- Code: ---public OnPlayerText(playerid,text) { if(pMuted[playerid] == 1)//now the mute function is activated. return SendClientMessage(playerid,red,''Error:You're muted so you cant talk.'');//Gives error message. return 0; } return 1; } --- End code ---
Now we must keep a disabling mute function when player disconnects.
--- Code: ---public OnPlayerDisconnect(playerid,reason) { pMuted[playerid] = 0; return 1; } --- End code ---
We're now done with creating a mute command.
Kalroz:
The script will look finally like this:
--- Code: ---#include <a_samp> #include <zcmd> #define red 0xFF0000 new pMuted[MAX_PLAYERS];
CMD:muteme(playerid,params []) { #pragma unused params pMuted[playerid] = 1; SendClientMessage(playerid,red,"You're muted and cannot talk."); return 1; }
public OnPlayerText(playerid,text) { if(pMuted[playerid] == 1) { SendClientMessage(playerid,red,"Error:You're muted so you cannot talk"); return 0; } return 1; }
public OnPlayerDisconnect(playerid, reason) { pMuted[playerid] = 0; return 1; }
--- End code ---
Y_Less:
--- Code: ---#include <a_samp> #include <zcmd> #define red 0xFF0000 new pMuted[MAX_PLAYERS];
CMD:muteme(playerid,params []) { #pragma unused params pMuted[playerid] = 1; SendClientMessage(playerid,red,"You're muted and cannot talk."); return 1; }
public OnPlayerText(playerid, text[]) { if(pMuted[playerid] == 1) { SendClientMessage(playerid,red,"Error:You're muted so you cannot talk"); return 0; } return 1; }
public OnPlayerDisconnect(playerid, reason) { pMuted[playerid] = 0; return 1; } --- End code ---
This is how the code should actually look like.
Lordz:
Nice work Xtreme. It's not just a tutorial a filterscript too. Keep going..
Kalroz:
Thank you Lordz. And thanks to Y_Less for correcting my mistake.
Navigation
[0] Message Index
|
MOVED: Creating TextDraw For Free ... :)
by Lordz
August 30, 2012, 10:53:11 am
|
Website designer.
by [RD]Cenation
August 29, 2012, 07:44:34 am
|
{Urgent}Help Needed
by Lordz
August 27, 2012, 05:51:20 pm
|
A help
by BlAck_DeViL
August 24, 2012, 05:26:26 pm
|
Hello all!
by [RD]Cenation
August 21, 2012, 03:04:29 pm
|
Hello All
by Lordz
August 20, 2012, 06:45:02 pm
|
Hello All
by Lordz
August 18, 2012, 04:10:39 pm
|
Need PS2 game.
by Lordz
August 18, 2012, 08:42:57 am
|
Map help.[Scripting]
by YoUnG_Ca$h
August 16, 2012, 05:06:09 pm
|
I Want To Change My UserName , So i am Applying
by BlAck_DeViL
August 16, 2012, 04:58:29 pm
|
|
|