Dice Posted April 5, 2013 Share Posted April 5, 2013 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
Dice Posted April 5, 2013 Author Share Posted April 5, 2013 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. Link to comment
Dice Posted April 5, 2013 Author Share Posted April 5, 2013 oh, i'm not getting any errors if thats what u mean, but it is defined, on the top of my script. Link to comment
ZL|LuCaS Posted April 5, 2013 Share Posted April 5, 2013 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 .. Link to comment
TAPL Posted April 5, 2013 Share Posted April 5, 2013 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
ZL|LuCaS Posted April 5, 2013 Share Posted April 5, 2013 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
Dice Posted April 5, 2013 Author Share Posted April 5, 2013 yes, but I never unload it, unless the resource stops, and if it starts it loads it. all its doing is saving it Link to comment
xXMADEXx Posted April 5, 2013 Share Posted April 5, 2013 Make sure the XML is on server side, otherwise the client can just edit his/her jail time. I recommend using MySQL or SQL, because XML can cause server lag, if the file contains to much data. Link to comment
Dice Posted April 5, 2013 Author Share Posted April 5, 2013 well, it is only for the people who quit once they got jailed, I dont think the number will be too high. 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