ternary operator string problem.
#1

Tried to make 2 string showing with ternary operator, so if
PlayerInfo[playerid][pBizz] differs from 999 (INVALID_BIZ_ID)
text would be 'No', otherwise should show up 'Yes'

I got error, I am pretty noob with the ternary operator, so if someone could help me I'll appreciate it.

pawn Code:
YCMD:stats(playerid, params[], help)
{
    #pragma unused help
    #pragma unused params
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        return SCM(playerid, COLOR_PURPLE, ""gray" * Cant use this command while being driver  !");
    new biss[4], car[4];
    format( biss, 4, "%s", ( PlayerInfo[playerid][pBizz] != INVALID_BIZZ_ID ) ? "Yes" : "No");
        // error 001: expected token: "-string end-", but found "-identifier-"
    format(  car, 4, "%s", ( PlayerInfo[playerid][pCar]   !=   INVALID_CAR_ID ) ? "Yes" : "No");
        // error 001: expected token: "-string end-", but found "-identifier-"
    new string[300];
    format(string, sizeof(string),
    ""yellow"|E-mail: "white"%s"yellow" |Level: "white"%d"yellow" |Cash: "white"%d"yellow" |BankAccount: "white"%d\n\
    "
yellow"|PhNumber: "white"%d"yellow" |PhAcc: "white"%d"yellow" |PayExp: "white"%d/20 "yellow"|Pays had: "white"%d\n\
    "
yellow"|Bizz: "white"%s"yellow" |Car: "white"%s\n\
    "
yellow"|Last log: "white"%s",
    PlayerInfo[playerid][pEmail], PlayerInfo[playerid][pLevel], SafeGetPlayerMoney(playerid),
    PlayerInfo[playerid][pBankAcc], PlayerInfo[playerid][pPhoneNr], PlayerInfo[playerid][pPhoneAcc], PlayerInfo[playerid][pPayExp], PlayerInfo[playerid][pPaysHad], biss, car,
    PlayerInfo[playerid][pLastLog]);
    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, "Info", string, "Ok", "");
    return 1;
}
Reply
#2

Wrap the strings in parentheses like ("Yes") and ("No"). This will work. Y_Less broke something in the compiler while adapting it for SA-MP.
Reply
#3

pawn Code:
biss = ( PlayerInfo[playerid][pBizz] != INVALID_BIZZ_ID ) ? ("Yes") : ("No");
car = ( PlayerInfo[playerid][pCar]   !=   INVALID_CAR_ID ) ? ("Yes") : ("No");
Reply
#4

Quote:
Originally Posted by Vince
View Post
Wrap the strings in parentheses like ("Yes") and ("No"). This will work. Y_Less broke something in the compiler while adapting it for SA-MP.
Thank you, but Haven't understood it clearly. REP anyway!
Quote:
Originally Posted by Jefff
View Post
pawn Code:
biss = ( PlayerInfo[playerid][pBizz] != INVALID_BIZZ_ID ) ? ("Yes") : ("No");
car = ( PlayerInfo[playerid][pCar]   !=   INVALID_CAR_ID ) ? ("Yes") : ("No");
Thanks, compiles nice, gonna check it later! REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)