[DMC] Posted September 29, 2010 Share Posted September 29, 2010 function addStatsData() setElementData(localPlayer,"Race Loses",0) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), addStatsData) Well im using this to set in a label the amount of DM's lost But when i die it sets to 0 and when i change 0 to 5 it sets to 5 My question is how can i do +1 every time i die Link to comment
dzek (varez) Posted September 29, 2010 Share Posted September 29, 2010 omg.. its too easy to ask o_O and was asked 10000000000000 times.. make script from these ( i did not follow syntax etc, and it can have some typos) x = getElementData if not nil and not false setElementData (..., x+1) else setElementData(...,0) end Link to comment
[DMC] Posted September 29, 2010 Author Share Posted September 29, 2010 looks complicated function addStatsData() x = getElementData if not nil and not false setElementData (localPlayer,"Race Loses", x+1) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), addStatsData) i tried this Link to comment
dzek (varez) Posted September 29, 2010 Share Posted September 29, 2010 1.) dont forget about else i've written 2.) https://wiki.multitheftauto.com/wiki/GetElementData 3.) think! 4.) if x ~= nil and x ~= false then -- until you come with new question.. Link to comment
[DMC] Posted September 29, 2010 Author Share Posted September 29, 2010 1.) dont forget about else i've written2.) https://wiki.multitheftauto.com/wiki/GetElementData 3.) think! 4.) if x ~= nil and x ~= false then -- until you come with new question.. function addStatsData() setElementData(localPlayer,"Race Loses", +1) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), addStatsData) Like u did + i tried that before but it didnt work. but im sure it needs to work cuz i tried +1 before and then it worked but now it doesnt anymore Link to comment
dzek (varez) Posted September 29, 2010 Share Posted September 29, 2010 argh argh.... Should i give you link to lua tutorial and debugging tutorial? Just check other topics - every 5 messages i'm posting these links but nobody even cares to CLICK those links:/ function addStatsData() x = getElementData(localPlayer,"Race Loses") if x ~= nil and x ~= false then setElementData (localPlayer,"Race Loses", tonumber(x)+1) else setElementData (localPlayer,"Race Loses", 0) end end addEventHandler("onClientPlayerWasted", getLocalPlayer(), addStatsData) you just got to my personal blacklist of ppl not trying to think, which means i'm not interested in your topics anymore - if you care.. Link to comment
[DMC] Posted September 29, 2010 Author Share Posted September 29, 2010 (edited) srry maybe u can give me those links here again and i will try to think and learn more about lua Edited September 29, 2010 by Guest Link to comment
dzek (varez) Posted September 29, 2010 Share Posted September 29, 2010 https://wiki.multitheftauto.com/wiki/Scr ... troduction https://wiki.multitheftauto.com/wiki/Debugging general lua: http://www.lua.org/manual/5.0/manual.html general wiki (Scripting box on Main Page): https://wiki.multitheftauto.com/wiki/ Link to comment
Castillo Posted September 29, 2010 Share Posted September 29, 2010 i think this was easier, if getElementData(localPlayer,"Race Loses") then setElementData(localPlayer,"Race Loses",tonumber(getElementData(localPlayer,"Race Loses"))+1) else setElementData(localPlayer,"Race Loses",1) Link to comment
dzek (varez) Posted September 29, 2010 Share Posted September 29, 2010 same thing but looks more confusing for me (but eliminate my mistake when after first death Loses are set to 0 instead of 1) 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