• XP System working out how much XP they just gained help
    4 replies, posted
[CODE] local client = LocalPlayer() xptable = {} if xptable == nil then table.insert( xptable, tonumber(client:GetNWInt( "XPBar" )) elseif tonumber(client:GetNWInt( "XPBar" )) != tonumber(xptable) then client:PrintMessage( HUD_PRINTTALK, "+"..math.Clamp( client:GetNWInt( "XPBar" ), 0, xptable ) ) table.Empty( xptable ) end [/CODE] Well I have an Leveling system but, I wan't to display a +(how much xp they just gained) system to my leveling system. Like when a player has more XP then, the inserted table then display how much xp they just gained. Aka, little johnny got +150, and then in chat he saw: +150. Little johnny was super excited! Is this how you work out the difference between xptable and the client:GetNWInt()? with math.Clamp. And using insert tables? Or is that wrong, because I want this on each individual player. Thanks please help jacob :D
Why are you doing [CODE] tonumber(xptable) [/CODE] When the table isn't a number? Your code always confuses me a bit until I read it for a few minutes :p
I feel like you've totally over complicated what you want to accomplish
If I were doing a system like the one I think you're trying to do, I'd probably do something like this instead: [CODE] xptable = {} local client = LocalPlayer() local XPBarNumber = tonumber(client:GetNWInt( "XPBar" )) xptable[ client ] = xptable[ client ] or XPBarNumber -- This sets it to XPBarNumber if the table key for the player was nil before if xptable[ client ] ~= XPBarNumber then local diff = XPBarNumber - xptable[ client ] client:PrintMessage( HUD_PRINTTALK, "+"..diff ) xptable[ client ] or XPBarNumber end [/CODE] God knows if it makes sense to anyone except me, but it looks better in my head
[QUOTE=MPan1;50967172]If I were doing a system like the one I think you're trying to do, I'd probably do something like this instead: [CODE] xptable = {} local client = LocalPlayer() local XPBarNumber = tonumber(client:GetNWInt( "XPBar" )) xptable[ client ] = xptable[ client ] or XPBarNumber -- This sets it to XPBarNumber if the table key for the player was nil before if xptable[ client ] ~= XPBarNumber then local diff = XPBarNumber - xptable[ client ] client:PrintMessage( HUD_PRINTTALK, "+"..diff ) xptable[ client ] or XPBarNumber end [/CODE] God knows if it makes sense to anyone except me, but it looks better in my head[/QUOTE] I understand it lol
Sorry, you need to Log In to post a reply to this thread.