murilo2929 Posted October 22, 2019 Posted October 22, 2019 how can i make to clothes of CJ save when player exit of server?
Kenix Posted October 22, 2019 Posted October 22, 2019 (edited) Using setAccountData or db functions. https://wiki.multitheftauto.com/wiki/SetAccountData https://wiki.multitheftauto.com/wiki/DbQuery When you load/save https://wiki.multitheftauto.com/wiki/AddPedClothes https://wiki.multitheftauto.com/wiki/GetPedClothes Edited October 22, 2019 by Kenix
murilo2929 Posted October 23, 2019 Author Posted October 23, 2019 4 hours ago, Kenix said: Using setAccountData or db functions. https://wiki.multitheftauto.com/wiki/SetAccountData https://wiki.multitheftauto.com/wiki/DbQuery When you load/save https://wiki.multitheftauto.com/wiki/AddPedClothes https://wiki.multitheftauto.com/wiki/GetPedClothes function saveClothes() local account = getPlayerAccount(source) if ( not isGuestAccount(account) ) and ( getElementModel(source) == 0 ) then local texture = {} local model = {} for i=0, 17, 1 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 allTextures = table.concat(texture, ",") local allModels = table.concat(model, ",") outputDebugString("Clothessaver: Saved clothes") setAccountData(account, "Clothessaver:Texture", allTextures) setAccountData(account, "Clothessaver:Model", allModels) texture = {} model = {} end end addEventHandler("onPlayerQuit", getRootElement(), saveClothes) function setClothes() local account = getPlayerAccount(source) if ( not isGuestAccount(account) ) then local textureString = getAccountData(account, "Clothessaver:Texture") local modelString = getAccountData(account, "Clothessaver:Model") local textures = split(textureString, 44) local models = split(modelString, 44) setElementModel(source,0) for i=0, 17, 1 do if ( textures[i+1] ~= " " ) then addPedClothes(source, textures[i+1], models[i+1], i) end end outputChatBox("Clothes were added by clothessaver", source, 0, 255, 0) textures = {} models = {} end end addEventHandler("onPlayerLogin", getRootElement(), setClothes) i try like this and don't work
VenomOG Posted October 23, 2019 Posted October 23, 2019 function saveNewClothing(player) for type=0,17 do local texture, model = getPedClothes(player, type) setAccountData(getPlayerAccount(player),"clothes_".. type,tostring(texture) ..",".. tostring(model)) end end ---- LOGIN function loadClothes(player) skin = getElementModel(player) if tonumber(skin) == 0 then setTimer(function (source) for type=0, 17 do local info = getAccountData(account,"clothes_".. type) if info then local info = split(info, ",") if (info[1] and info[2]) then addPedClothes(source, tostring(info[1]), tostring(info[2]), type) end end end end, 2000, 1, source) end
murilo2929 Posted October 23, 2019 Author Posted October 23, 2019 8 hours ago, Network said: function saveNewClothing(player) for type=0,17 do local texture, model = getPedClothes(player, type) setAccountData(getPlayerAccount(player),"clothes_".. type,tostring(texture) ..",".. tostring(model)) end end ---- LOGIN function loadClothes(player) skin = getElementModel(player) if tonumber(skin) == 0 then setTimer(function (source) for type=0, 17 do local info = getAccountData(account,"clothes_".. type) if info then local info = split(info, ",") if (info[1] and info[2]) then addPedClothes(source, tostring(info[1]), tostring(info[2]), type) end end end end, 2000, 1, source) end 2019-10-23 09:01:08] QUIT: ADMIN_STAR left the game [Quit] [2019-10-23 09:01:09] WARNING: account\login_s.Lua:140: Bad argument @ 'getPedClothes' [Expected ped at argument 1, got string 'Quit'] [2019-10-23 09:01:09] WARNING: account\login_s.Lua:141: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'Quit'] [2019-10-23 09:01:09] WARNING: account\login_s.Lua:141: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean] [2019-10-23 09:01:15] WARNING: account\login_s.Lua:140: Bad argument @ 'getPedClothes' [Expected ped at argument 1, got string 'Quit'] [DUP x17] [2019-10-23 09:01:15] WARNING: account\login_s.Lua:141: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'Quit'] [DUP x17] [2019-10-23 09:01:15] WARNING: account\login_s.Lua:141: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean] [DUP x17] that error appear when i exit
VenomOG Posted October 23, 2019 Posted October 23, 2019 addEventHandler("onPlayerQuit",root,function() saveNewClothing(source) end) 5 hours ago, murilo2929 said: 2019-10-23 09:01:08] QUIT: ADMIN_STAR left the game [Quit] [2019-10-23 09:01:09] WARNING: account\login_s.Lua:140: Bad argument @ 'getPedClothes' [Expected ped at argument 1, got string 'Quit'] [2019-10-23 09:01:09] WARNING: account\login_s.Lua:141: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'Quit'] [2019-10-23 09:01:09] WARNING: account\login_s.Lua:141: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean] [2019-10-23 09:01:15] WARNING: account\login_s.Lua:140: Bad argument @ 'getPedClothes' [Expected ped at argument 1, got string 'Quit'] [DUP x17] [2019-10-23 09:01:15] WARNING: account\login_s.Lua:141: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'Quit'] [DUP x17] [2019-10-23 09:01:15] WARNING: account\login_s.Lua:141: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean] [DUP x17] that error appear when i exit
murilo2929 Posted October 23, 2019 Author Posted October 23, 2019 3 hours ago, Network said: addEventHandler("onPlayerQuit",root,function()saveNewClothing(source)end) [2019-10-23 18:43:17] QUIT: ADMIN_STAR left the game [Quit] [2019-10-23 18:43:17] WARNING: account\s_login.Lua:107: Bad argument @ 'getPedClothes' [Expected ped at argument 1, got nil] [2019-10-23 18:43:17] WARNING: account\s_login.Lua:108: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2019-10-23 18:43:17] WARNING: account\s_login.Lua:108: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean] [2019-10-23 18:43:17] WARNING: account\s_login.Lua:107: Bad argument @ 'getPedClothes' [Expected ped at argument 1, got nil] [DUP x17] [2019-10-23 18:43:17] WARNING: account\s_login.Lua:108: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [DUP x17] [2019-10-23 18:43:17] WARNING: account\s_login.Lua:108: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean] [DUP x17] [2019-10-23 18:43:17] ERROR: account\s_login.Lua:139: attempt to call global 'saveNewClothing' (a nil value)
murilo2929 Posted October 24, 2019 Author Posted October 24, 2019 2 hours ago, Network said: Mate are u logged in? for sure
VenomOG Posted October 24, 2019 Posted October 24, 2019 9 hours ago, murilo2929 said: for sure send me account script in private
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