Jump to content

Help wihelp with code plz :D


novo

Recommended Posts

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

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