WhoAmI Posted February 24, 2015 Posted February 24, 2015 Hello there, I have problem I have such a code addEventHandler ( "onPlayerQuit", root, function () if getElementData ( source, "imie" ) then uid = tonumber ( getElementData ( source, "uid" ) ) local x,y,z = getElementPosition ( source ) local cash = getPlayerMoney ( source ) local skin = getElementModel ( source ) local hp = getElementHealth ( source ) outputDebugString ( skin .. hp ) dbExec ( db, "UPDATE Postacie SET portfel = '?', x = ?, y = ?, z = ?, skin = '?', hp = '?' WHERE uid = '?'", tonumber(cash), x, y, z, tonumber(skin), hp, uid ) end end) And the 'skin' and 'hp' output '0' and it saves so in database. When I spawn again I'm dead. Is it problem in my code or it is only bug of this event?
Castillo Posted February 24, 2015 Posted February 24, 2015 You mean that both getElementModel and getElementHealth are returning the wrong values?
WhoAmI Posted February 24, 2015 Author Posted February 24, 2015 Yea, exactly. outputDebugString ( skin .. hp ) It outputs "00", but my hp is 100 and skin isn't equal to 0.
JR10 Posted February 25, 2015 Posted February 25, 2015 The health and model functions shouls return the correct values, even on quit. Make sure that no other scripts are changing them. Also, does it return the position and the money correctly?
WhoAmI Posted February 25, 2015 Author Posted February 25, 2015 Yea, It does. Everything works fine instead of this two. I'm pretty sure that other scripts don't change those values. I'm not amateur scripter and I'm really confused about this.
JR10 Posted February 25, 2015 Posted February 25, 2015 Just tested your code (without db and the check) and it did output the correct values.
WhoAmI Posted February 25, 2015 Author Posted February 25, 2015 When I'll get back to home I gonna check all other running resources. Thanks.
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