Jump to content

onPlayerQuit


Recommended Posts

function onQuit() 
    if getElementData(source, "account:logged") then -- logged in account 
        --[[local lAccount = getElementData(source, "account:id") 
        local preparedQuery1 = "UPDATE `accounts` SET `admin_level`='".. getElementData(source, "account:admin") .."' WHERE `id`='".. lAccount .."'" 
        local Q1 = mysql:query(preparedQuery1) 
         
        if not Q1 then 
            outputDebugString("Error saving account " .. getElementData(source, "account:username"), 1) 
            return false 
        end 
        outputDebugString("Successfully saved account " .. getElementData(source, "account:username"))]] 
    end 
    if getElementData(source, "character:logged") then -- logged in a character 
        local lCharacter = getElementData(source, "character:id") 
        local x, y, z = getElementPosition(source) 
        local rz, ry, rz = getElementRotation(source) 
        local dim, int, model = getElementDimension(source), getElementInterior(source), getElementModel(source) 
        local preparedQuery2 = "UPDATE `characters` SET `x`='".. x .."', `y`='".. y .."', `z`='".. z .."', `rz`='".. rz .."', `dimension`='".. dim .."', `interior`='".. int .."', `skin`='".. model .."' WHERE `id`='".. lCharacter .."'" 
        local Q2 = mysql:query(preparedQuery2) 
         
        if not Q2 then 
            outputDebugString("Error saving character " .. getElementData(source, "character:name"), 1) 
            return false 
        end 
        mysql:free_result(Q2) 
        outputDebugString("Successfully saved character " .. getElementData(source, "character:name")) 
    end 
end 
addEventHandler("OnPlayerQuit", getRootElement(), onQuit) 

This doesn't seem to be working. It doesn't show errors in debugscript & doesn't save anything to the database. Ignore the quoted out part.

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