unknooooown Posted July 23, 2011 Share Posted July 23, 2011 Hi. Got a small problem here, its probably not a big deal, but I hope you can help me with it When I run the script I get a nil value in return on line 19. Cant figure out why. Script: http://pastebin.com/MwEU2Mcf Thanks. Link to comment
SDK Posted July 23, 2011 Share Posted July 23, 2011 Look at the example: https://wiki.multitheftauto.com/wiki/ExecuteSQLSelect You need to use result[1].playerHealth or result[1]["playerHealth"], not a number. Link to comment
unknooooown Posted July 23, 2011 Author Share Posted July 23, 2011 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
SDK Posted July 23, 2011 Share Posted July 23, 2011 Hm, probably. Try this, I changed your line 17 and a small error on line 14 http://pastebin.com/SbB93gzp Link to comment
unknooooown Posted July 23, 2011 Author Share Posted July 23, 2011 Hm, probably. Try this, I changed your line 17 and a small error on line 14http://pastebin.com/SbB93gzp Thank you for the try. Still returns a nil value and gives me a bad argument @ executeSQLUpdate. Link to comment
unknooooown Posted July 23, 2011 Author Share Posted July 23, 2011 Still looking for a solution Link to comment
Castillo Posted July 23, 2011 Share Posted July 23, 2011 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
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