Any way to shorten this?
#1

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
Reply
#2

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.
Reply
#3

Thanks alot, but if you wouldnt mind could you explain that to me? it works but i still dont understand how
Reply
#4

/ means PlayerPoints part by 500 (10/2 = 5), it also checks if player is not the current rank
Reply
#5

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.
Reply
#6

Thanks ******, whas just searching pawn_language.pdf for something similar!
Reply
#7

pawn Code:
new new_rank = (GetPlayerPoints(playerid) / 500) + 1;
Reply
#8

Quote:
Originally Posted by Kalcor
View Post
pawn Code:
new new_rank = (GetPlayerPoints(playerid) / 500) + 1;
:O now thats short.
Reply
#9

Quote:
Originally Posted by Kalcor
View Post
pawn Code:
new new_rank = (GetPlayerPoints(playerid) / 500) + 1;
PAWNed lol.
Reply
#10

Wow, thanks, so do i have to add anything onto that? I get an error message sayng the new_rank symbol is never used.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)