getPlayerName = Thirrasgo Posted March 26, 2020 Share Posted March 26, 2020 Preciso de ajuda para automatizar este sistema de Save-Clothes, preciso que ele salve as roupas na hora do player sair (ou dps q comprar) e carregar as roupas quando o player logar. function onPlayerExit(player) local account = getPlayerAccount(player) local texture = {} local model = {} for i=0, 17 do local clothesTexture, clothesModel = getPedClothes(player, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local setTextures = table.concat(texture, ",") local setModels = table.concat(model, ",") setAccountData(account, "setexture", setTextures) setAccountData(account, "setmodel", setModels) texture = {} model = {} end addCommandHandler("save", save) function load(player) local textures = {} local models = {} local account = getPlayerAccount(player) local textureLoad = getAccountData(account, "setexture") local modelLoad = getAccountData(account, "setmodel") local textures = split(textureLoad, 44) local models = split(modelLoad, 44) setElementModel(player,0) for i=0, 17 do if ( textures[i+1] ~= " " ) then addPedClothes(player, textures[i+1], models[i+1], i) end end textures = {} models = {} end addCommandHandler("load", load) Link to comment
KronoS Lettify Posted March 26, 2020 Share Posted March 26, 2020 Em vez de você utilizar Command Handlers para as funções, pode usar Event Handlers. Os eventos que podem ser úteis no seu caso, é: onPlayerLogin e onPlayerQuit 1 Link to comment
getPlayerName = Thirrasgo Posted March 26, 2020 Author Share Posted March 26, 2020 3 minutes ago, KronoS Lettify said: Em vez de você utilizar Command Handlers para as funções, pode usar Event Handlers. Os eventos que podem ser úteis no seu caso, é: onPlayerLogin e onPlayerQuit --save function onPlayerExit(player) local account = getPlayerAccount(player) local texture = {} local model = {} for i=0, 17 do local clothesTexture, clothesModel = getPedClothes(player, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local setTextures = table.concat(texture, ",") local setModels = table.concat(model, ",") setAccountData(account, "setexture", setTextures) setAccountData(account, "setmodel", setModels) texture = {} model = {} end addEventHandler("onPlayerQuit" getRootElement (), onPlayerExit ) function load(player) local textures = {} local models = {} local account = getPlayerAccount(player) local textureLoad = getAccountData(account, "setexture") local modelLoad = getAccountData(account, "setmodel") local textures = split(textureLoad, 44) local models = split(modelLoad, 44) setElementModel(player,0) for i=0, 17 do if ( textures[i+1] ~= " " ) then addPedClothes(player, textures[i+1], models[i+1], i) end end textures = {} models = {} end addCommandHandler("load", load) addEventHandler( "onPlayerLogin", getRootElement (), load ) assim? Link to comment
KronoS Lettify Posted March 27, 2020 Share Posted March 27, 2020 33 minutes ago, getPlayerName = Thirrasgo said: --save function onPlayerExit(player) local account = getPlayerAccount(player) local texture = {} local model = {} for i=0, 17 do local clothesTexture, clothesModel = getPedClothes(player, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local setTextures = table.concat(texture, ",") local setModels = table.concat(model, ",") setAccountData(account, "setexture", setTextures) setAccountData(account, "setmodel", setModels) texture = {} model = {} end addEventHandler("onPlayerQuit" getRootElement (), onPlayerExit ) function load(player) local textures = {} local models = {} local account = getPlayerAccount(player) local textureLoad = getAccountData(account, "setexture") local modelLoad = getAccountData(account, "setmodel") local textures = split(textureLoad, 44) local models = split(modelLoad, 44) setElementModel(player,0) for i=0, 17 do if ( textures[i+1] ~= " " ) then addPedClothes(player, textures[i+1], models[i+1], i) end end textures = {} models = {} end addCommandHandler("load", load) addEventHandler( "onPlayerLogin", getRootElement (), load ) assim? Não. Dá uma olhada nas páginas explicativas dos dois eventos que mencionei, na wiki do MTA. Essas páginas mostrarão como deve usar o evento. 1 Link to comment
getPlayerName = Thirrasgo Posted March 27, 2020 Author Share Posted March 27, 2020 12 minutes ago, KronoS Lettify said: Não. Dá uma olhada nas páginas explicativas dos dois eventos que mencionei, na wiki do MTA. Essas páginas mostrarão como deve usar o evento. Não faço a minima ideia de como eu possa fazer isso kkkkk Você poderia editá-lo pra mim por favor? Link to comment
Other Languages Moderators Lord Henry Posted March 27, 2020 Other Languages Moderators Share Posted March 27, 2020 Linha 3 e linha 26 estão erradas. player não é o parâmetro de função pros eventos onPlayerLogin e onPlayerQuit. E não use load como nome de função, pois essa é uma palavra reservada na linguagem Lua. 2 Link to comment
Angelo Pereira Posted March 27, 2020 Share Posted March 27, 2020 Fiz para você como ficará, diante as dicas do Lord --/> SALVAR ROUBAS AI SAIR. function save_player_quit ( ) local texture = {} local model = {} for i=0, 17 do local clothesTexture, clothesModel = getPedClothes(source, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local setTextures = table.concat(texture, ",") local setModels = table.concat(model, ",") local account = getPlayerAccount(source) setAccountData(account, "setexture", setTextures) setAccountData(account, "setmodel", setModels) texture = {} model = {} end addEventHandler("onPlayerQuit", getRootElement(), save_player_quit ) --/> CARREGAR ROUPAS AO LOGAR. function load_player_login ( ) local textures = {} local models = {} local account = getPlayerAccount(source) local textureLoad = getAccountData(account, "setexture") local modelLoad = getAccountData(account, "setmodel") if not textureLoad and not modelLoad then --/> Adicionado ! return --/> Adicionado ! end --/> Adicionado ! local textures = split(textureLoad, 44) local models = split(modelLoad, 44) setElementModel(source,0) for i=0, 17 do if ( textures[i+1] ~= " " ) then addPedClothes(source, textures[i+1], models[i+1], i) end end textures = {} models = {} end addEventHandler( "onPlayerLogin", getRootElement(), load_player_login ) 1 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