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

Lua someone can help with skin item?

908712

New Member
Joined
Jan 29, 2017
Messages
6
Reaction score
0
Hello, I have a question, can someone help me, rewrite the script?
I found the @M0ustafa user script:
Lua:
local t = {
    -- [vocation, promotedvocation] = {mini = minimum heal, maxi = maximum heal}
    [{1, 2, 5, 6}] = {mp={1050,1150},hp={100,150}},
    [{3, 7}] = {mp={300,500}, hp={800,950}},
    [{4, 8}] = {mp={150,300}, hp={2100,2450}},
    [{9, 10}] = {mp={1200,1300},hp={200,250}},
    [{11}] = {mp={350,650}, hp={900,1050}},
    [{12}] = {mp={250,350}, hp={2200,2450}}
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, EXHAUST_HEALING)

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not isPlayer(itemEx.uid) then
        return false
    elseif hasCondition(cid, CONDITION_EXHAUST, EXHAUST_HEALING) then
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    end

    local p = getPlayerVocation(cid)
    for k, v in pairs(t) do
        if isInArray(k, p) then
            doAddCondition(cid, exhaust)
            if v.mp then
                doCreatureAddMana(cid, math.random(v.mp[1], v.mp[2]))
            end
            if v.hp then
                doCreatureAddHealth(cid, math.random(v.hp[1], v.hp[2]))
            end
            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            return true
        end
    end

end

and I have a question if anyone can rewrite the script so that instead of hp item, will give player a new Outfit,?
the point is:
knight after use item will get: outfit id-1
druid after use item will get: outfit id-2
[example knight cant get druid outfits and druids cant get knights outfits]
My engine: TFS 0.3.6 - 8.54


Sorry for my english i use translator

P.S:

I am currently using this script but I have to add a lot of items and edit each one
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 7995 and (getPlayerStorageValue(cid, 94210) == EMPTY_STORAGE) then
        doPlayerAddOutfitId(cid, 1, 3)
        setPlayerStorageValue(cid, 94210, 1)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
        doPlayerSendTextMessage(cid,22,"You recive a Skin!")
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendCancel(cid,"You already have these Skin!")
    end
end
 
Solution
Hello, I have a question, can someone help me, rewrite the script?
I found the @M0ustafa user script:
Lua:
local t = {
    -- [vocation, promotedvocation] = {mini = minimum heal, maxi = maximum heal}
    [{1, 2, 5, 6}] = {mp={1050,1150},hp={100,150}},
    [{3, 7}] = {mp={300,500}, hp={800,950}},
    [{4, 8}] = {mp={150,300}, hp={2100,2450}},
    [{9, 10}] = {mp={1200,1300},hp={200,250}},
    [{11}] = {mp={350,650}, hp={900,1050}},
    [{12}] = {mp={250,350}, hp={2200,2450}}
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, EXHAUST_HEALING)

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not...
Hello, I have a question, can someone help me, rewrite the script?
I found the @M0ustafa user script:
Lua:
local t = {
    -- [vocation, promotedvocation] = {mini = minimum heal, maxi = maximum heal}
    [{1, 2, 5, 6}] = {mp={1050,1150},hp={100,150}},
    [{3, 7}] = {mp={300,500}, hp={800,950}},
    [{4, 8}] = {mp={150,300}, hp={2100,2450}},
    [{9, 10}] = {mp={1200,1300},hp={200,250}},
    [{11}] = {mp={350,650}, hp={900,1050}},
    [{12}] = {mp={250,350}, hp={2200,2450}}
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, EXHAUST_HEALING)

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not isPlayer(itemEx.uid) then
        return false
    elseif hasCondition(cid, CONDITION_EXHAUST, EXHAUST_HEALING) then
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    end

    local p = getPlayerVocation(cid)
    for k, v in pairs(t) do
        if isInArray(k, p) then
            doAddCondition(cid, exhaust)
            if v.mp then
                doCreatureAddMana(cid, math.random(v.mp[1], v.mp[2]))
            end
            if v.hp then
                doCreatureAddHealth(cid, math.random(v.hp[1], v.hp[2]))
            end
            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            return true
        end
    end

end

and I have a question if anyone can rewrite the script so that instead of hp item, will give player a new Outfit,?
the point is:
knight after use item will get: outfit id-1
druid after use item will get: outfit id-2
[example knight cant get druid outfits and druids cant get knights outfits]
My engine: TFS 0.3.6 - 8.54


Sorry for my english i use translator

P.S:

I am currently using this script but I have to add a lot of items and edit each one
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 7995 and (getPlayerStorageValue(cid, 94210) == EMPTY_STORAGE) then
        doPlayerAddOutfitId(cid, 1, 3)
        setPlayerStorageValue(cid, 94210, 1)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
        doPlayerSendTextMessage(cid,22,"You recive a Skin!")
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendCancel(cid,"You already have these Skin!")
    end
end
I hope this is what you were wanting, because it took me forever to learn how to interate through the index's. lmao
Never really understood pairs or ipairs before, but I think I have a decent grasp of the concept now, so thanks for the question to encourage me to finally learn something

