|
| 23 Jan 2015 08:21 PM |
Hey guys, I'm playing around with the generic RPG styled leveling system. What I trying to accomplish is if the player gets a massive gain in xp, they could possibly break it and still have enough xp left over after the level up to level up again.
I keep getting this: maximum event re-entrancy depth exceeded
And the XP keeps going into the negatives.
Script:
local needRecalc = false
function updateXP(plr, level, xp, nxp) needRecalc = false if xp.Value >= nxp.Value then xp.Value = xp.Value - nxp.Value if needRecalc == false and xp.Value >= nxp.Value then needRecalc = true end level.Value = level.Value + 1 end end
function updateLvl(plr, level, xp, nxp, gold) gold.Value = math.floor(gold.Value + ((level.Value*300)/40)) if level.Value == 1337 then nxp.Value = 1337 elseif level.Value == 273 then nxp.Value = 273 else nxp.Value = math.sqrt(math.floor((level.Value*273)+1))*2.73 end updateTag(plr, plr.Name, level, xp, nxp, gold) if needRecalc then updateXP(plr, level, xp, nxp) end end |
|
|
| Report Abuse |
|
|
cross700
|
  |
| Joined: 20 Oct 2012 |
| Total Posts: 258 |
|
| |
|
|
| 23 Jan 2015 08:27 PM |
| Anyone with a logical answer in the right direction? |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2015 08:27 PM |
| Wait you wanna remove all of the xp they gain after every level up? Thats terrible.. but i guess if you want just make it so the exp cant go over max exp. and when it hits it its set to 0 for 1 second. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2015 08:32 PM |
Nonono.. I wanna make it to where there's no excess xp..
For example...
Level 1:
XP: 1 NXP: 45
Player gains 3000 xp
XP: 3001 NXP: 45
Follow the latter after leveling
Level 2
XP: 2956 NXP: 64
Then it waits for XP to change again.. :/ So the player then has excess.. :( |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2015 08:39 PM |
| Bump? :D I'm not trying to be impatient, just really curious. |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 23 Jan 2015 08:40 PM |
| Loops or some strange calculation. The first one is easiest. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2015 08:42 PM |
Tried loops, still gets a massive negative, like somewhere alone 40k+
Calculations... Just... No.. That's what a vast majority of that is. |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 23 Jan 2015 08:43 PM |
| Then your doing your loop wrong. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2015 08:45 PM |
This should work right?
function updateStats(plr, level, xp, nxp, gold) repeat xp.Value = xp.Value - nxp.Value level.Value = level.Value + 1 gold.Value = math.floor(gold.Value + ((level.Value*300)/40)) if level.Value == 1337 then nxp.Value = 1337 elseif level.Value == 273 then nxp.Value = 273 else nxp.Value = math.sqrt(math.floor((level.Value*273)+1))*2.73 end DataStore:UpdateAsync("Level", level.Value) DataStore:UpdateAsync("Gold", gold.Value) updateTag(plr, plr.Name, level, xp, nxp, gold) wait(0.3) until xp.Value < nxp.Value end |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 10:45 AM |
| Theoretically yes but what if an exploiter changed the nxp.Value to 0. Hint, don't use Values objects using datapersistance for the values it doesnt have a max save limit per minute and has same disadvantages as using Value objects, especially since i dont see you saving them with DataStore in this script. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 05:03 PM |
Then you obviously don't know datastore
DataStore:UpdateAsync("Level", level.Value) DataStore:UpdateAsync("Gold", gold.Value) |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 07:36 PM |
I'm laughing at that. I'm talking about the exp. Unless you're mental or you just can't read then stop trying. If you can't accomplish this without help then don't disrespect the people trying to help you.
And yes I do know datastore, obviously more than you.
So you don't answer back with some idiotic assumption:
local store = game:GetService("DataStoreService"):GetDataStore("Guilds")
local Guildjoin = script.Parent.Guildjoin local Guildname = script.Parent.GuildName local Guildmemb = script.Parent.Parent.Parent.Parent.Parent local Guild local cancel = script.Parent.Cancel plr = script.Parent.Parent.Parent.Parent.Parent on = false
Guildjoin.MouseButton1Down:connect(function() if not on then on = true if store:GetAsync(Guildname.Text) ~= nil then if store:GetAsync(Guildname.Text)[4][Guildmemb.Name] == nil then Guild = store:GetAsync(Guildname.Text) if Guild[3] < 6 then Guild[3] = Guild[3] + 1 table.insert(Guild[4],{Guildmemb.Name, Guild[3]}) store:SetAsync(Guildname.Text,{Guild[1],Guild[2],Guild[3],Guild[4],Guild[3]}) plr.GuildNAME.Value = Guildname.Text script.Parent.Parent.Parent.GuildList.GuildMembers.Disabled = true wait() script.Parent.Parent.Parent.GuildList.GuildMembers.Disabled = false script.Parent.Visible = false script.Parent.Parent.Visible = false script.Parent.Parent.Parent.GuildList.Visible = true else end else end end end end)
cancel.MouseButton1Click:connect(function() script.Parent.Visible = false script.Parent.Parent.BackgroundTransparency = 0 script.Parent.Parent.Create.Visible = true script.Parent.Parent.Join.Visible = true end)
|
|
|
| Report Abuse |
|
|