23.06.2011, 23:27
pawn Код:
targetid = strval(params);
pawn Код:
(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss)
pawn Код:
#define faction_swat ( 50 )
#define faction_army ( 49 )
#define faction_lspd ( 77 )
#define faction_ss ( 76 )
pawn Код:
OnPlayerCommandText( playerid, cmdtext[ ] )
Anyway, it's more easier to do it with ZCMD + sscanf.
pawn Код:
COMMAND:cuff( playerid, params[ ] )
{
new
targetID
;
if(pFaction[playerid] != faction_army || pFaction[playerid] != faction_swat || pFaction[playerid] != faction_lspd || pFaction[playerid] != faction_ss)
return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}You are not a leo." );
if ( sscanf( params, "u", targetID ) )
return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}/cuff < playerID / partOfName>." );
if ( targetID == INVALID_PLAYER_ID )
return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}Invalid player." );
new
Float: targetPos[ 3 ]
;
GetPlayerPos( targetID, targetPos[ 0 ], targetPos[ 1 ], targetPos[ 2 ] );
if ( !IsPlayerInRangeOfPoint( playerid, 3.0 /* The range, you can change it */, targetPos[ 0 ], targetPos[ 1 ], targetPos[ 2 ] )
return SendClientMessage( playerid, -1, "{AA0000}Error: {FFFFFF}You need to be near from the people you want to cuff." );
new
szString[ 128 ],
szCuffer[ 24 ],
szVictim[ 24 ]
;
GetPlayerName( playerid, szCuffer, sizeof szCuffer ); GetPlayerName( targetid, szVictim, sizeof szVictim );
format( szString, sizeof szString, "* You have been cuffed by a LEO named : %s.", szCuffer );
SendClientMessage( targetID, 0xAAAAAAAA, szString );
format( szString, sizeof szString, "* You have cuffed suspect named : %s.", szVictim );
SendClientMessage( playerid, 0xAAAAAAAAA, szString );
TogglePlayerControllable( targetID, 0 );
return 1;
}