Jump to content

Races +1 (client)


[DMC]

Recommended Posts

Posted
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 :|

Posted

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 
  

Posted

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

Posted
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..

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 :S

cuz i tried +1 before and then it worked but now it doesnt anymore

Posted

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..

Posted (edited)

:cry:

srry maybe u can give me those links here again and i will try to think and learn more about lua

Edited by Guest
Posted

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) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...