PDA

View Full Version : operator.


KessMan
28/10/2016, 08:51 PM
How can optimize?
if(price < 1000 || price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");

SickAttack
28/10/2016, 08:53 PM
It's already fine how it is.

KessMan
28/10/2016, 09:07 PM
It's already fine how it is.

Not work...
if(1000 < price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");

SickAttack
28/10/2016, 09:32 PM
Not work...
if(1000 < price > 200000) return SendClientMessage(playerid, COLOR_DARKGRAY, "ERROR.");

Try it...

Freaksken
28/10/2016, 09:32 PM
How can optimize?
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

Not work...
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

Threshold
29/10/2016, 03:30 AM
I always use something like:
if(!(1000 <= price <= 200000))
But that's just my personal preference.

Freaksken
29/10/2016, 04:00 AM
I always use something like:
if(!(1000 <= price <= 200000))
But that's just my personal preference.

Omg, that syntax actually works in Pawn? Didn't even know! :D 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.

SickAttack
29/10/2016, 04:08 AM
Omg, that syntax actually works in Pawn? Didn't even know! :D 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.