Jump to content

Last player name to db


Annas

Recommended Posts

How can i add player last name to the database

i tried this , but it's not working

  
function saveData() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    local lastname = getPlayerName(source) 
        -- Last name 
    dbExec(db, "UPDATE banking (name, lastname) VALUES(?)", account, lastname) 
end 
addEventHandler("onPlayerQuit", root, saveData) 
addEventHandler("onPlayerLogout", root, saveData) 

Sorry if it's wrong board :?

HELP ME PLEASE :roll:

Link to comment

Hey, what you have coded was totally, wrong, try that

function saveData() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    local lastname = getPlayerName(source) 
        -- Last name 
    dbExec(db, "UPDATE banking SET lastname=? WHERE name='"..tostring(account).."'LIMIT 1", lastname) 
end 
addEventHandler("onPlayerQuit", root, saveData) 
addEventHandler("onPlayerLogout", root, saveData) 

Link to comment
Hey, what you have coded was totally, wrong, try that
function saveData() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    local lastname = getPlayerName(source) 
        -- Last name 
    dbExec(db, "UPDATE banking SET lastname=? WHERE name='"..tostring(account).."'LIMIT 1", lastname) 
end 
addEventHandler("onPlayerQuit", root, saveData) 
addEventHandler("onPlayerLogout", root, saveData) 

Ah i forgot the tostring()

Btw dude, i think he has set variable account with name and not lastname

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