[Tutorial] How to create muteme command.
#1

How to create muteme command.

Introduction
This tutorial will help you to create a muteme command.
After a player using this command,the player will be muted till he/she 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.

pawn Код:
#include <a_samp>
#include <zcmd>
Now we need a color to give message to player.
So lets define a color.
Here I'll define red's hex code.
pawn Код:
#define red 0xFF0000
Next step is to make new function to change the stats
of player.

pawn Код:
new pMuted[MAX_PLAYERS];
Now lets start with making command.

pawn Код:
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;
 }
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.

pawn Код:
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;
}
Now we must keep a disabling mute function when player disconnects.
pawn Код:
public OnPlayerDisconnect(playerid,reason)
{
     pMuted[playerid] = 0;//Player gets unmuted here.
     return 1;
}
We're now done with creating a mute command.

Problems/Errors
If you find any problems or errors,please tell me.
I didnt check this script coz im posting this via Mobile.

This is how the script look:
pawn Код:
#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;
}
Hope you guys will like it.

Credits
Tutorial:Kalroz.
ZCMD:ZeeX.
A_SAMP:SA-MP Team.


Regards,
Kalroz.
Reply


Messages In This Thread
How to create muteme command. - by Kalroz - 29.07.2012, 07:43
Re: How to create muteme command. - by Kindred - 29.07.2012, 07:51
Re: How to create muteme command. - by Kalroz - 29.07.2012, 07:59
Re: How to create muteme command. - by Vince - 29.07.2012, 11:00
Re: How to create muteme command. - by [MM]RoXoR[FS] - 31.07.2012, 02:31
Re: How to create muteme command. - by doreto - 31.07.2012, 08:40
Re: How to create muteme command. - by Lordzy - 31.07.2012, 13:37
Re: How to create muteme command. - by oKzrh - 02.08.2012, 12:13
Re: How to create muteme command. - by AaronKillz - 02.08.2012, 23:11
Re: How to create muteme command. - by Kalroz - 09.08.2012, 15:05
Re: How to create muteme command. - by xSkullx - 12.08.2012, 17:50
Re: How to create muteme command. - by Lordzy - 18.08.2012, 09:35
Re: How to create muteme command. - by Kaperstone - 18.08.2012, 19:34
Re: How to create muteme command. - by FalconX - 18.08.2012, 22:02

Forum Jump:


Users browsing this thread: 2 Guest(s)