NeedSumHelp Posted November 6, 2010 Posted November 6, 2010 function MoneyForWinner() local alivePlayers = getAlivePlayers() if #alivePlayers == 1 then local playername = getPlayerName( alivePlayers[1] ) local serial = getPlayerSerial(alivePlayers[1]) local Cash = executeSQLSelect( "GREENTHING", "Cash","serial = '" .. serial .. "'") Cashs = tonumber(Cash[1]["Cash"]) + 150 setElementData(alivePlayers[1] ,"data.playername",playername,true) setElementData(alivePlayers[1] ,"data.Cash",Cashs,true) executeSQLUpdate ( "GREENTHING", "Cash = '"..Cashs.."'","serial = '" .. serial .. "'") end end addEventHandler("onPlayerWasted", rootElement , MoneyForWinner) it says bad argument @ getplayerserial and getplayername This should give winner 150 rubla but w/e its not doing it and im sure everything is correct.. what i should do ?
dzek (varez) Posted November 6, 2010 Posted November 6, 2010 im not sure if you should use 1 as table index. try: if #alivePlayers == 1 then for key,val in ipairs(alivePlayers) do -- your stuff here -- val is player element end Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
NeedSumHelp Posted November 6, 2010 Author Posted November 6, 2010 for key,val in ipairs(alivePlayers) do i changed to example: local playername = getPlayerName( val[1] ) and no errors but still not working
dzek (varez) Posted November 6, 2010 Posted November 6, 2010 show full code pls Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
NeedSumHelp Posted November 6, 2010 Author Posted November 6, 2010 function MoneyForWinner() local alivePlayers = getAlivePlayers() if #alivePlayers == 1 then for key,val in ipairs(alivePlayers) do local playername = getPlayerName( val[1] ) local serial = getPlayerSerial(val[1]) local Cash = executeSQLSelect( "GREENTHING", "Cash","serial = '" .. serial .. "'") Cashs = tonumber(Cash[1]["Cash"]) + 150 setElementData(val[1] ,"data.playername",playername,true) setElementData(val[1] ,"data.Cash",Cashs,true) executeSQLUpdate ( "GREENTHING", "Cash = '"..Cashs.."'","serial = '" .. serial .. "'") end end addEventHandler("onPlayerWasted", rootElement , MoneyForWinner) Or still error.. attempt to index local 'val' (a userdata value) line local playername = getPlayerName( val[1] )
dzek (varez) Posted November 6, 2010 Posted November 6, 2010 replace val[1] with only val Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
NeedSumHelp Posted November 6, 2010 Author Posted November 6, 2010 ah right, tought it will change it for everyone but yeah u were right thanks for very very fast help.. never seen such speed in forums im serious ur the best moderator i ever seen and i dint try to rise ur ego ^^ ok again, thank you
dzek (varez) Posted November 6, 2010 Posted November 6, 2010 umm, well, thanks, being some kind of no-life makes my replies fast hope i'll get new job soon.. whatever.. glad i helped Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
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