ternanry operator
#1

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
Reply
#2

Its not about that its about the szName, how us the code for that.
Reply
#3

pawn Код:
(pInfo[playerid][statsLastName][0] == EOS) ? (GetPlayerNameEx(playerid)) : (pInfo[playerid][statsLastName])
Thats the line.. If I remove it, everything works fine.
Reply
#4

pawn Код:
(pInfo[playerid][statsLastName][0] == EOS) ? GetPlayerNameEx(playerid) : pInfo[playerid][statsLastName];
Reply
#5

Same.
Reply
#6

Show me where you created szName, did you make sure it was a string and not an integer
Reply
#7

pawn Код:
szName[MAX_PLAYERS][MAX_PLAYER_NAME + 1]
Reply
#8

Try changing it to:
pawn Код:
szName[MAX_PLAYER_NAME + 1];
Reply
#9

szName is created for every player..
Reply
#10

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)