Jump to content

CJ Clothes saving function


TheHavique

Recommended Posts

Im working on a CJ clothes script, to save it, Im using this function:

function createClothesJSONString ( returnType ) 
    local clothesTable = {} 
    local smtn = false 
    for i=0,17 do 
        local texture, model = getPedClothes ( localPlayer, i ) 
        if ( texture ) then 
            local theType, theIndex = getTypeIndexFromClothes ( texture, model ) 
            clothesTable[theType] = theIndex 
            smtn = true 
        end 
    end 
    if ( smtn ) then 
        if ( returnType == "JSON" ) then 
            return "" .. toJSON( clothesTable ):gsub( " ", "" ) .. "" 
        else 
            return clothesTable 
        end 
    else 
        return "NULL" 
    end 
end  

The output this function gives is this for example:

[{"1":25,"2":14,"3":13,"0":0,"13":8,"15":10}]

"1" = clothesType

:25 = clothesIndex

etc.

But the problem is, as you can see it outputs, "0":0. This causes shirts not being saved because it always set their shirt to player_torso. Anyone has any idea how I can fix this?

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