Posts: 111
Threads: 10
Joined: Jun 2011
Quote:
Originally Posted by Basicz
pawn Код:
SendClientMessage(id, 0xFFF00AA, "Admin %s gave you %i", playerid, amount);
^ That will not work because of %s = playerid plus the normal SendClientMessage does not have support to format string(s).
pawn Код:
format( string, sizeof string, "Admin %s gave you %i.", GetName( playerid ), amount ); SendClientMessage( id, 0xFFFF00AA, string );
The code above will work I think.
pawn Код:
format(string, sizeof(string), "You gave %s $ to %i.", amount, GetName(id));
string = amount
integer = playername
?
pawn Код:
format( string, sizeof string, "You gave $%i to %s.", amount, GetName(id));
The code above will work I think.
Also? Why do you use 256 on string? :S
String in sscanf for player name ? xD
Rewritten /givecash
pawn Код:
dcmd_givecash( playerid, params[ ] ) { if ( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, 0xAA0000AA, "Error: Not an admin." ); new targetid, amount; if ( sscanf( params, "ud", targetid, amount ) ) return SendClientMessage( playerid, 0xAA0000AA, "Error: /givecash < playerid / partofname > < amount >" ); if ( targetid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, 0xAA0000AA, "Error: Invalid player." ); if ( amount < 0 ) return SendClientMessage( playerid, 0xAA0000AA, "Error: Invalid amount." ); new string[ 128 ]; format( string, sizeof string, "Admin %s gave you $%d.", GetName( playerid ), amount ); SendClientMessage( playerid, 0xAA0000AA, string ); format( string, sizeof string, "You gave $%d to %s.", amount, GetName( targetid ) ); SendClientMessage( targetid, 0xAA0000AA, string ); GivePlayerMoney( targetid, amount ); return 1;
|
The command that you game me doesn't work, it returns "Error : /givecash < playerid ....."
Help ?