Jump to content

Clothes save , help


Annas

Recommended Posts

Posted

.. idk if it hard or not , but SCRIPTERS can make it ..

i need to SAVE CLOTHES of CJ

i one a SAVE SYSTEM FOR IT

but when i change the skin to any number (not 0=CJ)

and reconnect , + back to CJ skin , clothes will not still saved :(

Help me with CLOTHES SAVE ..

i wish you understand ..

IF YOU NEED THE SCRIPT THAT'S I USED :

clothes saver (saveclothes)

https://community.multitheftauto.com/ind ... ls&id=1868

Posted
Try it by yourself and we will help you .

tryed

--[[ 
original script by iAnnAs (iannas ben ahmed) 
--]] 
  
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) 
        for i=0, 17, 1 do 
            if ( textures[i+1] ~= " " ) then 
                addPedClothes(source, textures[i+1], models[i+1], i) 
            end 
        end 
        exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
        textures = {} 
        models = {} 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setClothes) 
  

Posted
you didn't, show me your try

as what i said mr.Walid , it's working , clothes saved

but .. when i change it to any other Skin ID + reconnect and back the skin to CJ skin , (CLOTHES is setted back to 0)

Posted

You need to use removePedClothes on player login.

Try this

-- Save 
addEventHandler ( "onPlayerQuit", root, function ( ) 
    local account = getPlayerAccount ( source ) 
    if ( isGuestAccount( account ) ) then return end 
    local clothes = { } 
    for i=0, 17 do 
        clothes[i] = { getPedClothes ( source, i ) } 
    end 
    clothes = toJSON ( clothes ) 
    setAccountData ( account, "Clothes", clothes ) 
  
end ) 
  
-- Load  
addEventHandler ( "onPlayerLogin", root, function ( _, account ) 
    local clothes = getAccountData ( account, "Clothes" ) 
    if not clothes then return end 
    removeAllPedClothes(source) 
    for i, v in pairs ( fromJSON ( clothes ) ) do 
        local text, id = unpack ( v ) 
        if text then  
        addPedClothes ( source, text, id, i ) 
        end  
    end 
end ) 
  
-- Remove all  
function removeAllPedClothes(thePed) 
    for i=0, 17 do 
        removePedClothes(thePed, i) 
    end 
    return true 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

not work ..

1-i add this LUA in SERVER SIDE

2-i get clothes

3-reconnect

4-clothes saved (thx)

5-i changed the skin id to 230

6-reconnect

7-back the CJ skin

(not saved , the CJ didn't have any clothes)

HELP pls .

Posted
not work ..

1-i add this LUA in SERVER SIDE

2-i get clothes

3-reconnect

4-clothes saved (thx)

5-i changed the skin id to 230

6-reconnect

7-back the CJ skin

(not saved , the CJ didn't have any clothes)

HELP pls .

show me full code

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

So .. MY CODE :

--[[ 
original script by iAnnAs (iannas ben ahmed) 
--]] 
  
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) 
        for i=0, 17, 1 do 
            if ( textures[i+1] ~= " " ) then 
                addPedClothes(source, textures[i+1], models[i+1], i) 
            end 
        end 
        exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
        textures = {} 
        models = {} 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setClothes) 
  
function loadClothes(player) 
    local account = getPlayerAccount(player) 
    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) 
        for i=0, 17, 1 do 
            if ( textures[i+1] ~= " " ) then 
                addPedClothes(player, textures[i+1], models[i+1], i) 
            end 
        end 
        exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
        textures = {} 
        models = {} 
    else 
        outputChatBox("Please login!", player, 255, 0, 0) 
    end 
end 
addCommandHandler("loadClothes", loadClothes) 
  
function saveClothes(player) 
    local account = getPlayerAccount(player) 
    if ( not isGuestAccount(account) ) then 
        if ( getElementModel(player) == 0 ) then 
            local texture = {} 
            local model = {} 
            for i=0, 17, 1 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 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 = {} 
        else 
            exports.CSTtexts:sendMessage("Your skin must be skin 0 (CJ Skin)", 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Please login!", player, 255, 0, 0) 
    end 
end 
addCommandHandler("saveClothes", saveClothes) 

Posted
--[[ 
original script by iAnnAs (iannas ben ahmed) 
--]] 
  
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 
        if ( getElementModel(player) == 0 ) then 
            local textureString = getAccountData(account, "Clothessaver:Texture") 
            local modelString = getAccountData(account, "Clothessaver:Model") 
            local textures = split(textureString, 44) 
            local models = split(modelString, 44) 
            for i=0, 17, 1 do 
                if ( textures[i+1] ~= " " ) then 
                    addPedClothes(source, textures[i+1], models[i+1], i) 
                end 
            end 
            exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
            textures = {} 
            models = {} 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setClothes) 
  
