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

RevScripts Use itemid2 on itemid1 then make itemid3

Paxiz

Premium User
Premium User
Joined
Mar 21, 2024
Messages
44
Solutions
1
Reaction score
21
Location
~pl /opt
I need script:
If i use item with ID 2222 on item id 1111 then i got item id 3333
But it possible if player have storage 5555 with value 3.
If player dont have storage 5555 or have value 2 or lower then cancel message "You cant make it".

Example: old enchant spike sword to fire spike sword but with storage 5555 with value >= 3.

TFS 1.4.2
 
Solution
X
Don't be like me.
Don't code this way.
Label your tables properly.

Anyways, enjoy.
LUA:
local config = {
-- use 2222 on 1111 get 3333 if storage 5555 >= 3
    [2222] = {1111, 3333, 5555, 3}
}

local testAction = Action()

function testAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Target must be an item.")
        return true
    end
    local index = config[item:getId()]
    if index[1] ~= target:getId() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Cannot use on this item.")
        return true
    end
    if player:getStorageValue(index[3]) < index[4] then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You...
Don't be like me.
Don't code this way.
Label your tables properly.

Anyways, enjoy.
LUA:
local config = {
-- use 2222 on 1111 get 3333 if storage 5555 >= 3
    [2222] = {1111, 3333, 5555, 3}
}

local testAction = Action()

function testAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Target must be an item.")
        return true
    end
    local index = config[item:getId()]
    if index[1] ~= target:getId() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Cannot use on this item.")
        return true
    end
    if player:getStorageValue(index[3]) < index[4] then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't make it.")
        return true
    end
    item:remove(1)
    target:remove(1)
    player:addItem(index[2], 1, true)
    return true
end

for k, v in pairs(config) do
    testAction:id(k)
end
testAction:register()
 
Solution

Similar threads

Back
Top