Jump to content

Clothes save , help


Annas

Recommended Posts

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) 
  

Link to comment

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 

Link to comment

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 .

Link to comment
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

Link to comment

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) 

Link to comment
--[[ 
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 
) 

Link to comment
--[[ 
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 ..

Link to comment

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...