Use "return new.." Possible? - 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: Use "return new.." Possible? (
/showthread.php?tid=565830)
Use "return new.." Possible? -
GuyYahood1 - 01.03.2015
Hello,
I get error when I do it:
PHP код:
new x = 2;
if(x == 2)return new string[128]; format(string,sizeof(string),"x = %d",x),SendClientMessageToAll(-1,string);
that's errors:
PHP код:
(2742) : error 029: invalid expression, assumed zero
(2742) : error 017: undefined symbol "str"
(2742) : warning 215: expression has no effect
(2742) : error 001: expected token: ";", but found "]"
(2742) : fatal error 107: too many error messages on one line
Line 2742:
PHP код:
if(x == 2)return new string[128]; format(string,sizeof(string),"x = %d",x),SendClientMessageToAll(-1,string);
I don't want to use that:
PHP код:
if(x == 2)
{
new string[128];
format(string,sizeof(string),"x = %d",x);
return SendClientMessageToAll(-1,string);
}
There's a way to use it without errors?
Re: Use "return new.." Possible? -
CalvinC - 01.03.2015
You need to put it in a compound statement, because if you stack it like this:
pawn Код:
if(something) (function); (function);
The compiler will just use it like this:
pawn Код:
if(something) (function);
(function);