Thread: Useful Snippets
View Single Post
Old 10/02/2018, 09:00 AM   #1257
RxErT
Huge Clucker
 
Join Date: May 2016
Location: SA:MP Lemon
Posts: 258
Reputation: 12
Default Simple Whisper and Car Whisper commands controllable

*Features:
This system contain, 4 commands, are the following:
-/w (/whisper).
-/cw (whispering inside a car).
-/wspy (spying whisper messages).
-/cwspy (spying car whisper)


*Includes used:
-a_samp...
-Zeex command processor.
-sscanf2


Source:

Includes:

PHP Code:
//===Includes===//
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//-------------// 
Variables:
PHP Code:
//===Variables===//
new wspy[MAX_PLAYERS];
new 
cwspy[MAX_PLAYERS];
new 
pmspy[MAX_PLAYERS];
new 
IsSpawned[MAX_PLAYERS];
//=================// 
some optimization under public OnPlayerConnect(playerid) callback:

PHP Code:
public OnPlayerConnect(playerid)
{
   
IsSpawned[playerid] = 0;
   
wspy[playerid] = 0;
   
cwspy[playerid] = 0;
   
pmspy[playerid] = 0;
   return 
1;

Also under public OnPlayerSpawn(playerid):

PHP Code:
public OnPlayerSpawn(playerid)
{
   
IsSpawned[playerid] = 1;
   return 
1;

/*Car Whisper Code:*/
PHP Code:
CMD:cw(playeridparams[])
{
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        new 
string[250], textes[120], name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridname,sizeof(name));

        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/cw <message>");
        }
        else
        {
            if(
IsPlayerInAnyVehicle(playerid))
            {
                new 
vehicleID GetPlayerVehicleID(playerid);

                new 
string2[250];
                
format(string2sizeof(string2), "{adf407}[Car Whisper] {FFFFFF}%s(%i): {adf407}%s",nameplayeridstring);

                for(new 
0<= MAX_PLAYERSi++)
                {
                    if(
IsPlayerInVehicle(ivehicleID))
                    {
                        
SendClientMessage(i, -1string2);
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid,0xf8f8f8fff"ERROR: {F00f00}You are not in a vehicle.");
            }
            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerInAnyVehicle(playerid))
                    {
                        if (
IsPlayerAdmin(i))
                        {
                            if (
cwspy[i])
                            {
                                new 
cwtext[200];
                                
format(cwtextsizeof(cwtext), "{f00f00}[Car Whisper SPY]>> %s: %s",namestringtextes);
                                
SendClientMessage(i, -1cwtext);
                            }
                          }
                      }
                }
            }
        }
        return 
1;

/*Note: you can replaceIsPlayerAdmin(playerid) with your own administrator's system variable.*/

/* Car Whisper Spying */

PHP Code:
CMD:cwspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
cwspy[playerid])
            {
                
cwspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are not spying on car whisper.");
            }
            else
            {
                
cwspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {adf407}You are now spying on car whisper.");
            }
        }
    }
    return 
1;

/* Whisper */

PHP Code:
CMD:w(playeridparams[])
{
        new 
string[250];
        new 
nameplaya[MAX_PLAYER_NAME];
        new 
textes2[120];
        
GetPlayerName(playeridnameplaya,sizeof(nameplaya));
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/(w)hisper <message>");
        }
        else
        {
            new 
Float:x,Float:y,Float:z;
            
GetPlayerPos(playerid,x,y,z);

            new 
string2[250];
            
format(string2sizeof(string2), "{f47e07}[WHISPER] {FFFFFF}%s(%i): {f47e07}%s",nameplayaplayeridstring);

            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerInRangeOfPoint(i15.0xyz))
                {
                    
SendClientMessage(i, -1string2);
                    
PlayerPlaySound(i1085,0.0,0.0,0.0);
                }
                 if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerAdmin(i))
                    {
                         if (
wspy[i])
                        {
                        new 
wtext[200];
                        
format(wtextsizeof(wtext), "{f904e9}[WHISPER SPY]> {FFFFFF}%s: %s",nameplayastringtextes2);
                        
SendClientMessage(i, -1wtext);
                        }
                    }
                }
            }
        }
        return 
