Help me fast. - 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: Help me fast. (
/showthread.php?tid=634518)
Help me fast. -
Smokinn - 20.05.2017
* Script code:
if(strlen(inputtext))
{
new tmppass[64];
mysql_real_escape_string(inputtext, tmppass);
//************************************************** ****************
OnPlayerLogin(playerid, tmppass);
}
* Warning:
warning 225: unreachable code
* Warning line/code:
if(strlen(inputtext))
Re: Help me fast. -
Smokinn - 20.05.2017
Thanks.
Re: Help me fast. -
Affan - 23.05.2017
Код:
if(strlen(inputtext) > 0)
Try this. I guess you are trying to check if the inputtext has any characters whatsoever. So by adding greater than 0, it will check if inputtext has any text at all.
Re: Help me fast. -
Vince - 23.05.2017
"Unreachable". Means it can't be reached and will never be executed. Also means you need to look at the code above it, not below it.
Re: Help me fast. -
NaS - 23.05.2017
Quote:
Originally Posted by Affan
Код:
if(strlen(inputtext) > 0)
Try this. I guess you are trying to check if the inputtext has any characters whatsoever. So by adding greater than 0, it will check if inputtext has any text at all.
|
It is the same in this case (of course yours isn't wrong, but you don't have to do it, nor is it the solution here). Because any number greater than 0 is considered true, that will make it valid - so any length but 0 will execute the code within the if statement.
This cannot technically be the cause for Warning 225. strlen() returns a value that isn't known at compile time - thus regardless which checks are done the code in brackets can potentially always be executed in a specific case - so it is in theory always reachable. Also the Compiler doesn't know that strlen can only return positive values or zero, so even if you do if(strlen(string) < 0) that warning will not be thrown.
Re: Help me fast. -
Affan - 24.05.2017
Quote:
Originally Posted by NaS
It is the same in this case (of course yours isn't wrong, but you don't have to do it, nor is it the solution here). Because any number greater than 0 is considered true, that will make it valid - so any length but 0 will execute the code within the if statement.
This cannot technically be the cause for Warning 225. strlen() returns a value that isn't known at compile time - thus regardless which checks are done the code in brackets can potentially always be executed in a specific case - so it is in theory always reachable. Also the Compiler doesn't know that strlen can only return positive values or zero, so even if you do if(strlen(string) < 0) that warning will not be thrown.
|
Oh thanks, you learn a new thing everyday!