Jump to content

SQL Data Error.


Maurize

Recommended Posts

So no errors appearing. But if i browse the database, i can´t find any table named "playerData".

Please help me and tell me what i have done wrong.

Thanks ;)

function CreateTable() 
executeSQLCreateTable( "playerData", "name STRING, x FLOAT, y FLOAT, z FLOAT, s INT" ) 
end 
addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), CreateTable ) 
  
function UpdateTable() 
local x, y, z  = getElementPosition( source ) 
local s = getElementModel( source ) 
local playerTable = executeSQLUpdate( "playerData", "name = '" .. getAccountName( getPlayerAccount( source ) ) .. "'", "x = '" .. x .. "'", "y = '" .. y .. "'", "z = '" .. z .. "'", "s = '" .. s .. "'" ) 
end 
addEventHandler( "onPlayerQuit", getRootElement(), UpdateTable ) 
  
function SelectTable() 
local playerTable = executeSQLSelect ( "playerData", "name = '" .. getAccountName( getPlayerAccount( source ) ) .. "'", "x", "y", "z", "s" ) 
setElementPosition( source, playerTable[3], playerTable[4], playerTable[5] ) 
setElementModel( source, playerTable[6] ) 
end 
addEventHandler( "onPlayerLogin", getRootElement(), SelectTable ) 

Link to comment

Both function arguments are wrong.

bool executeSQLUpdate ( string tableName, string set, [ string conditions ] ) 

3 arguments.

executeSQLUpdate should be:

executeSQLUpdate( "playerData", "name = '" .. getAccountName( getPlayerAccount( source ) ) .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', s = '" .. s .. "'" ) 

Creating the table is correct, make sure you are checking registry.db not internal.db

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