• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Some Scripts to Improved Bosses, Teleports...

Mariuskens

Sword Art Online 2D-MMORPG
Joined
Nov 21, 2008
Messages
1,009
Reaction score
119
Location
Spain
GitHub
Olimpotibia
Hello im starting this thread to build littlel list with some scripts writed here on this forum.
To start i need some scripts for my project Sword Art Online 2d so we can add more to all community.
This scripts major runs in Tfs 1.1 / Tfs 1.2 <<--
Lets go:

*Movements:
-Teleport creature when stepin "x" Uniqueid.
function onStepIn(player, item, pos)
if player:isPlayer() == true then
local newpos = {x = 123, y = 456, z = 7}
player:teleportThing(newpos)
sendMagicEffect(newpos, 12)
-- player:sendTextMessage(22, "Fui teletransportado!")
end
return true
end

*Actions:
- With "X" Storageid players can open door.
function onUse(player, item, fromPosition, target, toPosition, isHotkey)elseif isInArray(keys, itemId) then
local numberOfStorage = 1234
local newDoorId = 4321
local oldDoorId = 5678
if player:getStorageValue(numberOfStorage) >= 1 then
item:transform(newDoorId)
addEvent(function fecharSozinho(item)
item:transform(oldDoorId)
return true
end, 5000)
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce precisa ter concluido a missao dos poneis viados.")
end
return true
end

*Creatures:
-

*Creaturescripts:
- When Creature name "dead" get player "X" storageid.


Thnx for your time to help me and others to complete/share/write this scripts :p
 
Last edited:
Step-in:
Code:
function onStepIn(player, item, pos)
    if player:isPlayer() == true then
        local newpos = {x = 123, y = 456, z = 7}
        player:teleportThing(newpos)
        sendMagicEffect(newpos, 12)
        -- player:sendTextMessage(22, "Fui teletransportado!")
    end
    return true
end

Door example:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)elseif isInArray(keys, itemId) then
    local numberOfStorage = 1234
    local newDoorId = 4321
    local oldDoorId = 5678
    if player:getStorageValue(numberOfStorage) >= 1 then
        item:transform(newDoorId)
        addEvent(function fecharSozinho(item)
            item:transform(oldDoorId)
            return true
            end, 5000)
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Voce precisa ter concluido a missao dos poneis viados.")
    end
    return true
end
 
Last edited:
*Actions:
- With "X" Storageid players can open door.
This already exists in the default doors.lua script.
https://github.com/otland/forgottenserver/blob/master/data/actions/scripts/other/doors.lua#L4

For the stepin script.
Code:
sendMagicEffect(newpos, 12)
-- player:sendTextMessage(22, "Fui teletransportado!")
If you look at compat.lua, you can see there how it's used.
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L584
So that should be like this.
Code:
Position(newpos):sendMagicEffect(CONST_ME_MAGIC_BLUE)
The textmessage is right besides the number part, that will give a debug.
So it should be like this.
Code:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Fui teletransportado!")

Can you give more information about the creaturescript?
If it should only give a storage when a player kills a monster you can check for the monster name and add the storage in a kill script (function onKill).
Code:
if target:getName() == "Skunk" and player:getStorageValue(8847) == -1 then
     player:setStorageValue(8847, 1)
end
Also always good to check if the target is a player or monster, incase there is a player who gives himself the same name as that monster.
 
This already exists in the default doors.lua script.
https://github.com/otland/forgottenserver/blob/master/data/actions/scripts/other/doors.lua#L4

For the stepin script.
Code:
sendMagicEffect(newpos, 12)
-- player:sendTextMessage(22, "Fui teletransportado!")
If you look at compat.lua, you can see there how it's used.
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L584
So that should be like this.
Code:
Position(newpos):sendMagicEffect(CONST_ME_MAGIC_BLUE)
The textmessage is right besides the number part, that will give a debug.
So it should be like this.
Code:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Fui teletransportado!")

Can you give more information about the creaturescript?
If it should only give a storage when a player kills a monster you can check for the monster name and add the storage in a kill script (function onKill).
Code:
if target:getName() == "Skunk" and player:getStorageValue(8847) == -1 then
     player:setStorageValue(8847, 1)
end
Also always good to check if the target is a player or monster, incase there is a player who gives himself the same name as that monster.

Mandame un private / send me one privtmsge plx xd
 
Back
Top