stefutz101 Posted August 27, 2015 Share Posted August 27, 2015 Hi i want to make a lvl-script on DayZ Mta , and i want to make on screen to show you current exp / exp to lvl up . But how i cant make go GetAccountData on client side ? The experience is saved in account data on server-side so i need a function to get "exp" frome server-side . Help , please ? Please :( Link to comment
Olle Risk Posted August 27, 2015 Share Posted August 27, 2015 triggerServerEvent triggerClientEvent It's actually not that hard, you'll just call the server with the relevant arguments then let it pass them back to the client. Link to comment
Overkillz Posted August 27, 2015 Share Posted August 27, 2015 Maybe you want to draw the Level, then you can use setElementData getElementData Link to comment
Mann56 Posted August 28, 2015 Share Posted August 28, 2015 (edited) As Overkillz and Olle Risk said, for an exp system, you can use setElementData getElementData and then save the data using getAccountData setAccountData Edited August 28, 2015 by Guest Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 setElementData can already sync the data between server-side and client-side. Link to comment
Mann56 Posted August 28, 2015 Share Posted August 28, 2015 setElementData can already sync the data between server-side and client-side. Oh yeah, my bad, i'll remove the triggerServerEvent. Link to comment
stefutz101 Posted August 28, 2015 Author Share Posted August 28, 2015 I already try with getElementData but it display 0 . http://iceimg.net/images/2015/08/28/mta ... -49-28.png With getAccountData i try too , but i have error : attempting to concatenate a nil value . Client-Side local thePlayer= getLocalPlayer() local currentexp = GetAccontData(thePlayer,"exp") I looked in client function on wiki and getAccountData isn't , so i think is only server-side . I will try with triggerServerEvent . It must be something like this ? : triggerServerEvent("onZombieGetsKilled" , thePlayer , "exp" ). It's good ? Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 No it's not. triggerServerEvent('onZombieGetsKilled', root, currentexp) You can also use setElementData. Link to comment
stefutz101 Posted August 28, 2015 Author Share Posted August 28, 2015 local thePlayer = getLocalPlayer() addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() triggerServerEvent(thePlayer,'onZombieGetsKilled',root, currentexp) local currentlvl = getElementData(thePlayer, "lvl") or 1 dxDrawText(currentexp.."", 600, 104, 688, 128, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "left", "top") dxDrawText("/", 625, 104, 688, 128, tocolor(30, 247, 7, 255), 0.50, "bankgothic", "left", "top") dxDrawText(""..levelExp[currentlvl], 650,104,796,123, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "left", "top") end This is Client-side , and btw i have defined levelExp . It work but for lvlExp[currentlvl] but now dont display nothing . Ps : SetElementData ? You want to say GetElementData ? Help , please Link to comment
stefutz101 Posted August 28, 2015 Author Share Posted August 28, 2015 Help , please ? Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 It's messed up. Why are you triggering the event from the server in the first place. (sorry for not pointing this out in the first reply) You can just use setElementData server-side and getElementData client-side. While this is not the best approach, performance wise, it still the easiest one. Link to comment
stefutz101 Posted August 28, 2015 Author Share Posted August 28, 2015 I do it but i have a problem , if player leave server when player he have lvl 0. And 0 exp function login(source) setElementData(source, "lvl", getElementData(source,"lvl")) setElementData(source, "exp", getElementData(source,"exp")) end addEventHandler("onPlayerLogin", getRootElement(),login) function login(source) local currentexp = getElementData(source, "exp") or 0 local currentlvl = getElementData(source, "lvl") or 1 setElementData(source, "lvl", tonumber(currentlvl)) setElementData(source, "exp", tonumber(currentexp)) end addEventHandler("onPlayerQuit", getRootElement(),login) Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 Element data are session based, when the player leaves the server it's reset. You need setAccountData to actually save the data. On login you load the data using getAccountData, then you set it as element data for the player. On quit/logout you save it with setAccountData. Link to comment
stefutz101 Posted August 28, 2015 Author Share Posted August 28, 2015 Solved , ty But i have an bug : Example : if i have EXP : 95 / 100 and i kill a zombie and toad ( local toad= math.random(10, 15) and for example toad is 10 i will have 105/100 exp but at next zombie killed i will make lvl up and 5 / 115 . I can fix this ? It's not important bug but i ask if i can solve it. Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 if (exp + toad > 100) then exp = 100 end Link to comment
stefutz101 Posted August 28, 2015 Author Share Posted August 28, 2015 I want to say , the Exp : y / x when you kill a zombie it calculate at you next zombie you current exp . Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 I don't understand. What I posted should solve your problem. 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