Command cash
#4

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;
Reply


Messages In This Thread
Command cash - by ludesert - 27.06.2011, 07:55
Re: Command cash - by iPLEOMAX - 27.06.2011, 08:06
Re : Command cash - by ludesert - 27.06.2011, 08:17
Re: Command cash - by Basicz - 27.06.2011, 08:39
Re : Command cash - by ludesert - 27.06.2011, 09:14
Re : Re: Command cash - by ludesert - 27.06.2011, 10:15
Re : Re: Command cash - by ludesert - 27.06.2011, 10:21
Re: Command cash - by iPLEOMAX - 27.06.2011, 11:41
Re : Re: Command cash - by ludesert - 27.06.2011, 19:49
Re: Command cash - by iPLEOMAX - 27.06.2011, 19:53

Forum Jump:


Users browsing this thread: 4 Guest(s)