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

CreatureEvent Upgrade sistem by click

jajajiji

New Member
Joined
Jan 20, 2009
Messages
23
Reaction score
1
1.- data/actions/scripts/upgrade.lua
Code:
local messagetype = MESSAGE_EVENT_ORANGE
local fetishs = {
    [7800] = {chance = 100, amount = 1, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7801] = {chance = 80, amount = 2, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7802] = {chance = 50, amount = 3, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7803] = {chance = 20, amount = 2, set = setItemAttack, get = getItemAttack, name = "attack", destroy = TRUE},
    [7804] = {chance = 30, amount = 3, set = setItemAttack, get = getItemAttack, name = "attack", destroy = TRUE},
    [7805] = {chance = 100, amount = 1, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7806] = {chance = 80, amount = 3, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7807] = {chance = 50, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7808] = {chance = 20, amount = 3, set = setItemDefense, get = getItemDefense, name = "defense", destroy = TRUE},
    [7809] = {chance = 30, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense", destroy = TRUE},
    [7810] = {chance = 100, amount = 1, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7811] = {chance = 80, amount = 2, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7812] = {chance = 50, amount = 3, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7813] = {chance = 20, amount = 2, set = setItemArmor, get = getItemArmor, name = "armor", destroy = TRUE},
    [7814] = {chance = 30, amount = 3, set = setItemArmor, get = getItemArmor, name = "armor", destroy = TRUE},
    [7850] = {chance = 100, amount = 5, set = setItemAttack, get = getItemAttack, name = "attack"}, -- only given when access >= 5
    [7851] = {chance = 100, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense"}, -- only given when access >= 5
    [7852] = {chance = 100, amount = 5, set = setItemArmor, get = getItemArmor, name = "armor"}    -- only given when access >= 5
}
local minmax = {
    min1 = 7800, -- minimum of the random fetishs for access < 5
    max1 = 7814, -- maximum of the random fetishs for access < 5
    min2 = 7850, -- minimum of the random fetishs for access >= 5
    max2 = 7852, -- maximum of the random fetishs for access >= 5
}
-- WARNING: look further down and your eyes will burn. --
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.actionid == 0 then
        local new = getPlayerAccess(cid) >= 5 and math.random(minmax.min2, minmax.max2) or math.random(minmax.min1, minmax.max1)
        local text = "You remove the dust and revealed that it is a "..fetishs[new].chance.."% fetish for "..fetishs[new].name.." +"..fetishs[new].amount.."."..(fetishs[new].destroy ~= nil and " It has a slight chance of breaking your item." or "")
        doPlayerSendTextMessage(cid, messagetype, text)
        doSetItemActionId(item.uid, new)
        setItemName(item.uid, fetishs[new].chance.."% fetish for "..fetishs[new].name.." +"..fetishs[new].amount)
    elseif fetishs[item.actionid] ~= nil then
        if fetishs[item.actionid].get(itemEx.uid) > 0 then
            if itemEx.actionid < 150 then
                local amount = math.max(0, itemEx.actionid - 100)
                local chance = math.random(0, 100)
                local text = fetishs[item.actionid].name.." upgrade on "..getItemNameById(itemEx.itemid).." failed."
                if chance <= fetishs[item.actionid].chance then
                    fetishs[item.actionid].set(itemEx.uid, (fetishs[item.actionid].get(itemEx.uid)+fetishs[item.actionid].amount))
                    text = getItemNameById(itemEx.itemid).." "..fetishs[item.actionid].name.." +"..fetishs[item.actionid].amount.."."
                elseif fetishs[item.actionid].destroy ~= nil or fetishs[item.actionid].destroy == TRUE then
                    if math.random(0, 1) == 1 then
                        doRemoveItem(itemEx.uid)
                        text = getItemNameById(itemEx.itemid).." has been destroyed."
                    end
                end
                doPlayerSendTextMessage(cid, messagetype, text)
                doSetItemActionId(itemEx.uid, 100+(amount+1))
                setItemName(itemEx.uid, getItemNameById(itemEx.itemid).." (Level "..(amount+1)..")")
                doSendMagicEffect(toPosition, (chance <= fetishs[item.actionid].chance and 13 or 2))
                doRemoveItem(item.uid)
            else
                doPlayerSendCancel(cid, "This weapon has already been upgraded 50 times.")
            end
        else
            doPlayerSendCancel(cid, "This item may not be upgraded.")
        end
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
        return TRUE
end
2.- data/actions/actions.xml
Code:
    <action itemid="9970" event="script" value="upgrade.lua"/>
tested on TFS 0.3.4

HOW TO USE?
upgradec.jpg

1.- Use with something
2.- Check the message for upgrade armor,defense or attack
3.- Use with item
4.- Check item

Credits:
jordanhenry
 
Last edited:
YOU CANNOT USE THIS SCRIPT WITH ITEMS THAT CAN BE STACKED!!!!!


Any stackable item with an actionid will change when you;

move it
trade it
etc

So you need to use any other "usable" item for this, not a gem
 
Last edited:
Congratz, jajajiji, you can copy&paste, and then delete the credits...

Sincerely,
Yours Pablol
 
YOU CANNOT USE THIS SCRIPT WITH ITEMS THAT CAN BE STACKED!!!!!


Any stackable item with an actionid will change when you;

move it
trade it
etc

So you need to use any other "usable" item for this, not a gem
change XXXX for items Id of other no stackable
Code:
<action itemid="XXXX" event="script" value="upgrade.lua"/>
 
1.- data/actions/scripts/upgrade.lua
Code:
local messagetype = MESSAGE_EVENT_ORANGE
local fetishs = {
    [7800] = {chance = 100, amount = 1, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7801] = {chance = 80, amount = 2, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7802] = {chance = 50, amount = 3, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7803] = {chance = 20, amount = 2, set = setItemAttack, get = getItemAttack, name = "attack", destroy = TRUE},
    [7804] = {chance = 30, amount = 3, set = setItemAttack, get = getItemAttack, name = "attack", destroy = TRUE},
    [7805] = {chance = 100, amount = 1, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7806] = {chance = 80, amount = 3, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7807] = {chance = 50, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7808] = {chance = 20, amount = 3, set = setItemDefense, get = getItemDefense, name = "defense", destroy = TRUE},
    [7809] = {chance = 30, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense", destroy = TRUE},
    [7810] = {chance = 100, amount = 1, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7811] = {chance = 80, amount = 2, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7812] = {chance = 50, amount = 3, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7813] = {chance = 20, amount = 2, set = setItemArmor, get = getItemArmor, name = "armor", destroy = TRUE},
    [7814] = {chance = 30, amount = 3, set = setItemArmor, get = getItemArmor, name = "armor", destroy = TRUE},
    [7850] = {chance = 100, amount = 5, set = setItemAttack, get = getItemAttack, name = "attack"}, -- only given when access >= 5
    [7851] = {chance = 100, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense"}, -- only given when access >= 5
    [7852] = {chance = 100, amount = 5, set = setItemArmor, get = getItemArmor, name = "armor"}	-- only given when access >= 5
}
local minmax = {
    min1 = 7800, -- minimum of the random fetishs for access < 5
    max1 = 7814, -- maximum of the random fetishs for access < 5
    min2 = 7850, -- minimum of the random fetishs for access >= 5
    max2 = 7852, -- maximum of the random fetishs for access >= 5
}
-- WARNING: look further down and your eyes will burn. --
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.actionid == 0 then
        local new = getPlayerAccess(cid) >= 5 and math.random(minmax.min2, minmax.max2) or math.random(minmax.min1, minmax.max1)
        local text = "You remove the dust and revealed that it is a "..fetishs[new].chance.."% fetish for "..fetishs[new].name.." +"..fetishs[new].amount.."."..(fetishs[new].destroy ~= nil and " It has a slight chance of breaking your item." or "")
        doPlayerSendTextMessage(cid, messagetype, text)
        doSetItemActionId(item.uid, new)
        setItemName(item.uid, fetishs[new].chance.."% fetish for "..fetishs[new].name.." +"..fetishs[new].amount)
    elseif fetishs[item.actionid] ~= nil then
        if fetishs[item.actionid].get(itemEx.uid) > 0 then
            if itemEx.actionid < 150 then
                local amount = math.max(0, itemEx.actionid - 100)
                local chance = math.random(0, 100)
                local text = fetishs[item.actionid].name.." upgrade on "..getItemNameById(itemEx.itemid).." failed."
                if chance <= fetishs[item.actionid].chance then
                    fetishs[item.actionid].set(itemEx.uid, (fetishs[item.actionid].get(itemEx.uid)+fetishs[item.actionid].amount))
                    text = getItemNameById(itemEx.itemid).." "..fetishs[item.actionid].name.." +"..fetishs[item.actionid].amount.."."
                elseif fetishs[item.actionid].destroy ~= nil or fetishs[item.actionid].destroy == TRUE then
                    if math.random(0, 1) == 1 then
                        doRemoveItem(itemEx.uid)
                        text = getItemNameById(itemEx.itemid).." has been destroyed."
                    end
                end
                doPlayerSendTextMessage(cid, messagetype, text)
                doSetItemActionId(itemEx.uid, 100+(amount+1))
                setItemName(itemEx.uid, getItemNameById(itemEx.itemid).." (Level "..(amount+1)..")")
                doSendMagicEffect(toPosition, (chance <= fetishs[item.actionid].chance and 13 or 2))
                doRemoveItem(item.uid)
            else
                doPlayerSendCancel(cid, "This weapon has already been upgraded 50 times.")
            end
        else
            doPlayerSendCancel(cid, "This item may not be upgraded.")
        end
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
        return TRUE
end
2.- data/actions/actions.xml
Code:
	<action itemid="9970" event="script" value="upgrade.lua"/>
tested on TFS 0.3.4

HOW TO USE?
upgradec.jpg

1.- Use with something
2.- Check the message for upgrade armor,defense or attack
3.- Use with item
4.- Check item

Useful script but next time give respective credits. This is not yours, its clearly from jordanhenry. The only thing you did was copy it + paste it here, so next time state that fact.

Give credits.

And

...No shit.

Lol.
 
Updated now can upgrade bows and crossbows
*actionid save now can trade, move, etc.:thumbup:
*now shows in description if is destroy or not
\data\actions\scripts\upgrade.lua
PHP:
local messagetype = MESSAGE_EVENT_ORANGE
local fetishs = {
    [7800] = {chance = 100, amount = 1, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7801] = {chance = 80, amount = 2, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7802] = {chance = 50, amount = 3, set = setItemAttack, get = getItemAttack, name = "attack"},
    [7803] = {chance = 20, amount = 2, set = setItemAttack, get = getItemAttack, name = "attack", destroy = TRUE},
    [7804] = {chance = 30, amount = 3, set = setItemAttack, get = getItemAttack, name = "attack", destroy = TRUE},
    [7805] = {chance = 100, amount = 1, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7806] = {chance = 80, amount = 3, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7807] = {chance = 50, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense"},
    [7808] = {chance = 20, amount = 3, set = setItemDefense, get = getItemDefense, name = "defense", destroy = TRUE},
    [7809] = {chance = 30, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense", destroy = TRUE},
    [7810] = {chance = 100, amount = 1, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7811] = {chance = 80, amount = 2, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7812] = {chance = 50, amount = 3, set = setItemArmor, get = getItemArmor, name = "armor"},
    [7813] = {chance = 20, amount = 2, set = setItemArmor, get = getItemArmor, name = "armor", destroy = TRUE},
    [7814] = {chance = 30, amount = 3, set = setItemArmor, get = getItemArmor, name = "armor", destroy = TRUE},
    [7815] = {chance = 100, amount = 1, set = setItemShootRange, get = getItemShootRange, name = "range"},
    [7816] = {chance = 80, amount = 2, set = setItemShootRange, get = getItemShootRange, name = "range"},
    [7817] = {chance = 50, amount = 3, set = setItemShootRange, get = getItemShootRange, name = "range"},
    [7818] = {chance = 20, amount = 2, set = setItemShootRange, get = getItemShootRange, name = "range", destroy = TRUE},
    [7819] = {chance = 30, amount = 3, set = setItemShootRange, get = getItemShootRange, name = "range", destroy = TRUE},
    [7850] = {chance = 100, amount = 5, set = setItemAttack, get = getItemAttack, name = "attack"}, -- only given when access >= 5
    [7851] = {chance = 100, amount = 5, set = setItemDefense, get = getItemDefense, name = "defense"}, -- only given when access >= 5
    [7852] = {chance = 100, amount = 5, set = setItemArmor, get = getItemArmor, name = "armor"}, -- only given when access >= 5
    [7853] = {chance = 100, amount = 5, set = setItemShootRange, get = getItemShootRange, name = "range"}	-- only given when access >= 5
}
local minmax = {
    min1 = 7800, -- minimum of the random fetishs for access < 5
    max1 = 7819, -- maximum of the random fetishs for access < 5
    min2 = 7850, -- minimum of the random fetishs for access >= 5
    max2 = 7853, -- maximum of the random fetishs for access >= 5
}
-- WARNING: look further down and your eyes will burn. --
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.actionid == 0 then
        local new = getPlayerAccess(cid) >= 5 and math.random(minmax.min2, minmax.max2) or math.random(minmax.min1, minmax.max1)
        local text = "You remove the dust and revealed that it is a "..fetishs[new].chance.."% fetish for "..fetishs[new].name.." +"..fetishs[new].amount.."."..(fetishs[new].destroy ~= nil and " It has a slight chance of breaking your item." or "")
        doPlayerSendTextMessage(cid, messagetype, text)
        doSetItemActionId(item.uid, new)
        doSetItemSpecialDescription(item.uid, text)
        setItemName(item.uid, fetishs[new].chance.."% fetish for "..fetishs[new].name.." +"..fetishs[new].amount)
    elseif fetishs[item.actionid] ~= nil then
        if fetishs[item.actionid].get(itemEx.uid) > 0 then
            if itemEx.actionid < 110 then
                local amount = math.max(0, itemEx.actionid - 100)
                local chance = math.random(0, 100)
                local text = fetishs[item.actionid].name.." upgrade on "..getItemNameById(itemEx.itemid).." failed."
                if chance <= fetishs[item.actionid].chance then
                    fetishs[item.actionid].set(itemEx.uid, (fetishs[item.actionid].get(itemEx.uid)+fetishs[item.actionid].amount))
                    text = getItemNameById(itemEx.itemid).." "..fetishs[item.actionid].name.." +"..fetishs[item.actionid].amount.."."
                elseif fetishs[item.actionid].destroy ~= nil or fetishs[item.actionid].destroy == TRUE then
                    if math.random(0, 1) == 1 then
                        doRemoveItem(itemEx.uid)
                        text = getItemNameById(itemEx.itemid).." has been destroyed."
                    end
                end
                doPlayerSendTextMessage(cid, messagetype, text)
                doSetItemActionId(itemEx.uid, 100+(amount+1))
                setItemName(itemEx.uid, getItemNameById(itemEx.itemid).." (Level "..(amount+1)..")")
                doSendMagicEffect(toPosition, (chance <= fetishs[item.actionid].chance and 13 or 2))
                doRemoveItem(item.uid)
            else
                doPlayerSendCancel(cid, "This weapon has already been upgraded 10 times.")
            end
        else
            doPlayerSendCancel(cid, "This item may not be upgraded.")
        end
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
        return TRUE
end
\data\actions\actions.xml
PHP:
<action fromid="9743" toid="9744" event="script" value="upgrade.lua"/>
\data\items\items.xml
PHP:
	<item fromid="9743" toid="9744" name="upgrade crystal">
		<attribute key="weight" value="10"/>
	</item>
Enjoy this scripts
Credits (Again):
Created by jordanhenry and modified by Jajajiji(me)
 
I made this script as a base for upgrade systems, you can adjust the values as you wish. Thanks for sharing my script, but please ask for my permission before doing so in future.
 
I made this script as a base for upgrade systems, you can adjust the values as you wish. Thanks for sharing my script, but please ask for my permission before doing so in future.

Thank you for making this script, it will be used heavily on my server.

Edit: Range doesn't work
 
Last edited:
Back
Top