+- +-

+-Website Stats

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: 0
Most Online Ever: 17
(October 07, 2012, 05:33:16 am)
Users Online
Members: 0
Guests: 0
Total: 0

Author Topic: How to create muteme command.  (Read 71 times)

0 Members and 0 Guests are viewing this topic.

Offline Kalroz

  • Master Moderator
  • ****
  • Posts: 19
  • Reputation: 10
  • Location: UK
How to create muteme command.
« on: July 22, 2012, 07:17:16 pm »
                    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: [Select]
#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.
Code: [Select]
#define red 0xFF0000

Next step is to make new function to change the stats
of player.

Code: [Select]
new pMuted[MAX_PLAYERS];

Now lets start with making command.

Code: [Select]
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.

Code: [Select]
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.
Code: [Select]
public OnPlayerDisconnect(playerid,reason)
{
     pMuted[playerid] = 0;
     return 1;
}

We're now done with creating a mute command.
« Last Edit: July 23, 2012, 06:47:22 pm by Xtreme »

Offline Kalroz

  • Master Moderator
  • ****
  • Posts: 19
  • Reputation: 10
  • Location: UK
Re: How to create muteme command.
« Reply #1 on: July 22, 2012, 07:38:55 pm »
The script will look finally like this:
Code: [Select]
#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;
}
« Last Edit: July 23, 2012, 06:46:02 pm by Xtreme »

Offline Y_Less

  • Little Clucker
  • *
  • Posts: 11
  • Reputation: 1
Re: How to create muteme command.
« Reply #2 on: July 22, 2012, 07:50:05 pm »
Code: [Select]
#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;
}

This is how the code should actually look like.

Offline Lordz

  • Beta Master
  • ******
  • Posts: 68
  • Reputation: 28
Re: How to create muteme command.
« Reply #3 on: July 22, 2012, 07:54:08 pm »
Nice work Xtreme.
It's not just a tutorial a filterscript too.
Keep going..

Offline Kalroz

  • Master Moderator
  • ****
  • Posts: 19
  • Reputation: 10
  • Location: UK
Re: How to create muteme command.
« Reply #4 on: July 23, 2012, 06:38:37 pm »
Thank you Lordz.
And thanks to Y_Less for correcting my mistake.

 

Recent Topics

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