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:18   Re: I need "for loop" algorithm
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
Code:
for(new i = 1; i <= MAX_LEVEL; i++) {     p_Level[i++]     continue; }

This?
Quote:
Originally Posted by CreativeTR View Post
of course not

example:

HTML Code:
 for(new i = 1; i <= MAX_LEVEL; i++) {
                        if(currentExp >= (currentExp*i) && currentExp <= (currentExp*i) + (currentExp*i)) {
                                 p_Level[i]
                                 break;
                        }
 }
Neither of those make any sense. They don't actually do anything.

This function will give you the required XP for the supplied level:

Code:
stock getLevelXP(level)
{
	return level > 0 ? getLevelXP(level - 1) + ADD_EXP_PER_KILL * (level - 1) : 0
}
And you can use it like this:
Code:
PlayerLevel = XP > getLevelXP(PlayerLevel + 1) ? PlayerLevel + 1 : PlayerLevel
Note that it won't automatically detect a gain of more than 1 level between subsequent executions. So, you either need to compensate by calling it often enough that that situation never happens or use a loop to count up from PlayerLevel + 1 until XP > getLevelXP() returns false.
__________________

Last edited by fysiks; 03-12-2017 at 14:18.
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