maarten123 Posted May 21, 2010 Share Posted May 21, 2010 hi all, i wanna make a script that you get Race points but it's not work can you help me? Greeting Maarten123 Script: function addPoints(playerSource) local playeraccount = getPlayerAccount ( source ) local points = getPlayerAccount ( source, "Points" ) + 3 setAccountData ( playeraccount, "Points", points ) outputChatBox("will it work?", player, 222, 0, 0, true) end addCommandHandler("add",addPoints) Link to comment
Dark Dragon Posted May 21, 2010 Share Posted May 21, 2010 for command handlers the player is not source but the first parameter of the function (in your case playerSource), if you however change it to use the appropriate event source will be fine. to make it work with what you currently have replace all "source"s with "playerSource" Link to comment
maarten123 Posted May 21, 2010 Author Share Posted May 21, 2010 function addPoints(playerSource) local playeraccount = getPlayerAccount ( playerSource ) local points = getPlayerAccount ( playerSource, "Points" ) + 3 setAccountData ( playeraccount, "Points", points ) outputChatBox("will it work?", playerSource, 222, 0, 0, true) end addCommandHandler("add",addPoints) but didn't work Link to comment
Dark Dragon Posted May 21, 2010 Share Posted May 21, 2010 did you just forget to copy it or did you remove the end of the function and the command handler? line 3 should be getAccountData (the player account should go there), you maybe need to use tonumber to turn the string which getAccountDataReturns to a number Link to comment
maarten123 Posted May 21, 2010 Author Share Posted May 21, 2010 the warning: [23:45:20] ERROR: ...server11580/mods/deathmatch/resources/stats/test.lua:3: attempt to perform arithmetic on a userdata value Link to comment
maarten123 Posted May 21, 2010 Author Share Posted May 21, 2010 did you just forget to copy it or did you remove the end of the function and the command handler? line 3 should be getAccountData (the player account should go there), you maybe need to use tonumber to turn the string which getAccountDataReturns to a number is this wat you mean?Not work i don't understand function addPoints(playerSource) local playeraccount = getPlayerAccount ( playerSource ) local points = getPlayerAccount ( playerSource, "Points" ) + 3 setAccountData ( playeraccount, "Points", tonumber(points) ) outputChatBox("work?", playerSource, 222, 0, 0, true) end addCommandHandler("add",addPoints) Link to comment
Dark Dragon Posted May 23, 2010 Share Posted May 23, 2010 still line 3, make it getAccountData and put the player account there instead of the player, and no you need to use tonumber on getAccountData, because getAccountData returns a string: https://wiki.multitheftauto.com/wiki/GetAccountData 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