• 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!

TFS 0.X Random addon doll problem with script

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i try create script for random addon doll, but my script give one addon and if player use doll again he dont get more addons ;/ And how to add blockade if player have addon, so scritp give next addon? And if player have all addons from doll, he can't use doll?

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addons_male = {
        381,
        383,
        385,
        387,
        389,
        391,
        393
    }
local addons_famele = {
        382,
        384,
        386,
        388,
        390,
        392,
        394
    }
local msg = {"Congratulations! You get full random addon!"}
    if(getPlayerItemCount(cid, 12716) > 0) then
            doPlayerRemoveItem(cid, 12716, 1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[1])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
            if(getPlayerSex(cid) == 0)then
                for i = 1, #addons_famele do
                local fameleaddon = addons_famele[i]
                doPlayerAddOutfit(cid, fameleaddon, 3)
                end
            else
                for i = 1, #addons_male do
                local maleaddon = addons_male[i]
                doPlayerAddOutfit(cid, maleaddon, 3)
            end
            end
            end
            return true
            end
 
Lua:
local config = {
    [PLAYERSEX_MALE] = {381, 383, 385, 387, 389, 391, 393},
    [PLAYERSEX_FEMALE] = {382, 384, 386, 388, 390, 392, 394},
    msgSucess = 'Congratulations! You get full random addon!',
    msgNoHaveDoll = 'You do not have the addon doll.',
    msgHaveAllOutfits = 'You already have all the addons.',
    removeItemId = 12716,
    removeAmount = 1,
}

local function randomAddon(cid, table)
    local random = table[math.random(#table)]
    if canPlayerWearOutfitId(cid, random) then
        random = randomAddon()
    end
    return random
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmpConfig = config[getPlayerSex(cid)]
    if not tmpConfig then
        return false
    end

    if getPlayerItemCount(cid, config.itemId) < 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgNoHaveDoll)
        return true
    end

    for i = 1, #tmpConfig do
        if canPlayerWearOutfitId(cid, tmpConfig[i]) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgHaveAllOutfits)
            return true
        end
    end

    local look = randomAddon(cid, tmpConfig)
    doPlayerRemoveItem(cid, config.removeItemId, config.removeAmount)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgSucess)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
    doPlayerAddOutfit(cid, randomAddon(cid, tmpConfig), 3)
    return true
end
Test, please, I still get lost in functions 0.4, haha :p
 
Lua:
local config = {
    [PLAYERSEX_MALE] = {381, 383, 385, 387, 389, 391, 393},
    [PLAYERSEX_FEMALE] = {382, 384, 386, 388, 390, 392, 394},
    msgSucess = 'Congratulations! You get full random addon!',
    msgNoHaveDoll = 'You do not have the addon doll.',
    msgHaveAllOutfits = 'You already have all the addons.',
    removeItemId = 12716,
    removeAmount = 1,
}

local function randomAddon(cid, table)
    local random = table[math.random(#table)]
    if canPlayerWearOutfitId(cid, random) then
        random = randomAddon()
    end
    return random
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmpConfig = config[getPlayerSex(cid)]
    if not tmpConfig then
        return false
    end

    if getPlayerItemCount(cid, config.itemId) < 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgNoHaveDoll)
        return true
    end

    for i = 1, #tmpConfig do
        if canPlayerWearOutfitId(cid, tmpConfig[i]) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgHaveAllOutfits)
            return true
        end
    end

    local look = randomAddon(cid, tmpConfig)
    doPlayerRemoveItem(cid, config.removeItemId, config.removeAmount)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgSucess)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
    doPlayerAddOutfit(cid, randomAddon(cid, tmpConfig), 3)
    return true
end
Test, please, I still get lost in functions 0.4, haha :p

Not work ;/ If i use item, i get 2 outfits (381 and 383), if i'm female i get too only 2 outfits for male, if i try use item again, i dont get more outfits ;/
 
Lua:
local config = {
    [PLAYERSEX_MALE] = {381, 383, 385, 387, 389, 391, 393},
    [PLAYERSEX_FEMALE] = {382, 384, 386, 388, 390, 392, 394},
    msgSucess = 'Congratulations! You get full random addon!',
    msgNoHaveDoll = 'You do not have the addon doll.',
    msgHaveAllOutfits = 'You already have all the addons.',
    removeItemId = 2160,
    removeAmount = 1,
}

