Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exp Rollover fix
#1
Currently, the exp rolls over, but because the CheckPlayerLevelUp is only called once, the exp will basically just pool up, with the level up only ever being called when an NPC is killed.

Here's a quick fix.

Replace this line:
Code:
If GetPlayerExp(inde...

With:
Code:
Do While GetPlayerExp(Index) >= GetPlayerNextLevel(Index)

Replace the end if at the bottom with:
Code:
DoEvents
Loop

All this does, is loop through until the player no longer has enough exp to level up.

It'll now spam '[Name] has gained a level!' in the GlobalChat, however.

Can quickly fix that by adding this after the loop:

Code:
Call GlobalMsg(GetPlayerName(Index) & " has gained " & levelCount & " level(s)!", Brown)
Call PlayerMsg(Index, "You have gained " & levelCount & " level(s)!  You now have " & GetPlayerPOINTS(Index) & " stat points to distribute.", BrightBlue)

Adding this to the top of the subroutine:

Code:
Dim levelCount As Byte

Then replacing these 2 lines:
Code:
Call GlobalMsg(GetPlayer...
Call PlayerMsg(Index, "Yo...

With:

Code:
levelCount = levelCount + 1

Then, add this line just above the entire loop:

Code:
If Not GetPlayerExp(Index) >= GetPlayerNextLevel(Index) Then Exit Sub

Here it is in action:
[Image: levels.png]
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#2
Nice. Added
Reply
#3
levelCount = 0 isn't needed Big Grin
Reply
#4
Oops, forgot to add this to tutorial.

If you've already added the tutorial, add:

Code:
If Not GetPlayerExp(Index) >= GetPlayerNextLevel(Index) Then Exit Sub

Just before the loop. Added it to the tutorial now, so if you haven't added it yet, don't worry about it.

Not having that line in meant the server was spammed with "[Name] gained 0 level(s)!" because it didn't exit the sub if the player hadn't leveled at all ;D That line just exits out if no level takes place.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)