12.07.2011, 22:35
A simple /me, /do command filterscript with Strcmp ( slow command processor )
It's very simple!
EDIT: Added a "SendClosestMessage" function!
pawn Код:
#include < a_samp >
stock SendClosestMessage( playerid, color, const string[ ] )
{
new
Float: jPos[ 3 ]
;
GetPlayerPos( playerid, jPos[ 0 ], jPos[ 1 ], jPos[ 2 ] );
for ( new j = GetMaxPlayers( ), i; i < j; i ++ )
{
if ( !IsPlayerConnected( i ) )
continue;
if ( IsPlayerInRangeOfPoint( i, 5.0, jPos[ 0 ], jPos[ 1 ], jPos[ 2 ] ) )
{
SendClientMessage( i, color, string );
}
}
return 1;
}
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !strcmp( cmdtext, "/me", 3 ) )
{
if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
return SendClientMessage( playerid, -1, "Syntax: /me < action >" );
new
tempString[ 128 ],
pName[ 24 ]
;
GetPlayerName( playerid, pName, sizeof pName );
format( tempString, sizeof tempString, "* %s %s", pName, cmdtext[ 3 ] );
SendClosestMessage( playerid, -1, tempString );
return 1;
}
if ( !strcmp( cmdtext, "/do", 3 ) )
{
if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
return SendClientMessage( playerid, -1, "Syntax: /do < action >" );
new
tempString[ 128 ],
pName[ 24 ]
;
GetPlayerName( playerid, pName, sizeof pName );
format( tempString, sizeof tempString, "* (( %s )) %s", pName, cmdtext[ 3 ] );
SendClosestMessage( playerid, -1, tempString );
return 1;
}
return 0;
}
EDIT: Added a "SendClosestMessage" function!