xScatta Posted September 22, 2013 Posted September 22, 2013 Hey guys code here problem below. savestore = {} function ssavequit() k = getPlayerSerial(source) savestore[k] = getAllElementData(source) end function ssavejoin() serial = getPlayerSerial(source) if serial==k then setAllElementData(source,savestore[k]) end end addEventHandler("onPlayerQuit",getRootElement(),ssavequit) addEventHandler("onPlayerJoin",getRootElement(),ssavejoin) function setAllElementData(element, data) for key, value in pairs(data) do setElementData(element, key, value) end end so i want to save player data to serial at quit and when player join with his serial he gets his data help fast please . It's fine to celebrate success but it is more important to heed the lessons of failure.
xXMADEXx Posted September 22, 2013 Posted September 22, 2013 Try this: ((Not Tested)) savestore = {} function ssavequit() savestore[getPlayerSerial(source)] = getAllElementData(source) end function ssavejoin() local serial = getPlayerSerial ( source ) if ( savestore[serial] ) then for index, variable in ipairs ( savestore[serial] ) do setElementData ( source, index, variable ) end end end addEventHandler("onPlayerQuit",getRootElement(),ssavequit) addEventHandler("onPlayerJoin",getRootElement(),ssavejoin) The Ultimate Lua Tutorial! | MTA PHP SDK
xScatta Posted September 22, 2013 Author Posted September 22, 2013 Not working on join dont giving data. It's fine to celebrate success but it is more important to heed the lessons of failure.
xScatta Posted September 22, 2013 Author Posted September 22, 2013 *BUMP* It's fine to celebrate success but it is more important to heed the lessons of failure.
xScatta Posted September 23, 2013 Author Posted September 23, 2013 Please write me it because i dont know which one. It's fine to celebrate success but it is more important to heed the lessons of failure.
xScatta Posted September 23, 2013 Author Posted September 23, 2013 Nope dont works. i dont have my element data. It's fine to celebrate success but it is more important to heed the lessons of failure.
Castillo Posted September 23, 2013 Posted September 23, 2013 Show us how you did it now. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
.:HyPeX:. Posted September 24, 2013 Posted September 24, 2013 You could try saving data to a XML, i dont think there's a "Cloud space" for the Serial data where to save that.. Anyways try doing separate funcions for join and quit, that could make it work easier. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
xScatta Posted September 24, 2013 Author Posted September 24, 2013 @Solidsnake14 hey i was writing like that now. savestore = {} function ssavequit() savestore[getPlayerSerial(source)] = getAllElementData(source) end function ssavejoin() local serial = getPlayerSerial ( source ) if ( savestore[serial] ) then for index, variable in pairs ( savestore[serial] ) do setElementData ( source, index, variable ) end end end addEventHandler("onPlayerQuit",getRootElement(),ssavequit) addEventHandler("onPlayerJoin",getRootElement(),ssavejoin) It's fine to celebrate success but it is more important to heed the lessons of failure.
3NAD Posted September 24, 2013 Posted September 24, 2013 I think the 'store table' will lost after restart the resource.
xScatta Posted September 24, 2013 Author Posted September 24, 2013 I know that i just want to work even if when the data will be reset at restart! It's fine to celebrate success but it is more important to heed the lessons of failure.
TAPL Posted September 24, 2013 Posted September 24, 2013 You sure you have it server side on the meta? Because from what i see the code is impossible to not working.
xScatta Posted September 24, 2013 Author Posted September 24, 2013 yes its server side.! It's fine to celebrate success but it is more important to heed the lessons of failure.
TAPL Posted September 24, 2013 Posted September 24, 2013 Try this and see what does it out put. savestore = {} function ssavequit() savestore[getPlayerSerial(source)] = getAllElementData(source) end function ssavejoin() local serial = getPlayerSerial ( source ) if ( savestore[serial] ) then for index, variable in pairs ( savestore[serial] ) do setElementData ( source, index, variable ) outputChatBox(tostring(index)..": "..variable, source) end end end addEventHandler("onPlayerQuit",getRootElement(),ssavequit) addEventHandler("onPlayerJoin",getRootElement(),ssavejoin)
xScatta Posted September 24, 2013 Author Posted September 24, 2013 *BUMP* It's fine to celebrate success but it is more important to heed the lessons of failure.
xScatta Posted September 24, 2013 Author Posted September 24, 2013 nothing happens with your code. TAPL. It's fine to celebrate success but it is more important to heed the lessons of failure.
TAPL Posted September 24, 2013 Posted September 24, 2013 nothing happens with your code. TAPL. Then you never ever have set an element data.
3NAD Posted September 24, 2013 Posted September 24, 2013 savestore = {} function ssavequit ( ) local serial = getPlayerSerial ( source ) savestore[serial] = { }; for i, v in pairs ( getAllElementData(source) ) do table.insert ( savestore[serial], { key=i, value=v } ) end end function ssavejoin ( ) local serial = getPlayerSerial ( source ) if savestore[serial] then for i, v in ipairs ( savestore[serial] ) do setElementData ( source, v.key, v.value ) end end end addEventHandler("onPlayerQuit",getRootElement(),ssavequit) addEventHandler("onPlayerJoin",getRootElement(),ssavejoin)
xScatta Posted September 24, 2013 Author Posted September 24, 2013 still the same. It's fine to celebrate success but it is more important to heed the lessons of failure.
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