- Joined
- Aug 11, 2008
- Messages
- 2,628
- Solutions
- 2
- Reaction score
- 240
Hello guys.
I decided to release a few of my scripts ( Training Booths , Vocation Booths , Teleportatin Spell ). These scripts were only tested on TFS Alpha 3.
Training Booths
What you need to do is to add an action id of 9001 (north) / 9002 (east) / 9003 (south) / 9004 (west) to whatever door you'd like. No need to add trainers through mapeditor as it'll summon two "Trainers" manually everytime someone enters the booth. Whenever someone leaves, the "Trainers" will disapear. You cannot enter the room whenever someone else uses it. Other then that, it also saves the name of the last player who used the booth at the door.
data/actions/scripts/booths/training/east.lua
data/actions/scripts/booths/training/south.lua
data/actions/scripts/booths/training/west.lua
data/actions/scripts/booths/training/north.lua
data/actions/actions.xml
There you go, have fun with it!
I decided to release a few of my scripts ( Training Booths , Vocation Booths , Teleportatin Spell ). These scripts were only tested on TFS Alpha 3.
Training Booths
What you need to do is to add an action id of 9001 (north) / 9002 (east) / 9003 (south) / 9004 (west) to whatever door you'd like. No need to add trainers through mapeditor as it'll summon two "Trainers" manually everytime someone enters the booth. Whenever someone leaves, the "Trainers" will disapear. You cannot enter the room whenever someone else uses it. Other then that, it also saves the name of the last player who used the booth at the door.
data/actions/scripts/booths/training/east.lua
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Define positions.
local charPos = getCreaturePosition(cid)
local doorPos = getThingPos(item.uid)
local monkOne = {x = doorPos.x + 2, y = doorPos.y - 1, z = doorPos.z}
local monkTwo = {x = doorPos.x + 2, y = doorPos.y + 1, z = doorPos.z}
local checkPlayer = {x = doorPos.x + 1, y = doorPos.y, z = doorPos.z, stackpos = 253}
-- Define directions.
local newDir = 1
local oldDir = 3
-- Check where the player is located at.
if ( charPos.x == doorPos.x - 1 and charPos.z == doorPos.z ) then
-- Check if someone already uses the training booth.
if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
doSendMagicEffect(getCreaturePos(cid), 2)
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, newDir)
-- Summon training monks.
doSummonCreature("Trainer", monkOne)
doSummonCreature("Trainer", monkTwo)
end
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, oldDir)
-- Remove training monks.
doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
-- Send magic effect.
doSendMagicEffect(monkOne, 2)
doSendMagicEffect(monkTwo, 2)
-- Define last character.
local charName = getCreatureName(cid)
doSetItemSpecialDescription(getThingfromPos(doorPos).uid, "Last one to use this booth was player:\n" .. charName .. ".")
end
return TRUE
end
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Define positions.
local charPos = getCreaturePosition(cid)
local doorPos = getThingPos(item.uid)
local monkOne = {x = doorPos.x - 1, y = doorPos.y + 2, z = doorPos.z}
local monkTwo = {x = doorPos.x + 1, y = doorPos.y + 2, z = doorPos.z}
local checkPlayer = {x = doorPos.x, y = doorPos.y + 1, z = doorPos.z, stackpos = 253}
-- Define directions.
local newDir = 2
local oldDir = 0
-- Check where the player is located at.
if ( charPos.y == doorPos.y - 1 and charPos.z == doorPos.z ) then
-- Check if someone already uses the training booth.
if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
doSendMagicEffect(getCreaturePos(cid), 2)
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, newDir)
-- Summon training monks.
doSummonCreature("Trainer", monkOne)
doSummonCreature("Trainer", monkTwo)
end
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, oldDir)
-- Remove training monks.
doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
-- Send magic effect.
doSendMagicEffect(monkOne, 2)
doSendMagicEffect(monkTwo, 2)
end
return TRUE
end
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Define positions.
local charPos = getCreaturePosition(cid)
local doorPos = getThingPos(item.uid)
local monkOne = {x = doorPos.x - 2, y = doorPos.y - 1, z = doorPos.z}
local monkTwo = {x = doorPos.x - 2, y = doorPos.y + 1, z = doorPos.z}
local checkPlayer = {x = doorPos.x - 1, y = doorPos.y, z = doorPos.z, stackpos = 253}
-- Define directions.
local newDir = 3
local oldDir = 1
-- Check where the player is located at.
if ( charPos.x == doorPos.x + 1 and charPos.z == doorPos.z ) then
-- Check if someone already uses the training booth.
if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
doSendMagicEffect(getCreaturePos(cid), 2)
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, newDir)
-- Summon training monks.
doSummonCreature("Trainer", monkOne)
doSummonCreature("Trainer", monkTwo)
end
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, oldDir)
-- Remove training monks.
doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
-- Send magic effect.
doSendMagicEffect(monkOne, 2)
doSendMagicEffect(monkTwo, 2)
end
return TRUE
end
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Define positions.
local charPos = getCreaturePosition(cid)
local doorPos = getThingPos(item.uid)
local monkOne = {x = doorPos.x - 1, y = doorPos.y - 2, z = doorPos.z}
local monkTwo = {x = doorPos.x + 1, y = doorPos.y - 2, z = doorPos.z}
local checkPlayer = {x = doorPos.x, y = doorPos.y - 1, z = doorPos.z, stackpos = 253}
-- Define directions.
local newDir = 0
local oldDir = 2
-- Check where the player is located at.
if ( charPos.y == doorPos.y + 1 and charPos.z == doorPos.z ) then
-- Check if someone already uses the training booth.
if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
doSendMagicEffect(getCreaturePos(cid), 2)
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, newDir)
-- Summon training monks.
doSummonCreature("Trainer", monkOne)
doSummonCreature("Trainer", monkTwo)
end
else
-- Teleport player.
doTeleportThing(cid, doorPos)
doMoveCreature(cid, oldDir)
-- Remove training monks.
doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
-- Send magic effect.
doSendMagicEffect(monkOne, 2)
doSendMagicEffect(monkTwo, 2)
end
return TRUE
end
data/actions/actions.xml
PHP:
<!-- Training Booths -->
<action actionid="9001" script="booths/training/north.lua" />
<action actionid="9002" script="booths/training/east.lua" />
<action actionid="9003" script="booths/training/south.lua" />
<action actionid="9004" script="booths/training/west.lua" />