J.Dre
Unity Games
Information:
This is a widely requested script. I decided to make a thread and properly tag it, allowing members to find it more easily while searching.
Tested and working on TFS 0.3.7. May not work for TFS 0.2.
How it works:
You simply add a monster to the table and kill the monster to create a portal.
Update Log:
For TFS 0.3.7:
data/creaturescripts/scripts/login.lua
data/creaturescripts/creaturescripts.xml
data/creaturescripts/scripts/script.lua
For TFS 0.3.6:
Warning: You may need to change "TALKTYPE_MONSTER" to "TALKTYPE_ORANGE_1".
This is a widely requested script. I decided to make a thread and properly tag it, allowing members to find it more easily while searching.
Tested and working on TFS 0.3.7. May not work for TFS 0.2.
How it works:
You simply add a monster to the table and kill the monster to create a portal.
Update Log:
- v1.0: Initial Release
* The initial release of the script.
- v1.1: Bug Fix
* Repaired an issue with the teleport not disappearing.
* Repaired an issue with the timer.
- v2.0: Script Update
* Updated the script with new features, including but not limited to a 'doSendAnimatedText' function for a countdown effect.
- v2.01: Bug Fix
* Removed an extra "and" on line 27 of the 0.3.6 version.
- v1.0: Initial Release
For TFS 0.3.7:
data/creaturescripts/scripts/login.lua
Code:
registerCreatureEvent(cid, "Killer")
data/creaturescripts/creaturescripts.xml
Code:
<event type="kill" name="Killer" event="script" value="script.lua"/>
data/creaturescripts/scripts/script.lua
Code:
local config = {
useCountdown = true -- true or false
}
local t = {
-- Monseter names must be lowercase.
["dog"] = {
toPos = 'Thais', -- enter a position OR a town's name \\ toPos = {x = 100, y = 100, z = 7} //
createPos = {x = 100, y = 100, z = 7, stackpos = 0},
time = 10, -- seconds until the TP is removed
msg = "You have taken my life!" -- the message the monster says upon death
},
["cat"] = {
toPos = 'Venore',
createPos = {x = 100, y = 100, z = 7, stackpos = 0},
time = 10, -- seconds until the TP is removed
msg = "You have taken my life!" -- the message the monster says upon death
}
}
local function remove(position)
local k = getTileItemById(position, 1387).uid
return k > 0 and doRemoveItem(k), doSendMagicEffect(position, CONST_ME_POFF)
end
local function doSendAnimatedText(pos, text, color, cid) -- by J.Dre
if tonumber(text) then
text = tonumber(text)
if cid and isPlayer(cid) then
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
else
local t = getSpectators(pos, 7, 5, false)
if t then
for _, cid in ipairs(t) do
if isPlayer(cid) then
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
end
end
end
end
else
if cid and isCreature(cid) then
doCreatureSay(cid, text, TALKTYPE_MONSTER)
else
local t = getSpectators(pos, 7, 5, false)
if t then
for _, cid in ipairs(t) do
if isPlayer(cid) then
doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
end
end
end
end
end
end
function onKill(cid, target, damage, flags)
local v = t[string.lower(getCreatureName(target))]
if(v and (damage == true or bit.band(flags, 1) == 1) and isMonster(target)) then
doCreatureSay(cid, v.msg, TALKTYPE_MONSTER, nil, nil, getCreaturePosition(target))
doSendMagicEffect(v.createPos, CONST_ME_ENERGYAREA)
doCreateTeleport(1387, type(v.toPos) == 'table' and v.toPos or getTownTemplePosition(getTownId(v.toPos)), v.createPos)
if(config.useCountdown) then
for j = 0, v.time do
local i = v.time - j
addEvent(doSendAnimatedText, j * 1000, v.createPos, i > 0 and tostring(i), MESSAGE_EVENT_DEFAULT)
end
end
addEvent(remove, v.time * 1000, v.createPos)
end
return true
end
Warning: You may need to change "TALKTYPE_MONSTER" to "TALKTYPE_ORANGE_1".
Code:
local config = {
useCountdown = true -- true or false
}
local t = {
["dog"] = {
toPos = 'Thais', -- enter a position OR a town's name \\ toPos = {x = 100, y = 100, z = 7} //
createPos = {x = 100, y = 100, z = 7, stackpos = 0},
time = 10, -- seconds until the TP is removed
msg = "You have taken my life!" -- the message the monster says upon death
},
["cat"] = {
toPos = 'Venore',
createPos = {x = 100, y = 100, z = 7, stackpos = 0},
time = 10, -- seconds until the TP is removed
msg = "You have taken my life!" -- the message the monster says upon death
},
}
local function remove(position)
local k = getTileItemById(position, 1387).uid
return k > 0 and doRemoveItem(k), doSendMagicEffect(position, CONST_ME_POFF)
end
function onKill(cid, target)
local v = t[string.lower(getCreatureName(target))]
if(v and isMonster(target)) then
doCreatureSay(cid, v.msg, TALKTYPE_MONSTER, nil, nil, getCreaturePosition(target))
doSendMagicEffect(v.createPos, CONST_ME_ENERGYAREA)
doCreateTeleport(1387, type(v.toPos) == 'table' and v.toPos or getTownTemplePosition(getTownId(v.toPos)), v.createPos)
if(config.useCountdown) then
for j = 0, v.time do -- By J.Dre
local i = v.time - j
addEvent(doSendAnimatedText, j * 1000, v.createPos, i > 0 and tostring(i), TEXTCOLOR_WHITE)
end
end
addEvent(remove, v.time * 1000, v.createPos)
end
return true
end
Last edited: