Jump to content

Jail save =\


Dice

Recommended Posts

addEventHandler ( "onPlayerQuit", root,  
    function() 
        if getElementData ( source, "jailed" ) == true then 
            cur_jails = xmlFindChild ( jaildata, "CurrentJails", 0 ) 
            local crooks = xmlCreateChild ( cur_jails, "Crook" ) 
            local left, x, e = getTimerDetails ( runningTimers[source][newTabPos] ) 
            xmlNodeSetAttribute ( crooks, "name", getPlayerName ( source ) ) 
            xmlNodeSetAttribute ( crooks, "serial", getPlayerSerial ( source ) ) 
            xmlNodeSetAttribute ( crooks, "TimeLeft", left ) 
            setElementData ( source, "jailed", false ) 
            killTimer ( runningTimers[source][newTabPos] ) 
            xmlSaveFile ( jaildata ) 
        end 
    end ) 
     
loadedCrooks = {} 
  
function joinData() 
    local currentJails = xmlFindChild ( jaildata, "CurrentJails", 0 ) 
    local currentCrooks = xmlNodeGetChildren ( currentJails ) 
    if currentCrooks then 
        for i, crook in ipairs ( currentCrooks ) do 
            for name, value in ipairs ( xmlNodeGetAttributes ( crook ) ) do 
                outputChatBox ( name .. " = " .. value ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerJoin", root, joinData ) 

I have this script with the jail when a player quits and they are jailed,

it creates something like this...

<Crook name="sss" serial="xxxxxxxxxxxxxxxxxxxxxxxxxxxx" TimeLeft="149935"></Crook> 
        <Crook name="avc" serial="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" TimeLeft="152974"></Crook> 
        <Crook name="sccss" serial="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" TimeLeft="111436"></Crook> 

Link to comment
it doesnt work,,, idk how to read all the crooks children and on top of that get all the attributes for them, yes i know which ones to use but idk how to set it up.

try this

function saveData(player) 
        if getElementData ( player, "jailed" ) == true then 
            cur_jails = xmlFindChild ( jaildata, "CurrentJails", 0 ) 
            local crooks = xmlCreateChild ( cur_jails, "Crook" ) 
            local left, x, e = getTimerDetails ( runningTimers[source][newTabPos] ) 
            xmlNodeSetAttribute ( crooks, "name", getPlayerName ( source ) ) 
            xmlNodeSetAttribute ( crooks, "serial", getPlayerSerial ( source ) ) 
            xmlNodeSetAttribute ( crooks, "TimeLeft", left ) 
            setElementData ( player, "jailed", false ) 
            killTimer ( runningTimers[source][newTabPos] ) 
            xmlSaveFile ( jaildata ) 
        end 
    end 
addEventHandler ( "onPlayerQuit", root, saveData) 
    
loadedCrooks = {} 
  
function joinData() 
    local currentJails = xmlFindChild ( jaildata, "CurrentJails", 0 ) 
    local currentCrooks = xmlNodeGetChildren ( currentJails ) 
    if currentCrooks then 
        for i, crook in ipairs ( currentCrooks ) do 
            for name, value in ipairs ( xmlNodeGetAttributes ( crook ) ) do 
                outputChatBox ( name .. " = " .. value ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerJoin", root, joinData ) 

I sleep xD..

Link to comment
oh, i'm not getting any errors if thats what u mean, but it is defined, on the top of my script.

You should define it each time an player quit/join to the server, because in the end of the event, you closing it with xmlSaveFile.

@ZL|LuCaS, onPlayerQuit don't have player parameter.

Link to comment
oh, i'm not getting any errors if thats what u mean, but it is defined, on the top of my script.

You should define it each time an player quit/join to the server, because in the end of the event, you closing it with xmlSaveFile.

@ZL|LuCaS, onPlayerQuit don't have player parameter.

lol. and truth and I'm sleepy bye..

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