• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Super ring

Atm you have if, else, elseif, else, elseif, else, elseif, else, end.
It should be like this.
Code:
if .. then
     -- blabla
else
     -- blabla
end

-- or

if .. then
     -- blabla
elseif .. then
     -- blabla
end

-- or

if .. then
     -- blabla
elseif .. then
     -- blabla
else
     -- blabla
end

-- or

if .. then
     -- blabla
elseif .. then
     -- blabla
elseif .. then -- you can repeat elseif in the if statements multiple times
     -- blabla
else -- else should be last above the end
     -- blabla
end

What you can do for the gender part is create an extra if statement after checking for voc.
Code:
if isDruid(cid) then
     if sex == 1 then
          -- blabla
     else
          -- blabla
     end
elseif isSorcerer(cid) then
     if sex == 1 then
          -- etc
 
Last edited:
When upgrading an existing script, you want establish a basic version 1st, start small, in this case, use an outfit condition to apply to the player.

All complex scripts start out small, once you have the basics working then you add to it more functionality, this is the normal method of writing a script/program.

Here I will start you off :)
Code:
-- using a table keeps the script orginized and easy to trouble shoot errors that will arise
-- use comments to show how the data is stored or excuted
local c = { -- c short for config
    -- use names for properties of variables/tables which make sense
    itemType = 2160,
    amount = 20,
    outfitStorage = 18000
}
-- 0 for female, 1 for male
local outfits = {
    [0] = { -- female, 0 corresponds to the sex of the player as female
        -- the index of the table below corresponds to vocation of the player
        [1] = { -- sorcerer,
            lookType = 243,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        },
        [2] = { -- druid
            lookType = 11,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        },
        [3] = { -- paladin
            lookType = 345,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        },
        [4] = { -- knight
            lookType = 306,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        }
    },
    [1] = { -- male, 1 corresponds to the sex of the player as male
        -- the index of the table below corresponds to vocation of the player
        [1] = { -- sorcerer
            lookType = 243,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        },
        [2] = { -- druid
            lookType = 11,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        },
        [3] = { -- paladin
            lookType = 345,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        },
        [4] = { -- knight
            lookType = 306,
            lookHead = 0,
            lookBody = 0,
            lookLegs = 0,
            lookFeet = 0,
            lookAddons = 0
        }
    }
}

function onEquip(cid, item, slot)
    -- onEquip executes more then once, this is just a preventive measure
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return false
        end
    else
        local cost = getPlayerItemCount(cid, c.itemType)
        -- 1st thing is 1st lets make sure they have enough money in this case to use this item
        if cost >= c.amount then
            -- then lets check if they have outfit already assigned to the player
            if getPlayerStorageValue(c.outfitStorage) < 1 then
            -- if not then lets get their vocation & sex, important because will use this later
                local vocation = getPlayerVocation(cid)
                local sex = getPlayerSex(cid)
                -- for now we are just testing the waters... lets just see if we can change the players outfit based on its sex and vocation
                -- so we take our outfits table and apply sex and vocation to the corresponding table indexes
                doSetCreatureOutfit(cid, outfits[sex][vocation], -1)
                -- The setting value you assign to the storage is optional, any number greater then 0
                -- however I like to use the vocation as its value
                setPlayerStorageValue(c.outfitStorage, vocation)
                -- remove the item amount from the player
                doPlayerRemoveItem(cid, c.itemType, c.amount)
                -- this table will be used later for the rest of the functionality of your script
                local p = {cid = cid, item = item, slot = slot, sex = sex, id = vocation}
            end
        end
    end
    return true
end

function onDeEquip(cid, item, slot)
    -- check to make sure the player has an outfit condition assigned to them, by checking the storage value
    if getPlayerStorageValue(c.outfitStorage) > 0 then
        -- if they do remove the outfit condition
        doRemoveCondition(cid, CONDITION_OUTFIT)
        -- set the storage value to 0
        setPlayerStorageValue(c.outfitStorage, 0)
    end
    return true
end
 
Please crop your signature,
Ur signature isn't cropped correctly too. :P

This is the full image;
ibu57wW.png
 

Similar threads

Replies
0
Views
182
Back
Top