djharbi2 Posted August 12, 2016 Posted August 12, 2016 This is clothes saver. 37 is Warnig 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") or "" local modelString = getAccountData(account, "Clothessaver:Model") or "" 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("", source, 0, 255, 0) textures = {} models = {} end end addEventHandler("onPlayerLogin", getRootElement(), setClothes)
kashtesov Posted August 12, 2016 Posted August 12, 2016 Maybe it not best solution, but try use toJSON(). try add: if textures[i+1] and models[i+1] then --todo end maybe your tables just incorrect
djharbi2 Posted August 12, 2016 Author Posted August 12, 2016 Maybe it not best solution, but try use toJSON().try add: if textures[i+1] and models[i+1] then --todo end maybe your tables just incorrect Error
!#NssoR_) Posted August 12, 2016 Posted August 12, 2016 كل الأكواد الي بالموضوع عبارة عن هريس addEventHandler("onPlayerQuit",root, function() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local cTable = {} for i = 0, 17 do local texture, model = getPedClothes(source, i) if texture and model then table.insert(cTable, {texture, model, i}) end end setAccountData(account, "Clothes", toJSON(cTable)) end end) addEventHandler("onPlayerLogin", root, function() if not isPedDead(source) then givePlayerClothes() else addEventHandler("onPlayerSpawn", source, givePlayerClothes) end end) function givePlayerClothes() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local data = getAccountData(account, "Clothes") if (data) then local cTable = fromJSON(data) if cTable and type(cTable) == "table" then local cSkin = getElementModel(source) setElementModel(source, 0) for _, value in ipairs(cTable) do addPedClothes(source, value[1], value[2], value[3]) end setElementModel(source, cSkin) end end end if eventName == "onPlayerSpawn" then removeEventHandler("onPlayerSpawn", source, givePlayerClothes) end end
djharbi2 Posted August 12, 2016 Author Posted August 12, 2016 كل الأكواد الي بالموضوع عبارة عن هريس addEventHandler("onPlayerQuit",root, function() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local cTable = {} for i = 0, 17 do local texture, model = getPedClothes(source, i) if texture and model then table.insert(cTable, {texture, model, i}) end end setAccountData(account, "Clothes", toJSON(cTable)) end end) addEventHandler("onPlayerLogin", root, function() if not isPedDead(source) then givePlayerClothes() else addEventHandler("onPlayerSpawn", source, givePlayerClothes) end end) function givePlayerClothes() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local data = getAccountData(account, "Clothes") if (data) then local cTable = fromJSON(data) if cTable and type(cTable) == "table" then local cSkin = getElementModel(source) setElementModel(source, 0) for _, value in ipairs(cTable) do addPedClothes(source, value[1], value[2], value[3]) end setElementModel(source, cSkin) end end end if eventName == "onPlayerSpawn" then removeEventHandler("onPlayerSpawn", source, givePlayerClothes) end end Thank You
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