if , itches my brain
#1

I kinda' forgot this, but with Pickupid & Dialogid, is it better to do if( pickupid ) else if ( pickupid ) or just if ( pickupid ) then if ( pickupid ) ?

What's more efficient, laggyless and so on ?
Reply
#2

use
pawn Code:
switch( dialogid )
   {

   }
Reply
#3

Can't use "switch", i'm stuck between "if" and "else if" .
Reply
#4

if(pickupid)
else if(pickupid)

is more efficent.

But if you can, you should
switch(pickupid)
Reply
#5

Nothing is more efficient as far as I know. They both work and "else" is kinda useless here.

But, if you are that concerned about the correctness, use else if. I don't see how "if" and then "if" can fail though.

By the way: I don't see how you can be stuck with "if". o_O
Reply
#6

I always use just "if" "if" "if". I don't see the point of "if" "else if" "else if"
Reply
#7

Quote:
Originally Posted by Kingunit
View Post
I always use just "if" "if" "if". I don't see the point of "if" "else if" "else if"
The point of using else if is so that if one statement above it is true, it wont continue to the next statement and continue to check.

I'm guessing you can't use switch because the pickup id's aren't static (pickup id's are assigned to variables).

And to answer your question, for dialogs (since dialogs are static id's), you should use a switch statement.
And for the pickups, if you aren't going to use static id's, it is recommended to do a
Code:
if
else if
else if
type structure.
Reply
#8

Quote:
Originally Posted by lolumadd_
View Post
The point of using else if is so that if one statement above it is true, it wont continue to the next statement and continue to check.

I'm guessing you can't use switch because the pickup id's aren't static (pickup id's are assigned to variables).

And to answer your question, for dialogs (since dialogs are static id's), you should use a switch statement.
And for the pickups, if you aren't going to use static id's, it is recommended to do a
Code:
if
else if
else if
type structure.
Of course they are static. https://sampwiki.blast.hk/wiki/CreatePickup
And I recommend him to use switch for pickup:
pawn Code:
public OnPlayerPickUpPickup(playerid,pickupid)
{
    switch(pickupid)
    {
        case House: //...............
        case Weapon:
        {
            //.................
        }
    }
    return 1;
}
Reply
#9

Dialog IDs are perfectly static though so the performance there can be improved by using switch!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)