Any way to shorten this? -
mrcoolballs - 25.08.2010
I am making this rank up system which is kinda annoying
Code:
if(GetPlayerPoints(playerid) == 500)
{
SendClientMessage(playerid,ORANGE,"You have been PROMOTED! You are now Rank 2");
PlayerInfo[playerid][PLevel] = 2;
return 1;
}
if(GetPlayerPoints(playerid) == 1000)
{
SendClientMessage(playerid,ORANGE,"You have been PROMOTED! You are now Rank 3");
PlayerInfo[playerid][PLevel] = 3;
return 1;
}
if(GetPlayerPoints(playerid) == 1500)
{
SendClientMessage(playerid,ORANGE,"You have been PROMOTED! You are now Rank 4");
PlayerInfo[playerid][PLevel] = 4;
return 1;
}
instead of making them go up to level 100
is there a way that i can go like
every 500 points the player gets he goes up a level instead of ading every single one
Re: Any way to shorten this? -
RSX - 25.08.2010
pawn Code:
rank=floatround(GetPlayerPoints(playerid)/500, floatround_floor)
if(PlayerInfo[playerid][PLevel] != rank)
{
format(string, 128, "You have been PROMOTED! You are now Rank %d", rank);
SendClientMessage(playerid,ORANGE,string);
PlayerInfo[playerid][PLevel] = rank;
return 1;
}
Float functions aren't the fastest, so don't execute it like every 200ms, optionally only when someone get's points.
Re: Any way to shorten this? -
mrcoolballs - 25.08.2010
Thanks alot, but if you wouldnt mind could you explain that to me? it works but i still dont understand how
Re: Any way to shorten this? -
Claude - 25.08.2010
/ means
PlayerPoints part by
500 (10/2 = 5), it also checks if player is not the current rank
Re: Any way to shorten this? -
RSX - 25.08.2010
Ok mndfck. forgot about division using substraction. but now you have possibly gotten code you'll never understand without bunch of reading. But still, it's a bunch of float functions, as pawn seems to have only float math functions (I mean that - is anyway defined as floatsub(oper1, float(oper2)); )
Which obviusly in ****** script shows that we have to use other thing than division. Thanks for example, it's useful for me too.
Re: Any way to shorten this? -
playbox12 - 25.08.2010
Thanks ******, whas just searching pawn_language.pdf for something similar!
Re: Any way to shorten this? -
Kalcor - 25.08.2010
pawn Code:
new new_rank = (GetPlayerPoints(playerid) / 500) + 1;
Re: Any way to shorten this? -
playbox12 - 25.08.2010
Quote:
Originally Posted by Kalcor
pawn Code:
new new_rank = (GetPlayerPoints(playerid) / 500) + 1;
|
:O now thats short.
Re: Any way to shorten this? -
wups - 25.08.2010
Quote:
Originally Posted by Kalcor
pawn Code:
new new_rank = (GetPlayerPoints(playerid) / 500) + 1;
|
PAWNed lol.
Re: Any way to shorten this? -
mrcoolballs - 26.08.2010
Wow, thanks, so do i have to add anything onto that? I get an error message sayng the new_rank symbol is never used.