Jump to content

executeSQL problem


seal

Recommended Posts

I'll like to save players' characters name into an sql table, but i got this debug message:

attemp to call global: executesqlquery(a nil value)

pls help me what do i wrong

function createLoginWindow(thePlayer) 
  showCursor(true, true) 
  wdwLogin = guiCreateWindow(0.425, 0.425,0.15, 0.15, "Type your character's name", true) 
  cname = guiCreateEdit(0.25, 0.2, 0.5, 0.15, "", true, wdwLogin) 
  guiEditSetMaxLength(cname, 15) 
  btnLogin = guiCreateButton(0.375, 0.7, 0.25, 0.2, "Save", true, wdwLogin) 
  addEventHandler ( "onClientGUIClick", btnLogin, saveNick, false ) 
  outputDebugString( "leves" ) 
end 
  
addCommandHandler("leves", createLoginWindow) 
  
function saveNick(button) 
  if button == "left" then 
    local nickname = guiGetText ( cname ) 
    executeSQLQuery("INSERT INTO accounts(character) VALUES(?)", cname ) 
    guiSetVisible(wdwLogin, false) 
    destroyElement ( wdwLogin ) 
    showCursor (  false ) 
  end 
end 

Link to comment

executeSQLQuery is server sided only, and I'm even questioning if you really can script.

Client

function createLoginWindow(thePlayer) 
  showCursor(true, true) 
  wdwLogin = guiCreateWindow(0.425, 0.425,0.15, 0.15, "Type your character's name", true) 
  cname = guiCreateEdit(0.25, 0.2, 0.5, 0.15, "", true, wdwLogin) 
  guiEditSetMaxLength(cname, 15) 
  btnLogin = guiCreateButton(0.375, 0.7, 0.25, 0.2, "Save", true, wdwLogin) 
  addEventHandler ( "onClientGUIClick", btnLogin, saveNick, false ) 
  outputDebugString( "leves" ) 
end 
  
addCommandHandler("leves", createLoginWindow) 
  
function saveNick(button) 
  if button == "left" then 
    local nickname = guiGetText ( cname ) 
    triggerServerEvent("saveCharacter", nickname) 
    guiSetVisible(wdwLogin, false) 
    destroyElement ( wdwLogin ) 
    showCursor (  false ) 
  end 
end 

Server

addEvent("saveCharacter", true) 
addEventHandler("saveCharacter", root, 
function(nickname) 
executeSQLQuery("INSERT INTO accounts(character) VALUES(?)", nickname) 
end 
) 

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