ZeyadGTX Posted January 28, 2015 Posted January 28, 2015 My level system shows Lv : and XP: In my Hud by using @ dxDrawText Function The Problem is, that's what shown in my Hud LV: 50 XP : 65004 How Can i make it get the Experience required to level up like this , Lv: 50 XP : 65004 / 70004 What Do i need an XML ?? or Script to show Exp Required Please Help ?? What To Make ! dxDrawText: if XP and LV then dxDrawText("XP #FFFFFF"..XP, sWidth*(670/1280), sHeight*(689/720), sWidth*(621/1280), sHeight*(715/720), tocolor(255, 255, 255, 255), (0.8/1280)*sWidth,(0.8/720)*sHeight,"bankgothic", "left", "top", false, false, true, true, false) dxDrawText("LV: #FFFFFF"..LV, sWidth*(350/1280), sHeight*(689/720), sWidth*(372/1280), sHeight*(715/720), tocolor(255, 255, 255, 255), (0.8/1280)*sWidth,(0.8/720)*sHeight,"bankgothic", "left", "top", false, false, true, true, false) end
Enargy, Posted January 29, 2015 Posted January 29, 2015 perhaps multiplying the values if a player level up in that case you would have to create a new function which case presents the calculation -- if you are interested getElementData setElementData getAccountData setAccountData
ZeyadGTX Posted January 29, 2015 Author Posted January 29, 2015 My level system works perfectly i need to add experience required to level up in my dxDrawText Help...
xeon17 Posted January 29, 2015 Posted January 29, 2015 How we can help you , when we don't know how your level system works...?
ZeyadGTX Posted January 29, 2015 Author Posted January 29, 2015 Server Side ( PART OF ) function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local killer1 = getPlayerName(killer) local noob = getPlayerName(source) local experience = math.random(25, 100) setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) if (tonumber(H) >= 100 and tonumber(H) <=400) then setElementData(killer, "LV", 1) setElementData(killer, "experience.rank", "Private") elseif (tonumber(H) >= 401 and tonumber(H) <=600) then setElementData(killer, "LV", 2) elseif (tonumber(H) >= 601 and tonumber(H) <=800) then setElementData(killer, "LV", 3) elseif (tonumber(H) >= 801 and tonumber(H) <=1000) then setElementData(killer, "LV", 4) setElementData(killer, "experience.rank", "Private First Class") elseif (tonumber(H) >= 1001 and tonumber(H) <=1200) then setElementData(killer, "LV", 5) elseif (tonumber(H) >= 1201 and tonumber(H) <=1400) then setElementData(killer, "LV", 6) elseif (tonumber(H) >= 1401 and tonumber(H) <=1600) then setElementData(killer, "LV", 7) setElementData(killer, "experience.rank", "Specialist") elseif (tonumber(H) >= 1601 and tonumber(H) <=1800) then setElementData(killer, "LV", -- s8) --> elseif (tonumber(H) >= 1801 and tonumber(H) <=2000) then setElementData(killer, "LV", 9) elseif (tonumber(H) >= 2001 and tonumber(H) <=2200) then setElementData(killer, "LV", 10) setElementData(killer, "experience.rank", "Corporal") elseif (tonumber(H) >= 2201 and tonumber(H) <=2400) then setElementData(killer, "experience.rank", "Corporal") end end end addEventHandler( "onPlayerWasted", getRootElement(), win) function onLogin (_,account) setElementData(source, "LV", getAccountData(account, "LV") or "0") setElementData(source, "EXP", getAccountData(account, "EEXP") or "0") setElementData(source, "player.key", getAccountData(account, "player.key") or "Guest") setElementData(source, "experience.rank", getAccountData(account, "experience.rank") or "Guest") end addEventHandler ("onPlayerLogin", root, onLogin) function onLogout (_,account) setElementData(source, "LV", 0) setElementData(source, "EXP", 0) setElementData(source, "reputation.point", 0) setElementData(source, "experience.rank", "Newbie") setElementData(source, "player.key", "Guest") end addEventHandler ("onPlayerLogout", root, onLogout) function saveData(thePlayer, theAccount) local theAccount = getPlayerAccount(source) if (theAccount and not isGuestAccount(theAccount)) then setAccountData (theAccount, "LV", getElementData(thePlayer, "LV")) setAccountData (theAccount, "EEXP", getElementData(thePlayer, "EXP")) setAccountData (theAccount, "experience.rank", getElementData(thePlayer, "experience.rank")) setAccountData (theAccount, "player.key", getElementData(thePlayer, "player.key")) end end addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) addEventHandler ("onPlayerLogout", root, function () saveData(source, getPlayerAccount(source)) end) --addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) addCommandHandler ( "setxp", function ( thePlayer, _, who, EXP ) if getElementData(thePlayer, "player.key") == "Zeyad" then if ( who ) then local EXP = tonumber (EXP) or 0 local ThePlayer = getPlayerFromParticalName ( who ) if ( ThePlayer ) then setElementData( ThePlayer,"EXP",EXP ) outputChatBox("Your XP has been set to "..EXP, ThePlayer, 255, 0, 0, true) else outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) end else outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) end end end ) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then
xeon17 Posted January 29, 2015 Posted January 29, 2015 Show the client part , when you draw the dx text.
-.Paradox.- Posted January 29, 2015 Posted January 29, 2015 How are you going to draw a dx text in server side?
ZeyadGTX Posted January 29, 2015 Author Posted January 29, 2015 I draw the text in my HUD local XP = getElementData(localPlayer, "EXP") or 0 local LV = getElementData(localPlayer, "LV") or 0 local rank = getElementData(localPlayer,"experience.rank") or "Newbie" if XP and LV then dxDrawText("#FF0000XP #FFFFFF"..XP, sWidth*(670/1280), sHeight*(689/720), sWidth*(621/1280), sHeight*(715/720), tocolor(255, 255, 255, 255), (0.8/1280)*sWidth,(0.8/720)*sHeight,"bankgothic", "left", "top", false, false, true, true, false) dxDrawText("#FF0000LV: #FFFFFF"..LV, sWidth*(350/1280), sHeight*(689/720), sWidth*(372/1280), sHeight*(715/720), tocolor(255, 255, 255, 255), (0.8/1280)*sWidth,(0.8/720)*sHeight,"bankgothic", "left", "top", false, false, true, true, false) end if rank then dxDrawImage(sWidth*(315/1280), sHeight*(685/720), sWidth*(32/1280), sHeight*(30/720), ":Experience/Emblems/"..rank..".png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end
John Smith Posted January 29, 2015 Posted January 29, 2015 Maybe if you actually knew something about scripting else than using other people's codes maybe then you'd know by yourself how to do these things.
ZeyadGTX Posted January 29, 2015 Author Posted January 29, 2015 why am i asking for help? 1st to learn 2nd to make a good sv
xeon17 Posted January 30, 2015 Posted January 30, 2015 Its simple, just check how many exp have the player and draw the text
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 Its simple, just check how many exp have the player and draw the text Oooh What an Example Bla bla bla
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 I want to draw Exp Required NOT EXP player HAS like EXP: 300 From 500 EXP : 300 / 500
xeon17 Posted January 30, 2015 Posted January 30, 2015 I didn't said it so clear , check how many exp the player have and draw the text how much he exp he need to get the next level. Simple. elseif (tonumber(H) >= 401 and tonumber(H) <=600) then triggerClientEvent(killer,"drawText",killer) end addEvent ( "drawText", true ) function drawText() addEventHandler ( "onClientRender", root, TextToNextLevel) end addEventHandler ( "drawText", root, drawText) function TextToNextLevel() dxDrawText() end
-.Paradox.- Posted January 30, 2015 Posted January 30, 2015 Its simple, just check how many exp have the player and draw the text Oooh What an Example Bla bla bla Stop throwing words at people who help you, It's not his mistake if you were too dumb to understand what he said.
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 ahh i need a help not to open an Conversations
xeon17 Posted January 30, 2015 Posted January 30, 2015 I already helped you , it's your problem if you're too dumb to understand. Have you even read my code?
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 I already helped you , it's your problem if you're too dumb to understand. Have you even read my code? I did but why some level systems uses XML to make Required EXP
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 I don't know , ask them why they use XML. any way no one can help me with this thanks.
Pierce Posted January 30, 2015 Posted January 30, 2015 have you considered using tables? e.g local sw,sh = guiGetScreenSize() levelUpTable = { -- required experience to level up,e.g if someone is level 1 he would need 500 xp to level up [1] = "500", [2] = "1000", [3] = "2000" } -- now draw it function levelRequired() local experience = getElementData(localPlayer,"EXP") local level = getElementData(localPlayer,"LV") dxDrawText("Level "..level.." EXP: "..experience.."/"..levelUpTable[level],sw/2,sh/2,sw,sh,tocolor(255,255,255)) end addEventHandler("onClientRender",root,levelRequired) there are better alternatives how to update level data instead of doing it onClientRender but this would work fine
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 have you considered using tables? e.g local sw,sh = guiGetScreenSize() levelUpTable = { -- required experience to level up,e.g if someone is level 1 he would need 500 xp to level up [1] = "500", [2] = "1000", [3] = "2000" } -- now draw it function levelRequired() local experience = getElementData(localPlayer,"EXP") local level = getElementData(localPlayer,"LV") dxDrawText("Level "..level.." EXP: "..experience.."/"..levelUpTable[level],sw/2,sh/2,sw,sh,tocolor(255,255,255)) end addEventHandler("onClientRender",root,levelRequired) there are better alternatives how to update level data instead of doing it onClientRender but this would work fine I made client File and Server file in my experience file both didn't work what shall i do ? local sw,sh = guiGetScreenSize() levelUpTable = { [1] = "200", [2] = "800", [3] = "1600" } function levelRequired() local XP = getElementData(localPlayer, "EXP") or 0 local LV = getElementData(localPlayer, "LV") or 0 dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV],sw/2,sh/2,sw,sh,tocolor(255,255,255)) end addEventHandler("onClientRender",root,levelRequired)
ZeyadGTX Posted January 30, 2015 Author Posted January 30, 2015 Cl.lua : 12 Attempt to concatenate Field "?" a nil value Debug Says
Pierce Posted January 30, 2015 Posted January 30, 2015 That's because script is trying to get data [0] from table which doesn't exist. I dont know if tables can have [0] as index because i haven't tried it but you could try to do it otherwise try to set default minimum level to 1 and it will work fine shortly, it's because your level is currently 0 which is not in the table
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