anyway yeah, I think this is what you were wanting.

Use item -> find item in table -> find vocation in index -> check storage -> give outfit
Lua:
local outfits = {
    [7995] = { -- itemid
        [{1, 5}] = {{94210, 1}, 1}, --[{vocation, ids}] = {{storage, storage_value}, outfitid}
        [{2, 6}] = {{94210, 1}, 2},
        [{3, 7}] = {{94210, 1}, 3},
        [{4, 8}] = {{94210, 1}, 4} -- 4 is knight, 8 is elite knight if I remember correctly.
        },
    [1111] = {
        [{1, 5}] = {{11111, 1}, 1},
        [{2, 6}] = {{11111, 1}, 2},
        [{3, 7}] = {{11111, 1}, 3},
        [{4, 8}] = {{11111, 1}, 4}
        },
    [2222] = {
        [{1, 5}] = {{22222, 1}, 1},
        [{2, 6}] = {{22222, 1}, 2},
        [{3, 7}] = {{22222, 1}, 3},
        [{4, 8}] = {{22222, 1}, 4}
        }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)   
    local array = outfits[item]
    if array then
        local vocation = getPlayerVocation(cid)
        for index, v in pairs(array) do
            for i = 1, #index do
                if index[i] == vocation then
                    local found = array[index]
                    -- found[1][1] / found[1][2] is the storage / storage_value in table
                    -- found[2] is the outfitid
                    if getCreatureStorage(cid, found[1][1]) < found[1][2] then
                        doSendMagicEffect(fromPosition, CONST_ME_POFF)
                        doPlayerSendCancel(cid, "You already have this outfit!")
                        return true
                    end
                    doPlayerAddOutfitId(cid, found[2], 3) -- 3 indicates to give both addons
                    doCreatureSetStorage(cid, found[1][1], found[1][2])
                    doSendMagicEffect(fromPosition, CONST_ME_HOLYDAMAGE)
                    doPlayerSendTextMessage(cid, 22, "You received an outfit!")
                    doRemoveItem(item.uid, 1)
                    return true
                end
            end
        end
        print("LUA_ERROR: Vocation does not exist.")
    else
        print("LUA_ERROR: Table Index does not exist.")
    end
    return true
end
 
Last edited:
Solution
I hope this is what you were wanting, because it took me forever to learn how to interate through the index's. lmao
Never really understood pairs or ipairs before, but I think I have a decent grasp of the concept now, so thanks for the question to encourage me to finally learn something

anyway yeah, I think this is what you were wanting.

Use item -> find item in table -> find vocation in index -> check storage -> give outfit
Lua:
local outfits = {
    [7995] = { -- itemid
        [{1, 5}] = {{94210, 1}, 1}, --[{vocation, ids}] = {{storage, storage_value}, outfitid}
        [{2, 6}] = {{94210, 1}, 2},
        [{3, 7}] = {{94210, 1}, 3},
        [{4, 8}] = {{94210, 1}, 4} -- 4 is knight, 8 is elite knight if I remember correctly.
        },
    [1111] = {
        [{1, 5}] = {{11111, 1}, 1},
        [{2, 6}] = {{11111, 1}, 2},
        [{3, 7}] = {{11111, 1}, 3},
        [{4, 8}] = {{11111, 1}, 4}
        },
    [2222] = {
        [{1, 5}] = {{22222, 1}, 1},
        [{2, 6}] = {{22222, 1}, 2},
        [{3, 7}] = {{22222, 1}, 3},
        [{4, 8}] = {{22222, 1}, 4}
        }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)  
    local array = outfits[item]
    if array then
        local vocation = getPlayerVocation(cid)
        for index, v in pairs(array) do
            for i = 1, #index do
                if index[i] == vocation then
                    local found = array[index]
                    -- found[1][1] / found[1][2] is the storage / storage_value in table
                    -- found[2] is the outfitid
                    if getCreatureStorage(cid, found[1][1]) < found[1][2] then
                        doSendMagicEffect(fromPosition, CONST_ME_POFF)
                        doPlayerSendCancel(cid, "You already have this outfit!")
                        return true
                    end
                    doPlayerAddOutfitId(cid, found[2], 3) -- 3 indicates to give both addons
                    doCreatureSetStorage(cid, found[1][1], found[1][2])
                    doSendMagicEffect(fromPosition, CONST_ME_HOLYDAMAGE)
                    doPlayerSendTextMessage(cid, 22, "You received an outfit!")
                    doRemoveItem(item.uid, 1)
                    return true
                end
            end
        end
        print("LUA_ERROR: Vocation does not exist.")
    else
        print("LUA_ERROR: Table Index does not exist.")
    end
    return true
end





Hello, thank you for your reply. But I pointed out that the problem is solved.
I solved the problem myself using my old script + I used Reborn NPC and everything works fine. I am sorry that you tried to solve my problem after i solved it myself; /
 
Back
Top