SA-MP Forums Archive
parentheses - 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: parentheses (/showthread.php?tid=579843)



parentheses - JoshNudock - 30.06.2015

Hello, I was wondering how do I remove the {} of the code, and leave only one to open { and } to close, it is currently as follows:
PHP код:
                    if (PlayerInfo[i][pExp] < expamount) {} ///
                    
else
                    {
                    } 
I want to leave like this:

PHP код:
                    if (..?)
                    {
                    } 



Re: parentheses - darkowner - 30.06.2015

I think you will fuck the script if you do that.


Re: parentheses - Roko_foko - 30.06.2015

there are multiple sulutions:
first
Код:
if( !(PlayerInfo[i][pExp] < expamount)) {
    //...
}
second
Код:
if(PlayerInfo[i][pExp] >= expamount) {
    //...
}



Re : parentheses - Terrorizt - 30.06.2015

I'd rather use this one:
Код:
if(...)
{
    // ...
}



Re: Re : parentheses - Roko_foko - 30.06.2015

Quote:
Originally Posted by Terrorizt
Посмотреть сообщение
I'd rather use this one:
Код:
if(...)
{
    // ...
}
It depends on the condition inside of the if. If condition is simple yea, if condition is better understandable in negated form, use the first solution. Perfomanse is the same, today we have good compilers and they will optimise the code.