What's the difference? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What's the difference? (
/showthread.php?tid=65811)
What's the difference? -
Danut - 16.02.2009
I've got this on a script , and i don't know why he use more than
return 1 +
pawn Код:
public HouseLevel(playerid)
{
if(IsPlayerConnected(playerid))
{
new h = PlayerInfo[playerid][pPhousekey];
if(h == 500)
{
return 0;
}
if(h <= 4)
{
return 1;
}
if(h >= 5 && h <= 9)
{
return 2;
}
if(h >= 10 && h <= 18)
{
return 3;
}
if(h >= 19 && h <= 22)
{
return 4;
}
if(h >= 23 && h <= 25)
{
return 5;
}
if(h == 26)
{
return 6;
}
if(h == 27)
{
return 7;
}
if(h >= 28 && h <= 31)
{
return 7;
}
if(h >= 32 && h <= 67)
{
return 8;
}
}
return 0;
}
Why he use return 2 , 3 , 4, 5, 6, 7, 8 !?
It's not the same difference ?
Re: What's the difference? -
MenaceX^ - 16.02.2009
Hard to explain :S, Dunno how even :\
Re: What's the difference? -
Danut - 16.02.2009
so
return 1 isn't
= with
return 2+ ?
Re: What's the difference? -
[LDT]LuxurY - 16.02.2009
Function always returns only 1 value and it could be everything, but the same type.
pawn Код:
if(h == 500)
{
return 0;
}
it's useless.
anyway it'll be simplier to create it with switch/case construction.
Edit: evil post
Re: What's the difference? -
Think - 16.02.2009
Quote:
Originally Posted by Danut
I've got this on a script , and i don't know why he use more than return 1 +
pawn Код:
public HouseLevel(playerid) { if(IsPlayerConnected(playerid)) { new h = PlayerInfo[playerid][pPhousekey]; if(h == 500) { return 0; } if(h <= 4) { return 1; } if(h >= 5 && h <= 9) { return 2; } if(h >= 10 && h <= 18) { return 3; } if(h >= 19 && h <= 22) { return 4; } if(h >= 23 && h <= 25) { return 5; } if(h == 26) { return 6; } if(h == 27) { return 7; } if(h >= 28 && h <= 31) { return 7; } if(h >= 32 && h <= 67) { return 8; } } return 0; }
Why he use return 2 , 3 , 4, 5, 6, 7, 8 !?
It's not the same difference ?
|
its like, if your housekey is like the first one 500, your house level will be 0 because it returns on 0
Re: What's the difference? -
Joe Staff - 16.02.2009
It's a way of figuring out a house's level.
It returns a different number so it can be used in a conditional
for example
pawn Код:
if(HouseLevel(playerid)<3)
{
return SendClientMessage(playerid,0xFF0000FF,"Your house is not high enough level to use this upgrade");
}
Re: What's the difference? -
Daren_Jacobson - 16.02.2009
you can return anything you want, 0 will make it pass using the !
pawn Код:
Function(params)
{
return params;
}
or
that would pass but
would not pass