function loadClothes(player) 
    local account = getPlayerAccount(player) 
    if ( not isGuestAccount(account) ) then 
        if ( getElementModel(player) == 0 ) then 
            local textureString = getAccountData(account, "Clothessaver:Texture") 
            local modelString = getAccountData(account, "Clothessaver:Model") 
            local textures = split(textureString, 44) 
            local models = split(modelString, 44) 
            for i=0, 17, 1 do 
                if ( textures[i+1] ~= " " ) then 
                    addPedClothes(player, textures[i+1], models[i+1], i) 
                end 
            end 
            exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
            textures = {} 
            models = {} 
        else 
            exports.CSTtexts:sendMessage("Your skin must be skin 0 (CJ Skin)", 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Please login!", player, 255, 0, 0) 
    end 
end 
addCommandHandler("loadClothes", loadClothes) 
  
function saveClothes(player) 
    local account = getPlayerAccount(player) 
    if ( not isGuestAccount(account) ) then 
        if ( getElementModel(player) == 0 ) then 
            local texture = {} 
            local model = {} 
            for i=0, 17, 1 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 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 = {} 
        else 
            exports.CSTtexts:sendMessage("Your skin must be skin 0 (CJ Skin)", 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Please login!", player, 255, 0, 0) 
    end 
end 
addCommandHandler("saveClothes", saveClothes) 
  
addEventHandler("onElementModelChange",root, 
function(old,new) 
    if ( getElementType(source) == "player" ) then 
        if ( new == 0 ) then 
        executeCommandHandler("loadClothes",source) 
        end 
    end 
end 
) 

Posted
--[[ 
original script by iAnnAs (iannas ben ahmed) 
--]] 
  
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 
        if ( getElementModel(player) == 0 ) then 
            local textureString = getAccountData(account, "Clothessaver:Texture") 
            local modelString = getAccountData(account, "Clothessaver:Model") 
            local textures = split(textureString, 44) 
            local models = split(modelString, 44) 
            for i=0, 17, 1 do 
                if ( textures[i+1] ~= " " ) then 
                    addPedClothes(source, textures[i+1], models[i+1], i) 
                end 
            end 
            exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
            textures = {} 
            models = {} 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setClothes) 
  
function loadClothes(player) 
    local account = getPlayerAccount(player) 
    if ( not isGuestAccount(account) ) then 
        if ( getElementModel(player) == 0 ) then 
            local textureString = getAccountData(account, "Clothessaver:Texture") 
            local modelString = getAccountData(account, "Clothessaver:Model") 
            local textures = split(textureString, 44) 
            local models = split(modelString, 44) 
            for i=0, 17, 1 do 
                if ( textures[i+1] ~= " " ) then 
                    addPedClothes(player, textures[i+1], models[i+1], i) 
                end 
            end 
            exports.CSTtexts:sendMessage("Your CJ Clothes were added Back", 0, 255, 0, true) 
            textures = {} 
            models = {} 
        else 
            exports.CSTtexts:sendMessage("Your skin must be skin 0 (CJ Skin)", 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Please login!", player, 255, 0, 0) 
    end 
end 
addCommandHandler("loadClothes", loadClothes) 
  
function saveClothes(player) 
    local account = getPlayerAccount(player) 
    if ( not isGuestAccount(account) ) then 
        if ( getElementModel(player) == 0 ) then 
            local texture = {} 
            local model = {} 
            for i=0, 17, 1 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 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 = {} 
        else 
            exports.CSTtexts:sendMessage("Your skin must be skin 0 (CJ Skin)", 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Please login!", player, 255, 0, 0) 
    end 
end 
addCommandHandler("saveClothes", saveClothes) 
  
addEventHandler("onElementModelChange",root, 
function(old,new) 
    if ( getElementType(source) == "player" ) then 
        if ( new == 0 ) then 
        executeCommandHandler("loadClothes",source) 
        end 
    end 
end 
) 

not work :/ , when i reconnect , clothes not saved ..

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...