Jump to content

executeSQLSelect returns nil values


Recommended Posts

Didn't change anything :\

Do you think it has something to do with the way I have written line 17 or 18?

    executeSQLUpdate ( "playerStats", "playerHealth = 'fetchPlayerHealth', playerArmor = 'fetchPlayerArmor', playerMoney = 'fetchPlayerMoney', "playerName = '" .. sourcename .. "'" ) 
        result = executeSQLSelect ( "playerStats", "playerHealth, playerArmor, playerMoney, playerName" ) 
  
 

Link to comment
function playerJoin() 
    executeSQLCreateTable ( "playerStats", "playerHealth, playerArmor, playerMoney, playerName TEXT" ) 
end 
addEventHandler("onResourceStart", getRootElement(), playerJoin) 
  
function addInfoToSQL() 
    fetchPlayerHealth = getElementHealth(source) 
    fetchPlayerArmor = getPedArmor(source) 
    fetchPlayerMoney = getPlayerMoney(source) 
    sourcename = getPlayerName ( source ) 
    result = executeSQLSelect ( "playerStats", "playerName", "playerName = '" .. sourcename .. "'" ) 
    if ( type( result ) == "table" and #result == 0 ) or not result then 
        outputChatBox ( "First Visit " .. sourcename .. "!", source ) 
        executeSQLInsert ( "playerStats", "'none', 'none', 'none', '" .. tostring(sourcename) .."'" ) 
    else 
        outputChatBox ( "Welcome back " .. sourcename .. "!", source ) 
        executeSQLUpdate ( "PlayerStats", "playerHealth = '".. tonumber(fetchPlayerHealth) .."', playerArmor = '".. tonumber(fetchPlayerArmor) .."', playerMoney = '".. tonumber(fetchPlayerMoney) .."'","playerName = '" .. tostring(sourcename) .. "'") 
        result = executeSQLSelect ( "playerStats", "playerHealth, playerArmor, playerMoney, playerName" ) 
        outputChatBox("Your Health: " .. result[1].playerHealth) 
        outputChatBox("Your Armor: " .. result[1].playerArmor) 
        outputChatBox("Your Money: " .. result[1].playerMoney) 
        outputChatBox("Your Name: " .. result[1].playerName) 
    end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), addInfoToSQL) 

Maybe a bit too late, but would help someone else ;).

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