PHP Code:
/*
__ _ _ ___ _
/ _(_)_ __ ___ _ __ | | ___ / _ \/\/\ ___ _ _ ___| |_ ___ _ __ ___
\ \| | '_ ` _ \| '_ \| |/ _ \ / /_)/ \ / __| | | / __| __/ _ \ '_ ` _ \
_\ \ | | | | | | |_) | | __/ / ___/ /\/\ \ \__ \ |_| \__ \ || __/ | | | | |
\__/_|_| |_| |_| .__/|_|\___| \/ \/ \/ |___/\__, |___/\__\___|_| |_| |_|
|_| |___/
*/
/*|============================================================================================|*/
/*|========================================| INCLUDES |========================================|*/
#include < a_samp >
#include < sscanf2 >
#include < zcmd >
#define SPLIT ( 85 )
#define USAGE "{02B0F5}"
#define WHITE "{FFFFFF}"
#define RED "{E85656}"
#define ORANGE "{DBB300}"
#define ADMIN "{9E4141}"
#define GREEN "{17BF41}"
/*|========================================| INCLUDES |========================================|*/
/*|============================================================================================|*/
/*|========================================| VARIABLES |=======================================|*/
new bool:PlayerBlockingPM[ MAX_PLAYERS ] [ MAX_PLAYERS ] = { false, ... }, bool:PMSblocked = false;
/*|========================================| VARIABLES |=======================================|*/
/*|============================================================================================|*/
/*|========================================| CALLBACKS |=======================================|*/
public OnFilterScriptInit( ) {
print( "|==========| PM SYSTEM |==========|" );
print( " By: Valentin Shadow" );
print( " Successfully loaded!" );
print( "|==========| PM SYSTEM |==========|" );
return ( true );
}
public OnPlayerDisconnect( playerid, reason ) {
for( new i = 0; i < MAX_PLAYERS; i++ ) {
PlayerBlockingPM[ playerid ] [ i ] = false;
PlayerBlockingPM[ i ] [ playerid ] = false;
}
return ( true );
}
/*|========================================| CALLBACKS |=======================================|*/
/*|============================================================================================|*/
/*|========================================| FUNCTIONS |=======================================|*/
SendClientMessageEx( playerid, color, const text[ ], { Float, _ }:... ) {
static args, str[ 144 ];
if( ( args = numargs( ) ) == 3 ){
SendClientMessage( playerid, color, text );
} else {
while( --args >= 3 ) {
#emit LCTRL 5
#emit LOAD.alt args
#emit SHL.C.alt 2
#emit ADD.C 12
#emit ADD
#emit LOAD.I
#emit PUSH.pri
}
#emit PUSH.S text
#emit PUSH.C 144
#emit PUSH.C str
#emit PUSH.S 8
#emit SYSREQ.C format
#emit LCTRL 5
#emit SCTRL 4
SendClientMessage(playerid, color, str);
#emit RETN
}
return ( true );
}
PlayerName( playerid ) {
new name[ MAX_PLAYER_NAME+1 ];
GetPlayerName( playerid, name, sizeof( name ) );
return name;
}
PName( playerid ) {
new name[ 24 ];
strmid( name, str_replace( '_', ' ', PlayerName( playerid ) ), 0, MAX_PLAYER_NAME );
return name;
}
str_replace( sSearch, sReplace, const sSubject[ ] ) {
new sReturn[ 128 ];
format( sReturn, sizeof( sReturn ), sSubject );
for( new i = 0; i < sizeof( sReturn ); i++ ) {
if( sReturn[ i ] == sSearch ) {
sReturn[ i ] = sReplace;
}
}
return sReturn;
}
/*|========================================| FUNCTIONS |=======================================|*/
/*|============================================================================================|*/
/*|========================================| COMMANDS |========================================|*/
CMD:pmhelp( playerid ) return SendClientMessageEx( playerid, -1, ""USAGE"| Commands: | "WHITE"/pm, /blockpm%s", ( IsPlayerAdmin( playerid ) ) ? ( ", /togpms." ) : ( "." ) );
CMD:pm( playerid, params[ ] ) {
new giveplayerid, text[ 170 ];
if( sscanf( params, "us[170]", giveplayerid, text ) ) return SendClientMessage( playerid, -1, ""USAGE"| Usage: | "WHITE"/pm [Name_Surname/Player ID] [Text]" );
else if( !IsPlayerConnected( giveplayerid ) ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"The specified player id isn't connected!" );
else if( PlayerBlockingPM[ giveplayerid ] [ playerid ] ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"The specified player id is blocking private messages from you!" );
else if( giveplayerid == playerid ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"You can not private message yourself!" );
else if( PMSblocked ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"An admin has "RED"blocked "WHITE"the private messages hence you are unable to send it!" );
else if( strlen( text ) > SPLIT ) {
SendClientMessageEx( giveplayerid, -1, ""ORANGE"(( PM FROM: %s%s(%d)"ORANGE": %.*s ...", ( IsPlayerAdmin( playerid ) ) ? ( ADMIN ) : ( ORANGE ), PName( playerid ), playerid, SPLIT, text );
SendClientMessageEx( giveplayerid, -1, ""ORANGE"..- %s ))", text[ SPLIT ] );
SendClientMessageEx( playerid, -1, ""ORANGE"(( PM TO: %s%s(%d)"ORANGE": %.*s ...", ( IsPlayerAdmin( giveplayerid ) ) ? ( ADMIN ) : ( ORANGE ), PName( giveplayerid ), giveplayerid, SPLIT, text );
SendClientMessageEx( playerid, -1, ""ORANGE"..- %s ))", text[ SPLIT ] );
}
else {
SendClientMessageEx( giveplayerid, -1, ""ORANGE"(( PM FROM: %s%s(%d)"ORANGE": %s ))", ( IsPlayerAdmin( playerid ) ) ? ( ADMIN ) : ( ORANGE ), PName( playerid ), playerid, text );
SendClientMessageEx( playerid, -1, ""ORANGE"(( PM TO: %s%s(%d)"ORANGE": %s ))", ( IsPlayerAdmin( giveplayerid ) ) ? ( ADMIN ) : ( ORANGE ), PName( giveplayerid ), giveplayerid, text );
}
return ( true );
}
CMD:blockpm( playerid, params[ ] ) {
new giveplayerid;
if( sscanf( params, "u", giveplayerid ) ) return SendClientMessage( playerid, -1, ""USAGE"| Usage: | "WHITE"/blockpm [Name_Surname/Player ID]" );
else if( !IsPlayerConnected( giveplayerid ) ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"The specified player id isn't connected!" );
else if( giveplayerid == playerid ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"You can not block private messages from yourself!" );
PlayerBlockingPM[ playerid ] [ giveplayerid ] = ( PlayerBlockingPM[ playerid ] [ giveplayerid ] ) ? ( false ) : ( true );
SendClientMessageEx( playerid, -1, ""RED"| WARNING: | "WHITE"You %s private messages from %s(%d)", ( PlayerBlockingPM[ playerid ] [ giveplayerid ] ) ? ( ""RED"started blocking"WHITE"" ) :
( ""GREEN"stopped blocking"WHITE"" ), PName( giveplayerid ), giveplayerid );
return ( true );
}
CMD:togpms( playerid ) {
new str[ 128 ];
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, ""RED"| ERROR: | "WHITE"You are not authorized to use this command as you're not logged in as an RCON administrator!" );
PMSblocked = ( PMSblocked ) ? ( false ) : ( true );
format( str, sizeof( str ), "An administrator has %s private messages for everyone!", ( PMSblocked ) ? ( ""RED"blocked"WHITE"" ) : ( ""GREEN"unblocked"WHITE"" ) );
SendClientMessageToAll( -1, str );
return ( true );
}
/*|========================================| COMMANDS |========================================|*/
/*|============================================================================================|*/
NOTE: I accept criticism and I'm willing to learn.