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(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.
Re: So weird.. -
karemmahmed22 - 14.09.2015
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;
}
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(string, sizeof string, "%s is currently holding $%i.", pName, amount); // formating the text with amount.
SendClientMessage(playerid, COLOR_YELLOW, string); //sends the message :/
Re: So weird.. -
saffierr - 14.09.2015
View my previous post. Thank you btw.