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

Simple onUse scripts

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hey guys!

I'm requesting about 3 simply onUse scripts for 1.2 tfs.

First -> use pick on special sqm will give you item. You can make it only once
Second -> use item on object will teleport the player to special location. Can you use once per day
Third -> use item on object will destroy object and make another one, will give item and after 10 seconds return to first form of object and only once player can make it.

Thanks guys!
 
For first with your map editor put the actionid of the tile to 1500, for the second thing put 1501 and third put 1502 then in actions.xml
XML:
<action itemid="2553" script="scripts.lua" />
<action itemid="xxxx" script="scripts.lua" />
<action itemid="xxxx" script="scripts.lua" />
then in scripts.lua put
Lua:
local cfirst = {
pickId = 2553
storage = 1500
action = 1500
reward = 2152
}
local csecond = {
storage = 1501
itemid = xxxx
action = 1501
toPos = Position(1000,1000,7)
days = 1
}
local cthird = {
useid = xxxx
storage = 1502
fromid = 1738
toid = 2250
reward = 2152
timer = 10
}
local firstrewardtype = ItemType(cfirst.reward)
local thirdrewardtype = ItemType(cthird.reward)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local playerCap = player:getCapacity()
    if item:getId() == cfirst.pickId and target:getActionId() == cfirst.action then
        if player:getStorageValue(cfirst.storage) ~= 1 then
            if playerCap > firstrewardtype:getCapacity() then
                player:addItem(cfirst.reward, 1)
                player:setStorageValue(cfirst.storage,1)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR,"You dug up a "..firstrewardtype:getName().." but weighing "..firstrewardtype:getCapacity().." it is too heavy.")
            end
        else
            return false
        end
    elseif item:getId() == csecond.itemid and target:getActionId() == csecond.action then
        if player:getStorageValue(csecond.storage) > os.time() then
            player:sendTextMessage(MESSAGE_INFO_DESCR,"You can only do this once per day.")
            return false
        else
            player:teleportTo(csecond.toPos)
            player:setStorageValue(csecond.storage, os.time() + csecond.days * 24 * 60 * 60)
        end
    elseif item:getId() == cthird.useid and target:getActionId() == cthird.action then
        if player:getStorageValue(cthird.storage) ~= 1 then
            if playerCap > thirdrewardtype:getCapacity() then
                target:transform(cthird.toid)
                player:addItem(cthird.reward,1)
                player:setStorageValue(cthird.storage,1)
                addEvent(function()
                    target:transform(cthird.fromid)
                end,cthird.timer*1000)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR,"You found a "..thirdrewardtype:getName().." but weighing "..thirdrewardtype:getCapacity().." it is too heavy.")
                return false
            end
        end
    end
    return true
end
These things are easily achievable yourself with basic knowledge, make sure you teach yourself and you can do things like this in a matter of minutes
go to the tutorial section if you want to learn lua
 
Last edited:
Back
Top