local function randomAddon(cid, table)
    local random = table[math.random(#table)]
    if canPlayerWearOutfit(cid, random) then
        random = randomAddon(cid, table)
    end
    return random
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmpConfig = config[getPlayerSex(cid)]
    if not tmpConfig then
        return false
    end

    if getPlayerItemCount(cid, config.removeItemId) < 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgNoHaveDoll)
        return true
    end

    for i = 1, #tmpConfig do
        if canPlayerWearOutfit(cid, tmpConfig[i]) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgHaveAllOutfits)
            return true
        end
    end

    local look = randomAddon(cid, tmpConfig)
    doPlayerRemoveItem(cid, config.removeItemId, config.removeAmount)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgSucess)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
    doPlayerAddOutfit(cid, look, 3)
    return true
end

it's more optimized
o_O
 
Last edited:
Lua:
local config = {
    [PLAYERSEX_MALE] = {381, 383, 385, 387, 389, 391, 393},
    [PLAYERSEX_FEMALE] = {382, 384, 386, 388, 390, 392, 394},
    msgSucess = 'Congratulations! You get full random addon!',
    msgNoHaveDoll = 'You do not have the addon doll.',
    msgHaveAllOutfits = 'You already have all the addons.',
    removeItemId = 2160,
    removeAmount = 1,
}

local function randomAddon(cid, table)
    local random = table[math.random(#table)]
    if canPlayerWearOutfit(cid, random) then
        random = randomAddon(cid, table)
    end
    return random
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmpConfig = config[getPlayerSex(cid)]
    if not tmpConfig then
        return false
    end
    if getPlayerItemCount(cid, config.removeItemId) < 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgNoHaveDoll)
        return true
    end
    for i = 1, #tmpConfig do
        if canPlayerWearOutfit(cid, tmpConfig[i]) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgHaveAllOutfits)
            return true
        end
    end
    doPlayerRemoveItem(cid, config.removeItemId, config.removeAmount)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgSucess)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
    doPlayerAddOutfit(cid, look, 3)
    return true
end


o_O

Now, if i use item, i get message "Congratulations! You get full random addon!" but any outfit dont added
 
Lua:
local config = {
    [PLAYERSEX_MALE] = {381, 383, 385, 387, 389, 391, 393},
    [PLAYERSEX_FEMALE] = {382, 384, 386, 388, 390, 392, 394},
    msgSucess = 'Congratulations! You get full random addon!',
    msgNoHaveDoll = 'You do not have the addon doll.',
    msgHaveAllOutfits = 'You already have all the addons.',
    removeItemId = 2160,
    removeAmount = 1,
}

local function randomAddon(cid, table)
    local random = table[math.random(#table)]
    if canPlayerWearOutfit(cid, random) then
        random = randomAddon(cid, table)
    end
    return random
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmpConfig = config[getPlayerSex(cid)]
    if not tmpConfig then
        return false
    end

    if getPlayerItemCount(cid, config.removeItemId) < 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgNoHaveDoll)
        return true
    end

    for i = 1, #tmpConfig do
        if canPlayerWearOutfit(cid, tmpConfig[i]) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgHaveAllOutfits)
            return true
        end
    end

    local look = randomAddon(cid, tmpConfig)
    doPlayerRemoveItem(cid, config.removeItemId, config.removeAmount)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgSucess)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
    doPlayerAddOutfit(cid, look, 3)
    return true
end
 
Lua:
local config = {
    [PLAYERSEX_MALE] = {381, 383, 385, 387, 389, 391, 393},
    [PLAYERSEX_FEMALE] = {382, 384, 386, 388, 390, 392, 394},
    msgSucess = 'Congratulations! You get full random addon!',
    msgNoHaveDoll = 'You do not have the addon doll.',
    msgHaveAllOutfits = 'You already have all the addons.',
    removeItemId = 2160,
    removeAmount = 1,
}

local function randomAddon(cid, table)
    local random = table[math.random(#table)]
    if canPlayerWearOutfit(cid, random) then
        random = randomAddon(cid, table)
    end
    return random
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmpConfig = config[getPlayerSex(cid)]
    if not tmpConfig then
        return false
    end

    if getPlayerItemCount(cid, config.removeItemId) < 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgNoHaveDoll)
        return true
    end

    for i = 1, #tmpConfig do
        if canPlayerWearOutfit(cid, tmpConfig[i]) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgHaveAllOutfits)
            return true
        end
    end

    local look = randomAddon(cid, tmpConfig)
    doPlayerRemoveItem(cid, config.removeItemId, config.removeAmount)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.msgSucess)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
    doPlayerAddOutfit(cid, look, 3)
    return true
end

Now work only for one use, i use item and i get one outfit (but on male i get female) and if i try use again i get message "You already have all the addons."
 
Back
Top