Pawn compiler crashing
#1

For some reason, this script is causing Pawn compiler to crash. What I need it to do is check if the player entered any inputtext, and if the haven't, do this.

pawn Код:
new skin = strval(inputtext);
            if(strlen(skin) == 0)
            }
                SendClientMessage(playerid,COLOR_RED, "ERROR: Please enter a skin ID, or select Cancel.");
                ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "Enter Skin ID",  "OK", "Cancel");
                return 1;
            }
Reply
#2

pawn Код:
if(strlen(skin) == 0)
/* Like, seriously - it's right here --> */           }
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
if(strlen(skin) == 0)
/* Like, seriously - it's right here --> */           }
Yeah, I know that now, I don't know how to check if there's no text though. Thanks for the help.
Reply
#4

I meant bracket pointing wrong way! Brackets are the most important thing for the compiler, they determine scope - when you miss one, or do things like that compiler can't handle things. As for checking is there is no text, check out isnull macro:

pawn Код:
#define isnull(%1) \
        ((%1[0] == 0) || (%1[0] == 1 && %1[1] == 0))
As you might know, string is an array of chars + NUL. So "ABC" is in fact { 'A', 'B', 'C', 0 } (0, '\0' and EOS are equivalent in pawn). isnull checks if first character is 0 - meaning end of string. The other comparison is important, but it affects other things. So - to check if string is empty:
pawn Код:
if(yourstring[0] == 0)
//equivalent to
if(yourstring[0] == '\0')
//equivalent to
if(yourstring[0] == EOS)
//equivalent to
if(!yourstring[0])
But, if you have isnull defined, use it instead.
Reply
#5

How did I miss that bracket...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)