1;

/* Whisper spy */

PHP Code:
COMMAND:wspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
wspy[playerid])
            {
                
wspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are no longer spying on WHISPERS.");
            }
            else
            {
                
wspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {a1f406}You are now spying on WHISPERS.");
            }
        }
    }
    return 
1;

*Whole source code:
PHP Code:
//Whisper, Car Whsiper simple systems, with some administration control.
//Made by RxErT

//===Includes===//
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//-------------//

//===Variables===//
new wspy[MAX_PLAYERS];
new 
cwspy[MAX_PLAYERS];
new 
pmspy[MAX_PLAYERS];
new 
IsSpawned[MAX_PLAYERS];
//=================//

public OnPlayerConnect(playerid)
{
   
IsSpawned[playerid] = 0;
   
wspy[playerid] = 0;
   
cwspy[playerid] = 0;
   
pmspy[playerid] = 0;
   return 
1;
}

public 
OnPlayerSpawn(playerid)
{
   
IsSpawned[playerid] = 1;
   return 
1;
}

/*Car Whisper*/
CMD:cw(playeridparams[])
{
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        new 
string[250], textes[120], name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridname,sizeof(name));

        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/cw <message>");
        }
        else
        {
            if(
IsPlayerInAnyVehicle(playerid))
            {
                new 
vehicleID GetPlayerVehicleID(playerid);

                new 
string2[250];
                
format(string2sizeof(string2), "{adf407}[Car Whisper] {FFFFFF}%s(%i): {adf407}%s",nameplayeridstring);

                for(new 
0<= MAX_PLAYERSi++)
                {
                    if(
IsPlayerInVehicle(ivehicleID))
                    {
                        
SendClientMessage(i, -1string2);
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid,0xf8f8f8fff"ERROR: {F00f00}You are not in a vehicle.");
            }
            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerInAnyVehicle(playerid))
                    {
                        if (
IsPlayerAdmin(i))
                        {
                            if (
cwspy[i])
                            {
                                new 
cwtext[200];
                                
format(cwtextsizeof(cwtext), "{f00f00}[Car Whisper SPY]>> %s: %s",namestringtextes);
                                
SendClientMessage(i, -1cwtext);
                            }
                          }
                      }
                }
            }
        }
        return 
1;
}
/* Car Whisper Spying */
CMD:cwspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
cwspy[playerid])
            {
                
cwspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are not spying on car whisper.");
            }
            else
            {
                
cwspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {adf407}You are now spying on car whisper.");
            }
        }
    }
    return 
1;
}
/*Done*/




/* Whisper */
CMD:w(playeridparams[])
{
        new 
string[250];
        new 
nameplaya[MAX_PLAYER_NAME];
        new 
textes2[120];
        
GetPlayerName(playeridnameplaya,sizeof(nameplaya));
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/(w)hisper <message>");
        }
        else
        {
            new 
Float:x,Float:y,Float:z;
            
GetPlayerPos(playerid,x,y,z);

            new 
string2[250];
            
format(string2sizeof(string2), "{f47e07}[WHISPER] {FFFFFF}%s(%i): {f47e07}%s",nameplayaplayeridstring);

            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerInRangeOfPoint(i15.0xyz))
                {
                    
SendClientMessage(i, -1string2);
                    
PlayerPlaySound(i1085,0.0,0.0,0.0);
                }
                 if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerAdmin(i))
                    {
                         if (
wspy[i])
                        {
                        new 
wtext[200];
                        
format(wtextsizeof(wtext), "{f904e9}[WHISPER SPY]> {FFFFFF}%s: %s",nameplayastringtextes2);
                        
SendClientMessage(i, -1wtext);
                        }
                    }
                }
            }
        }
        return 
1;
}

/* Whisper spy */
COMMAND:wspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
wspy[playerid])
            {
                
wspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are no longer spying on WHISPERS.");
            }
            else
            {
                
wspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {a1f406}You are now spying on WHISPERS.");
            }
        }
    }
    return 
1;
}
/* Done */ 
If you find anything strange feel free to remind me!
RxErT is offline   Reply With Quote