SA-MP Forums Archive
So weird.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: So weird.. (/showthread.php?tid=588996)



So weird.. - saffierr - 14.09.2015

I just cannot understand how this is wrong...
What's wrong about this code?

PHP код:
CMD:getcash(playeridparams[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 1) return 0;
       if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playeridCOLOR_YELLOWGREEN"Error: You are not authorized to use this command.");
    new 
targetplayer;
    if(
sscanf(params"i"targetplayer)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /getcash [ID]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Error: Player is not connected!");
    new 
string[50], pName[MAX_PLAYER_NAME], amount;
    
GetPlayerName(targetplayerpNameMAX_PLAYER_NAME);
    
format(stringsizeof string"%s is currently holding $%i."pNameamount);
    
GetPlayerMoney(targetplayer);
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;

It says me always that the player has $0 even when the player has like 10k or smth.


Re: So weird.. - karemmahmed22 - 14.09.2015

PHP код:
CMD:getcash(playeridparams[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 1) return 0;
       if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playeridCOLOR_YELLOWGREEN"Error: You are not authorized to use this command.");
    new 
targetplayer;
    if(
sscanf(params"i"targetplayer)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /getcash [ID]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Error: Player is not connected!");
    new 
string[50], pName[MAX_PLAYER_NAME], amount;
    
GetPlayerName(targetplayerpNameMAX_PLAYER_NAME);
    
amount GetPlayerMoney(targetplayer);
    
format(stringsizeof string"%s is currently holding $%i."pNameamount);
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;




Re: So weird.. - saffierr - 14.09.2015

Same story...

EDIT: Fixed.


Re: So weird.. - karemmahmed22 - 14.09.2015

Excuse me, but i just tested it on my server, it worked prefectly :/, Are you sure?
This simple does the job as i posted above:
PHP код:
    amount GetPlayerMoney(targetplayer); // storing player money in amount.
    
format(stringsizeof string"%s is currently holding $%i."pNameamount); // formating the text with amount.
    
SendClientMessage(playeridCOLOR_YELLOWstring); //sends the message :/ 



Re: So weird.. - saffierr - 14.09.2015

View my previous post. Thank you btw.