So weird..
#1

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

PHP код:
CMD:getcash(playerid, params[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 1) return 0;
       if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
    new 
targetplayer;
    if(
sscanf(params, "i", targetplayer)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /getcash [ID]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
    new 
string[50], pName[MAX_PLAYER_NAME], amount;
    
GetPlayerName(targetplayer, pName, MAX_PLAYER_NAME);
    
format(string, sizeof string, "%s is currently holding $%i.", pName, amount);
    
GetPlayerMoney(targetplayer);
    
SendClientMessage(playerid, COLOR_YELLOW, string);
    return 
1;
} 
It says me always that the player has $0 even when the player has like 10k or smth.
Reply
#2

PHP код:
CMD:getcash(playerid, params[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 1) return 0;
       if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
    new 
targetplayer;
    if(
sscanf(params, "i", targetplayer)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /getcash [ID]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
    new 
string[50], pName[MAX_PLAYER_NAME], amount;
    
GetPlayerName(targetplayer, pName, MAX_PLAYER_NAME);
    
amount = GetPlayerMoney(targetplayer);
    
format(string, sizeof string, "%s is currently holding $%i.", pName, amount);
    
SendClientMessage(playerid, COLOR_YELLOW, string);
    return 
1;
} 
Reply
#3

Same story...

EDIT: Fixed.
Reply
#4

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(string, sizeof string, "%s is currently holding $%i.", pName, amount); // formating the text with amount.
    
SendClientMessage(playerid, COLOR_YELLOW, string); //sends the message :/ 
Reply
#5

View my previous post. Thank you btw.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)