Using an array (enumerator and specifically a string) in a ternary operator causes the compiler to crash
#1

Instead of repeating myself when kicking a player, I've added a few parameters to my kick function and I'm now sending the message in the function's body.

PHP код:
KickEx(playerid, const reason[], kickerid INVALID_PLAYER_ID
I am using a custom function to send tagged messages (i.e: "[Error] message", where [Error] is the tag) but it's basically the same as 'ChatMsg' as seen in Southclaw's Scavenge&Survive: https://github.com/Southclaw/Scaveng...ls/message.pwn

Now all this has been irrelevant to the actual problem, which is the following line:
PHP код:
SendTaggedMessageToPlayer(playeridTYPE_ADMIN"%p has been kicked by the server by %s, reason: %s"playerid, ((kickerid == INVALID_PLAYER_ID) ? ("The Server") : (Player[kickerid][epd_Username])), reason); 
I've managed to dismantle the code to find the culprit and I was able to break it down to:
PHP код:
((kickerid == INVALID_PLAYER_ID) ? ("The Server") : (Player[kickerid][epd_Username])) 
Specifically to:
PHP код:
Player[kickerid][epd_Username
Replacing it with a literal string, fixes the problem, but is not the solution I seek:
PHP код:
((kickerid == INVALID_PLAYER_ID) ? ("The Server") : ("")) 
Is my code invalid or is this a compiler bug(/restriction?)?

By the way, epd_Username is declared as:
PHP код:
epd_Username[MAX_PLAYER_NAME
And I'm using it in OnPlayerConnect:
PHP код:
GetPlayerName(playeridPlayer[playerid][epd_Username], MAX_PLAYER_NAME); 
Reply
#2

Compiler bug.
Reply
#3

Did you try creating a new variable within the function?
PHP код:
//stock kick(blabla)
{
    new 
pName[24];
    
format(pName24Player[kickerid][epd_Username]); //Or if it still doesn't work; format(pName, 24, "%s", Player[kickerid][epd_Username]);
    //Messagestuff ("The server") : (pName)

Compilers sometimes are funny, and when something doesn't work one way, it does work the other way while the principle is the same.
Reply
#4

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Did you try creating a new variable within the function?
PHP код:
//stock kick(blabla)
{
    new 
pName[24];
    
format(pName24Player[kickerid][epd_Username]); //Or if it still doesn't work; format(pName, 24, "%s", Player[kickerid][epd_Username]);
    //Messagestuff ("The server") : (pName)

Compilers sometimes are funny, and when something doesn't work one way, it does work the other way while the principle is the same.
That's not what I was essentially doing as I'm already getting the player's name in OnPlayerConnect. Though, I did bypass the bug like that.

I've posted an issue on Zeex's repository and ****** pretty much confirmed that it got fixed in his compiler patches and it indeed seems to be.
Reply
#5

I know you didn't want to do that because you already got the name; but I was suggesting it to see if it then would compile, because it isn't a solution but a workaround.
Anyway, glad it's been fixed with that patch.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)