23.03.2012, 07:35
This can be more easy using sscanf and ZCMD.
pawn Код:
CMD:givecookie ( playerid , params [] )
{
if ( !PlayerInfo [ playerid ] [ pAdmin ] < 4 ) return SendClientMessage ( playerind , COLOR_GRAD1 , "Your are not authorizes to use that command!" ) ;
new ID , Str [ 128 ] ;
if ( !IsPlayerConnected ( ID ) ) return SendClientMessage ( playerid , -1 , "Invalid Player ID" ) ;
if ( sscanf ( params , "us[128]" , ID , Str ) ) return SendClientMessage ( playerid , -1 , "Usage : /givecookie [ID] [Reason]" ) ;
else
{
new pName [ MAX_PLAYER_NAME ] , vName [ MAX_PLAYER_NAME ] , string [ 128 ] ;
GetPlayerName ( playerid , pName , MAX_PLAYER_NAME ) ;
GetPlayerName ( ID , vName , MAX_PLAYER_NAME ) ;
PlayerInfo [ giveplayerid ][ pCookies ] += 1;
format ( string , 128 , "AdmCmd: %s has been given a cookie by %s, reason: %s" , pName , vName , Str );
SendClientMessageToAll ( -1 , string ) ;
}
return 1;
}