Norhy Posted December 27, 2012 Share Posted December 27, 2012 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
Castillo Posted December 27, 2012 Share Posted December 27, 2012 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
Norhy Posted December 27, 2012 Author Share Posted December 27, 2012 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
Castillo Posted December 27, 2012 Share Posted December 27, 2012 Then, instead of using "kills" data name, use "points". To add + 1 each time use: setElementData ( player, "points", getElementData ( player, "points" ) + 1 ) But the first argument of 'onPlayerWasted' is the totalAmmo, not a player element. Link to comment
Norhy Posted December 29, 2012 Author Share Posted December 29, 2012 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
Tete omar Posted December 29, 2012 Share Posted December 29, 2012 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
Norhy Posted December 29, 2012 Author Share Posted December 29, 2012 Coule you give me an Example? I'm a noob at this Link to comment
Castillo Posted December 29, 2012 Share Posted December 29, 2012 I think this: rank = tonumber ( getElementData ( playerElementHere, "race rank" ) ) Link to comment
Norhy Posted December 29, 2012 Author Share Posted December 29, 2012 But if i want to use this i need to get the players online or? Because if i have let's say 10 ranks and 3 players are online (10 - 3 = 7) the 7th rank will be taken as the 1st Link to comment
Castillo Posted December 29, 2012 Share Posted December 29, 2012 You just get the rank, and should be sorted by players online and position. Link to comment
Norhy Posted December 29, 2012 Author Share Posted December 29, 2012 Alright, thank you for your patience and help, i'll try to make it on my own. 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