seal Posted November 22, 2013 Share Posted November 22, 2013 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
iPrestege Posted November 22, 2013 Share Posted November 22, 2013 Because the sql function undefined in the client side . Link to comment
Baseplate Posted November 22, 2013 Share Posted November 22, 2013 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
TAPL Posted November 22, 2013 Share Posted November 22, 2013 triggerServerEvent("saveCharacter", nickname) ^^ triggerServerEvent("saveCharacter", localPlayer, nickname) Link to comment
Baseplate Posted November 22, 2013 Share Posted November 22, 2013 OOPS! Sorry lol, my mind isn't working correctly these days. Link to comment
seal Posted November 23, 2013 Author Share Posted November 23, 2013 thanks, i forgot it and now it is corrected thanks 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