SA-MP Forums Archive
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 2;
if(
== 2)return new string[128]; format(string,sizeof(string),"x = %d",x),SendClientMessageToAll(-1,string); 
that's errors:
PHP код:
(2742) : error 029invalid expressionassumed zero
(2742) : error 017undefined symbol "str"
(2742) : warning 215expression has no effect
(2742) : error 001expected token";"but found "]"
(2742) : fatal error 107too many error messages on one line 
Line 2742:
PHP код:
if(== 2)return new string[128]; format(string,sizeof(string),"x = %d",x),SendClientMessageToAll(-1,string); 
I don't want to use that:
PHP код:
if(== 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);