Pawn compiler crashing - 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: Pawn compiler crashing (
/showthread.php?tid=499014)
Pawn compiler crashing -
Aerotactics - 06.03.2014
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;
}
Re: Pawn compiler crashing -
Misiur - 06.03.2014
pawn Код:
if(strlen(skin) == 0)
/* Like, seriously - it's right here --> */ }
Re: Pawn compiler crashing -
Aerotactics - 06.03.2014
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.
Re: Pawn compiler crashing -
Misiur - 06.03.2014
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.
Re: Pawn compiler crashing -
Aerotactics - 06.03.2014
How did I miss that bracket...