novo Posted December 8, 2011 Share Posted December 8, 2011 Hi all. I need help with this code: function DestructionMoney2() local alivePlayers = getAlivePlayers() if info == "Destruction derby" then if #alivePlayers == 1 then local playername = getPlayerName(alivePlayers[1]) local serial = getPlayerSerial(alivePlayers[1]) local oldData = executeSQLSelect( "RaceStats", "RaceWins","serial = '" .. serial .. "'") givePlayerMoney(alivePlayers[1], 1200) local oldData = executeSQLSelect( "RaceStats", "RaceWins","serial = '" .. serial .. "'") newData = tonumber(oldData[1]["RaceWins"]) + 1 setElementData(alivePlayers[1],"Points",tonumber(getElementData(alivePlayers[1],"Points"))+5) setElementData(alivePlayers[1],"Race Wins",tonumber(getElementData(alivePlayers[1],"Race Wins"))+1) executeSQLUpdate ( "RaceStats", "RaceWins = '"..newData.."'","serial = '" .. serial .. "'") outputChatBox(getPlayerName ( alivePlayers[1] ) .. " has won $1200 for be the last player alive!",rootElement,0,255,0) end end end What's wrong on that code ? It gives you money when you're the last alive and it updates your data. Please help me. Bye <3 Link to comment
Kenix Posted December 8, 2011 Share Posted December 8, 2011 What the problem ? /debugscript 3 ? Link to comment
novo Posted December 8, 2011 Author Share Posted December 8, 2011 Nothing on debugscript 3. When i'm the last alive player, i don't get money. That happens. Link to comment
Evil-Cod3r Posted December 8, 2011 Share Posted December 8, 2011 for your info its SQL did you Make SQL? Link to comment
Kenix Posted December 8, 2011 Share Posted December 8, 2011 (edited) Try and say what debug write function DestructionMoney2() local alivePlayers = getAlivePlayers( ) if info == "Destruction derby" then if #alivePlayers ~= 0 then local selectPlayer = alivePlayers[1] if selectPlayer then local playername = getPlayerName ( selectPlayer ) local serial = getPlayerSerial( selectPlayer ) givePlayerMoney( selectPlayer, 1200) local oldData = executeSQLSelect( "RaceStats", "RaceWins","serial = '" .. serial .. "'") if oldData and #oldData ~= 0 then local newData = tonumber( oldData[1]["RaceWins"] ) + 1 setElementData( selectPlayer,"Points",tonumber( getElementData( selectPlayer,"Points" ) ) +5 ) setElementData( selectPlayer,"Race Wins",tonumber( getElementData( selectPlayer,"Race Wins") ) +1 ) local update = executeSQLUpdate ( "RaceStats", "RaceWins = '"..newData.."'","serial = '" .. serial .. "'" ) outputChatBox( getPlayerName ( selectPlayer ) .. " has won $1200 for be the last player alive!",root,0,255,0 ) if not update then error( "can't update" ) end else local insert = executeSQLInsert ( "RaceStats", "'0','none'" ) if not insert then error( "can't insert" ) end end else error( "not selected player" ) end else error( "not alive players" ) end end end p.s update code Edited December 8, 2011 by Guest Link to comment
Evil-Cod3r Posted December 8, 2011 Share Posted December 8, 2011 Kenix mybe he think its like any resource run it and work its SQL He Have To install SQL Link to comment
novo Posted December 8, 2011 Author Share Posted December 8, 2011 It's working Kenix, thank you <3. Evil-Cod3r, i have SQL installed on server. Bye <3 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