if , itches my brain -
cmg4life - 25.08.2011
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 ?
Re: if , itches my brain -
Johndaonee - 25.08.2011
use
Re: if , itches my brain -
cmg4life - 25.08.2011
Can't use "switch", i'm stuck between "if" and "else if" .
Re: if , itches my brain -
WooTFTW - 25.08.2011
if(pickupid)
else if(pickupid)
is more efficent.
But if you can, you should
switch(pickupid)
Re: if , itches my brain -
Mean - 27.08.2011
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
Re: if , itches my brain -
Kingunit - 28.08.2011
I always use just "if" "if" "if". I don't see the point of "if" "else if" "else if"
Re: if , itches my brain -
lolumadd_ - 28.08.2011
Quote:
Originally Posted by Kingunit
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
type structure.
Re: if , itches my brain -
=WoR=Varth - 28.08.2011
Quote:
Originally Posted by lolumadd_
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
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;
}
Re: if , itches my brain -
AndreT - 28.08.2011
Dialog IDs are perfectly static though so the performance there can be improved by using switch!