Thread: Useful Snippets
View Single Post
Old 21/04/2020, 03:02 PM   #37
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 96
Reputation: 35
Default Re: Useful Snippets

Simple Mute Script: (please remember to set player color or else his name in chat will be black)

PHP Code:
#include <a_samp>
#include <foreach>
#include <sscanf2>
#include <zcmd>

static bool:Muted[MAX_PLAYERS][MAX_PLAYERS];

public 
OnPlayerDisconnect(playeridreason)
{
    foreach(new 
i,Player)
    {
        
Muted[i][playerid] = false;
        
Muted[playerid][i] = false;
    }
    return 
1;
}

CMD:mute(playeridparams[])
{
    new 
username[31];
    if(
sscanf(params"u"user)) return SendClientMessage(playerid0xFFFFFFFF"Usage: /mute [id/name]");
    if(
user == playerid) return SendClientMessage(playerid0xFF0000FF"You cannot mute yourself!");
    if(!
IsPlayerConnected(user) || IsPlayerNPC(playerid)) return SendClientMessage(playerid0xFF0000FF"Invalid player!");
    if(
Muted[playerid][user]) return SendClientMessage(playerid0xFF0000FF"Player is allready muted!");
    
Muted[playerid][user] = true;
    
GetPlayerName(username24);
    
strcat(name" muted!");
    
SendClientMessage(playerid0xFFFF00FFname);
    return 
1;
}

CMD:unmute(playeridparams[])
{
    new 
username[33];
    if(
sscanf(params"u"user)) return SendClientMessage(playerid0xFFFFFFFF"Usage: /mute [id/name]");
    if(
user == playerid) return SendClientMessage(playerid0xFF0000FF"If you cannot mute yourself then why unmute!");
    if(!
IsPlayerConnected(user) || IsPlayerNPC(playerid)) return SendClientMessage(playerid0xFF0000FF"Invalid player!");
    if(!
Muted[playerid][user]) return SendClientMessage(playerid0xFF0000FF"Player is not muted!");
    
Muted[playerid][user] = false;
    
GetPlayerName(username24);
    
strcat(name" unmuted!");
    
SendClientMessage(playerid0xFFFF00FFname);
    return 
1;
}

public 
OnPlayerText(playeridtext[])
{
    new 
colorname[144];
    
color GetPlayerColor(playerid);
    
GetPlayerName(playeridname24);
    
strcat(name"{FFFFFF}: ");
    
strcat(nametext);
    foreach(new 
i,Player)
    {
        if(
Muted[i][playerid]) continue;
        
SendClientMessage(icolorname);
    }
    return 
0;

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote