raynner Posted October 24, 2016 Share Posted October 24, 2016 I'm doing a script level system is almost ending but I got to a point where you really do not know how to do because I have a broad knowledge in Lua. Client. --Note Value EXP comes from Server Side in the original script ValuerEXP = 30 NEWXP = guiProgressBarSetProgress(XpBar,guiProgressBarGetProgress(XpBar) + ValuerEXP) Good to look at this and have one and are a good listener will soon notice that this is a serious mistake. good if ValuerEXP = 30 and suppose ProgressBar (XpBar) = 80 we would have a total value of 110 is therefore just ahead in the script I define it. if (guiProgressBarGetProgress(XpBar) == 100) then guiProgressBarSetProgress(XpBar, 0) guiProgressBarSetProgress(LevelBar,getElementData(source, "LVL")+1) end I wanted to have a way to get the total value divilo and pick up the spare and set this spare in the following function could anyone help me with this? the inves set to 0 somehow get the value of the spare take 110 if get the rest = 10 and definilo below the inves 0. because in this way that I am getting only 20 of 30 EXP promised. Help me Link to comment
Captain Cody Posted October 24, 2016 Share Posted October 24, 2016 May you please explain better what you are trying to accomplish? Link to comment
raynner Posted October 24, 2016 Author Share Posted October 24, 2016 if getElementData(source, "EXP") and getElementData(source, "LVL") then ValuerEXP = 30 NEWXP = guiProgressBarSetProgress(XpBar,guiProgressBarGetProgress(XpBar) + ValuerEXP) ----- (guiProgressBarGetProgress(XpBar) = 80 + ValuerEXP = 30) = 110 end ---- if (guiProgressBarGetProgress(XpBar) == 100) then --- Here We have wasted 10 EXP ! :( --- ie the player has not received 30/30 Yes it is 20/30. guiProgressBarSetProgress(XpBar, 0) -- right is to take the leftovers in the case 10 guiProgressBarSetProgress(LevelBar,getElementData(source, "LVL")+1) end -- I wanted was to rescue this value in the case 10 and give her the inves set to 0 Link to comment
pa3ck Posted October 24, 2016 Share Posted October 24, 2016 Take a look at this topic: https://forum.multitheftauto.com/topic/89947-problems-with-custom-level-system/ Link to comment
raynner Posted October 24, 2016 Author Share Posted October 24, 2016 (edited) Solved I was organizing the time the player would earn EXP for their level and I had an idea and just thinking about it, then I will share to help others function .....() if getElementData(source, "EXP") and getElementData(source, "LVL") then TotalNewEXP = (guiProgressBarGetProgress(XpBar)+ValuerEXP) if (TotalNewEXP >= 100) then GiveCorrectEXP = TotalNewEXP - 100 NEWXP = guiProgressBarSetProgress(XpBar,guiProgressBarGetProgress(XpBar) + ValuerEXP) setElementData(source, "EXP", NEWXP) else NEWXP = guiProgressBarSetProgress(XpBar,guiProgressBarGetProgress(XpBar) + ValuerEXP) setElementData(source, "EXP", NEWXP) end if guiProgressBarGetProgress(XpBar) ~= 100 then outputChatBox("#FFAA00||#FFFF00 ❗ #FFAA00||#00FF7B +"..ValuerEXP.." #FFFF00In #00FF7BEXP #FFFF00It was acquired by completing the mission. EXP Total#00FF7B "..guiProgressBarGetProgress(XpBar).."#FFFF00.",255,255,255,true) end if (guiProgressBarGetProgress(XpBar) == 100) then guiProgressBarSetProgress(XpBar, GiveCorrectEXP) guiProgressBarSetProgress(LevelBar,getElementData(source, "LVL")+1) LVL = guiProgressBarGetProgress(LevelBar) setElementData(source, "LVL", LVL) outputChatBox("#FFAA00||#FFFF00 ❗ #FFAA00||#FFFF00Your #00FF7BEXP #FFFF00We reached the maximum its level was raised to #00FF7B"..getElementData(source,"LVL").."#FFFF00.",255,255,255,true) end end end Edited October 24, 2016 by raynner Link to comment
Dealman Posted October 24, 2016 Share Posted October 24, 2016 (edited) I think what he's trying to say he want to store the remainder towards the new level. Is every new level at 100? If yes, you can do this; if(getElementData(source, "EXP") and getElementData(source, "LVL")) then valuerEXP = 30 local currentXP = guiProgressBarGetProgress(XpBar) -- (80) -- Check if the result is greater than 100 if(currentXP+valuerEXP > 100) then local neededXP = 100-currentXP -- (100-80 = 20) local remainingXP = valuerXP-neededXP -- (30-20 = 10) guiProgressBarSetProgress(XpBar, remainingXP) guiProgressBarSetProgress(LevelBar, getElementData(source, "LVL")+1) -- Check if the result is less than 100 elseif(currentXP+valuerEXP < 100) then guiProgressBarSetProgress(XpBar, (currentXP+valuerEXP)) -- Check if the result is equal to 100 elseif(currentXP+valuerEXP == 100) then guiProgressBarSetProgress(XpBar, 0) guiProgressBarSetProgress(LevelBar, getElementData(source, "LVL")+1) end end Of course it depends on how your system works, and there are other ways to do it. Edit: Nvm you fixed it already Edited October 24, 2016 by Dealman Link to comment
raynner Posted October 25, 2016 Author Share Posted October 25, 2016 19 minutes ago, Dealman said: I think what he's trying to say he want to store the remainder towards the new level. Is every new level at 100? If yes, you can do this; if(getElementData(source, "EXP") and getElementData(source, "LVL")) then valuerEXP = 30 local currentXP = guiProgressBarGetProgress(XpBar) -- (80) -- Check if the result is greater than 100 if(currentXP+valuerEXP > 100) then local neededXP = 100-currentXP -- (100-80 = 20) local remainingXP = valuerXP-neededXP -- (30-20 = 10) guiProgressBarSetProgress(XpBar, remainingXP) guiProgressBarSetProgress(LevelBar, getElementData(source, "LVL")+1) -- Check if the result is less than 100 elseif(currentXP+valuerEXP < 100) then guiProgressBarSetProgress(XpBar, (currentXP+valuerEXP)) -- Check if the result is equal to 100 elseif(currentXP+valuerEXP == 100) then guiProgressBarSetProgress(XpBar, 0) guiProgressBarSetProgress(LevelBar, getElementData(source, "LVL")+1) end end Of course it depends on how your system works, and there are other ways to do it. Edit: Nvm you fixed it already Oh OK thank you man more I talked to up already working perfectly still thank you: D Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now