operator. - 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: operator. (
/showthread.php?tid=620309)
operator. -
KessMan - 28.10.2016
How can optimize?
Код HTML:
if(price < 1000 || price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");
Re: operator. -
SickAttack - 28.10.2016
It's already fine how it is.
Re: operator. -
KessMan - 28.10.2016
Quote:
Originally Posted by SickAttack
It's already fine how it is.
|
Not work...
Код HTML:
if(1000 < price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");
Re: operator. -
SickAttack - 28.10.2016
Quote:
Originally Posted by KessMan
Not work...
Код HTML:
if(1000 < price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");
|
Try it...
Re: operator. -
Freaksken - 28.10.2016
Quote:
Originally Posted by KessMan
How can optimize?
Код HTML:
if(price < 1000 || price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");
|
Price < 1000: Price can be negative infinity to 999
Price > 200000: Price can be 200001 to positive infinity
Quote:
Originally Posted by KessMan
Not work...
Код HTML:
if(1000 < price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");
|
1000 < price > 200000: Doesn't work in Pawn
EDIT: I was wrong, this syntax does work! The rest of my post is still valid though. + if this syntax would work, it's not even the same as the first code
1000 < price: Price can be 1001 to positive infinity
price > 200000: Price can be 200001 to positive infinity
Re: operator. -
Threshold - 29.10.2016
I always use something like:
PHP код:
if(!(1000 <= price <= 200000))
But that's just my personal preference.
Re: operator. -
Freaksken - 29.10.2016
Quote:
Originally Posted by Threshold
I always use something like:
PHP код:
if(!(1000 <= price <= 200000))
But that's just my personal preference.
|
Omg, that syntax actually works in Pawn? Didn't even know!

Glad I learned something!
Код:
//This:
if(1000 < price && price < 200000) {
...
}
//Is the same as this:
if(1000 < price < 200000) {
...
}
//And it actually works in this language.
Re: operator. -
SickAttack - 29.10.2016
Quote:
Originally Posted by Freaksken
Omg, that syntax actually works in Pawn? Didn't even know!  Glad I learned something!
Код:
//This:
if(1000 < price && price < 200000) {
...
}
//Is the same as this:
if(1000 < price < 200000) {
...
}
//And it actually works in this language.
|
People have said that it is slower. So you aren't really optimizing anything.