Markn1 Posted October 22, 2017 Share Posted October 22, 2017 (edited) Por favor ayuda No entiendo mucho. Se guarda solo cuando vas al servidor (or "logout"). ¡Si reinicia el recurso, no se guarda! local saveableData = { ["car"] = true, ["moto"] = true, ["air"] = true } function onStartorLogin (_,acc) setElementData ( source, "car", getAccountData ( acc, "car" ) or false ) setElementData ( source, "moto", getAccountData ( acc, "moto" ) or false ) setElementData ( source, "air", getAccountData ( acc, "air" ) or false ) end addEventHandler("onPlayerLogin", getRootElement(), onStartorLogin ) function onResRestrt (_,acc) setAccountData ( source, "car", getElementData ( acc, "car" ) or false ) setAccountData ( source, "moto", getElementData ( acc, "moto" ) or false ) setAccountData ( source, "air", getElementData ( acc, "air" ) or false ) end addEventHandler("onResourceStop", getRootElement(), onResRestrt ) --// addEventHandler("onResourceStart", getRootElement(), onResRestrt ) function outputChange(dataName,oldValue) if getElementType(source) == "player" then if saveableData[dataName] then setAccountData ( getPlayerAccount ( source ), dataName, getElementData ( source, dataName ) ) end end end addEventHandler("onElementDataChange",getRootElement(),outputChange) Edited October 22, 2017 by Markn1 Link to comment
alex17" Posted October 22, 2017 Share Posted October 22, 2017 function onStartorLogin (_,acc) for k, player in ipairs(getElementType("player")) do local acc = getPlayerAccount(player) if acc then setElementData ( player, "car", getAccountData ( acc, "car" ) or false ) setElementData ( player, "moto", getAccountData ( acc, "moto" ) or false ) setElementData ( player, "air", getAccountData ( acc, "air" ) or false ) end end end addEventHandler("onPlayerLogin", getRootElement(), onStartorLogin ) function onResRestrt (_,acc) for k, player in ipairs(getElementType("player")) do local acc = getPlayerAccount(player) if acc then setAccountData ( acc, "car", getElementData ( player, "car" ) or false ) setAccountData ( acc, "moto", getElementData ( player, "moto" ) or false ) setAccountData ( acc, "air", getElementData ( player, "air" ) or false ) end end end addEventHandler("onResourceStop", getRootElement(), onResRestrt ) los eventos onResourceStop y onResourceStart no tienen como argumentos a un jugador ni a una cuenta utiliza el codigo que te acabo de pasar Link to comment
Markn1 Posted October 22, 2017 Author Share Posted October 22, 2017 1 hour ago, alex17" said: function onStartorLogin (_,acc) for k, player in ipairs(getElementType("player")) do local acc = getPlayerAccount(player) if acc then setElementData ( player, "car", getAccountData ( acc, "car" ) or false ) setElementData ( player, "moto", getAccountData ( acc, "moto" ) or false ) setElementData ( player, "air", getAccountData ( acc, "air" ) or false ) end end end addEventHandler("onPlayerLogin", getRootElement(), onStartorLogin ) function onResRestrt (_,acc) for k, player in ipairs(getElementType("player")) do local acc = getPlayerAccount(player) if acc then setAccountData ( acc, "car", getElementData ( player, "car" ) or false ) setAccountData ( acc, "moto", getElementData ( player, "moto" ) or false ) setAccountData ( acc, "air", getElementData ( player, "air" ) or false ) end end end addEventHandler("onResourceStop", getRootElement(), onResRestrt ) no ( function onResRestrt ) - warning and error DEBUG: 1. bad argument @ 'getElementType' [ expected ....... at argument 1, got string 'player'] 2. ERROR: bad argument #1 to 'ipairs' (table expected, got boolean) Link to comment
alex17" Posted October 22, 2017 Share Posted October 22, 2017 12 minutes ago, Markn1 said: no ( function onResRestrt ) - warning and error DEBUG: 1. bad argument @ 'getElementType' [ expected ....... at argument 1, got string 'player'] 2. ERROR: bad argument #1 to 'ipairs' (table expected, got boolean) error mio cambia getElementType por getElementsByType 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