ternanry operator - 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: ternanry operator (
/showthread.php?tid=365811)
ternanry operator -
BaubaS - 04.08.2012
What's wrong in that use of ternanry operator?
pawn Код:
(pInfo[playerid][statsLastName][0] == EOS) ? (GetPlayerNameEx(playerid)) : (pInfo[playerid][statsLastName])
pawn Код:
#define GetPlayerNameEx(%0) (szName[%0])
Quote:
(1385 -- 1386) : error 033: array must be indexed (variable "szName")
|
It should work like that: if
statsLastName is null, it would show current player name. Else, it would show
statsLastName
Re: ternanry operator -
Mento - 04.08.2012
Its not about that its about the szName, how us the code for that.
Re: ternanry operator -
BaubaS - 04.08.2012
pawn Код:
(pInfo[playerid][statsLastName][0] == EOS) ? (GetPlayerNameEx(playerid)) : (pInfo[playerid][statsLastName])
Thats the line.. If I remove it, everything works fine.
Re: ternanry operator -
Mento - 04.08.2012
pawn Код:
(pInfo[playerid][statsLastName][0] == EOS) ? GetPlayerNameEx(playerid) : pInfo[playerid][statsLastName];
Re: ternanry operator -
BaubaS - 04.08.2012
Same.
Re: ternanry operator -
Mento - 04.08.2012
Show me where you created szName, did you make sure it was a string and not an integer
Re: ternanry operator -
BaubaS - 04.08.2012
pawn Код:
szName[MAX_PLAYERS][MAX_PLAYER_NAME + 1]
Re: ternanry operator -
Mento - 04.08.2012
Try changing it to:
pawn Код:
szName[MAX_PLAYER_NAME + 1];
Re: ternanry operator -
BaubaS - 04.08.2012
szName is created for every player..
Re: ternanry operator -
leonardo1434 - 04.08.2012
it should be like this, instead of a 2D array.
pawn Код:
new szName[MAX_PLAYER_NAME + 1];
#define GetPlayerNameEx(%0) GetPlayerName(%0,szName,sizeof(szName))
// usage
GetPlayerNameEx(playerid);