Jump to content

Points error


Norhy

Recommended Posts

Hey guys, i'm making a simple points system, but i'm getting an error.

function checkPoints ( player, command ) 
    local points = getElementData ( player, "kills" ) 
    outputChatBox ( "Points: " .. points, player, getRootElement(), 255, 255, 255 ) 
end 
addCommandHandler ( "points", checkPoints ) 

I get the error: " attempt to concatenate local 'points' ".

I've also tried this code:

function checkPoints ( player, command ) 
    outputChatBox ( "Points: " .. getElementData ( player, "points" ), player, getRootElement(), 255, 255, 255 ) 
end 
addCommandHandler ( "points", checkPoints ) 

But i get the error with this code too. How to solve this?

Link to comment

Must be because 'kills' is returning 'false', this should return '0' if he has no data.

function checkPoints ( player ) 
    local points = getElementData ( player, "kills" ) or 0 
    outputChatBox ( "Points: ".. points, player, 255, 255, 255 ) 
end 
addCommandHandler ( "points", checkPoints ) 

Link to comment

Thanks Castillo, you were always a great helper. However you may be confused why i use 'kills' as 'points', it's because i don't know if the system will know what 'points' data is when i use it with setElementData.

However it works now. I have also maked a system when you die you get money and 1 point, but it doesn't work :/

function deathMoney ( player ) 
    givePlayerMoney ( source, 1000 ) 
    outputChatBox ( "hi", getRootElement(), 255, 255, 255, true ) 
    setElementData ( player, "points", 1 ) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), deathMoney ) 

By the way, is it possible to add (+) the 'points'? Because using setElementData it will always set points to 1.

Thanks for you help and patience.

Link to comment

Thanks. One last question, is it possible to find out on which place the player died in race? I mean if there are 3 player connected, and he dies on the 3rd place, he'll get the lowest amount of money, on 2nd more amount of money and on first the most amount of money? If so, how?

Link to comment
Thanks. One last question, is it possible to find out on which place the player died in race? I mean if there are 3 player connected, and he dies on the 3rd place, he'll get the lowest amount of money, on 2nd more amount of money and on first the most amount of money? If so, how?

Make an increasable variable , and start to count.

Link to comment

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