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

Solved Help change script

dervin13

Active Member
Joined
Apr 26, 2008
Messages
459
Solutions
1
Reaction score
28
Hi, someone know and can help me to transform this script to tfs 1.2??

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local newPosition = {x=860, y=754, z=7}
        if item.actionid == 32263 then
           queststatus = getPlayerStorageValue(cid,12904)
           if queststatus == -1 then
                        doPlayerAddItem(cid, 2433, 1)
               doPlayerSendTextMessage(cid,22,"You have found a item.")
setPlayerStorageValue(cid,12904,1)
                doTeleportThing(cid, newPosition, TRUE)
                doSendMagicEffect(newPosition, CONST_ME_TELEPORT)
                doSendMagicEffect(fromPosition, CONST_ME_POFF)
                doCreatureSay(cid, "Grrrr.", TALKTYPE_ORANGE_1)
           else
               doPlayerSendTextMessage(cid,22,"You already take this reward.")
                doTeleportThing(cid, newPosition, TRUE)
                doSendMagicEffect(newPosition, CONST_ME_TELEPORT)
                doSendMagicEffect(fromPosition, CONST_ME_POFF)
                doCreatureSay(cid, "Grrrr.", TALKTYPE_ORANGE_1)
        end
        return TRUE
end end

It's a script that when the player open the chest he get the item and is teleported automaticaly getting the storage value
 
Change the 22 in the textmessage to any of these.
Code:
MESSAGE_STATUS_CONSOLE_RED
MESSAGE_EVENT_ORANGE
MESSAGE_STATUS_CONSOLE_ORANGE
MESSAGE_STATUS_WARNING
MESSAGE_EVENT_ADVANCE
MESSAGE_EVENT_DEFAULT
MESSAGE_STATUS_DEFAULT
MESSAGE_INFO_DESCR
MESSAGE_STATUS_SMALL
MESSAGE_STATUS_CONSOLE_BLUE
If you want to change the TFS 0.2 functions to TFS 1.2 functions you can use the compat.lua as example.
For example the function getPlayerStorageValue.
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L215
Code:
queststatus = player:getStorageValue(12904)


Others.
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L405
Code:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found an item.")


https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L366
Code:
player:setStorageValue(12904, 1)


https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L824
Code:
player:teleportTo(Position(860, 754, 7), false)


https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L585
Code:
fromPosition:sendMagicEffect(CONST_ME_POFF)


https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L178
Code:
player:say("Grrrr.", TALKTYPE_MONSTER_SAY)


And change cid to player in function onUse.
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
Last edited:
Back
Top