!INVALID_PLAYER_ID - 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: !INVALID_PLAYER_ID (
/showthread.php?tid=643767)
!INVALID_PLAYER_ID -
SeanDenZYR - 27.10.2017
MY CODE:
Code:
202CMD:bal(playerid, params[])
203{
204 new targetid;
205 new money2 = GetPlayerMoney(targetid);
206 new money = GetPlayerMoney(playerid);
207 new a[MAX_PLAYER_NAME+51];
208 format(a, sizeof(a), "{0FD620}Balance:{F50C0C} $%s", money);
209 SendClientMessage(playerid, -1, a);
210 if(!strcmp(selection, !INVALID_PLAYER_ID, true))
211 {
212 new name[MAX_PLAYER_NAME];
213 GetPlayerName(targetid, name, sizeof(name));
214 format(a, sizeof(a), "{0FD620}Balance of %s:{F50C0C} $%s",name,money2);
215 SendClientMessage(playerid, -1, a);
216 }
217 return 1;
218}
ERROR:
Code:
(210) : error 035: argument type mismatch (argument 2)
Re: !INVALID_PLAYER_ID -
Banditul18 - 27.10.2017
I have no idea what u want to do but u can't compare a string with an integer that way(presuming selection its a string)
Enentually you can transform selection into a integer(presuming you store some sort of id) and then compare with invalid_player_id
Re: !INVALID_PLAYER_ID -
SeanDenZYR - 27.10.2017
what i was tryna' do was if he just writes /bal, it only shows his money. but if he does /bal <playerid/playername> he gets the balance of another player
Re: !INVALID_PLAYER_ID -
Zeth - 27.10.2017
You can make this way simple using sscanf
PHP Code:
CMD:bal(playerid, params[])
{
new targetid;
new money = GetPlayerMoney(playerid);
new a[128];
if(sscanf(params, "u", targetid))
{
format(a, sizeof(a), "{0FD620}Balance:{F50C0C} $%s", money);
SendClientMessage(playerid, -1, a);
return 1;
}
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Error: Specified player is not connected.");
new money2 = GetPlayerMoney(targetid);
new name[MAX_PLAYER_NAME];
GetPlayerName(targetid, name, sizeof(name));
format(a, sizeof(a), "{0FD620}Balance of %s:{F50C0C} $%s",name,money2);
SendClientMessage(playerid, -1, a);
return 1;
}
Re: !INVALID_PLAYER_ID -
SeanDenZYR - 27.10.2017
thanks, i think its time to learn sscanf..
Re: !INVALID_PLAYER_ID -
Sew_Sumi - 27.10.2017
Quote:
Originally Posted by SeanDenZYR
thanks, i think its time to learn sscanf..
|
Better to also learn how to use simple checks though too.