Raised This Month: $ Target: $400
 0% 

I need "for loop" algorithm


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-12-2017 , 14:40   Re: I need "for loop" algorithm
Reply With Quote #6

Here is an alternative which does everything in a single function which is a direct replacement of your if elseif code:

Code:
stock getLevel(XP)
{
	new LevelXP = 0
	new iLevel = 0
	while( XP >= LevelXP )
	{
		LevelXP = LevelXP + ADD_EXP_PER_KILL * iLevel
		iLevel++
	}
	
	return iLevel - 1
}
Example:

Code:
p_Level[id] = getLevel(currentExp)
__________________
fysiks is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode