MadMOOK
Hoo
- Joined
- Apr 20, 2011
- Messages
- 802
- Reaction score
- 43
Ok, soo..
In this script, the player uses a lever and creates a teleport.
Not just any teleport! You can choose how many people can enter the TP before it disapears. Also there is a global storage on the lever, so whoever used the tp last can have the area to themselves for set amount of time. Lets begin!
When you add your lever in map editor put uniqueID 12710 on it.
Actions/QuestTPlever.lua
Movements/questTp.lua
In this script, the player uses a lever and creates a teleport.
Not just any teleport! You can choose how many people can enter the TP before it disapears. Also there is a global storage on the lever, so whoever used the tp last can have the area to themselves for set amount of time. Lets begin!
When you add your lever in map editor put uniqueID 12710 on it.
Code:
-- Add this to actions.xml!
<action uniqueid="12710" event="script" value="questTPlever.lua"/>
-- Add this to movements.xml!
<movement type="StepIn" uniqueid="5002" event="script" value="questTP.lua"/>
Actions/QuestTPlever.lua
Code:
--[0]By Mad MOOK][0]--
local config = {
TPCREpos = {x = 2058, y = 1992, z = 12}, -- where tp is created
TPTOpos = {x = 2079, y = 1992, z = 11}, -- where tp takes you
PEOPLE = 2, -- how many people can go in tp before close
tpID= 1387, -- item id of tp
STORAGE = 9855, -- duh
time = 300 -- time in seconds before lever can be used again
}
-- No need to EDIT BELOW. Unless you change the actionID because its occupied by something else OR another lever for a differant quest, that is all.
function onUse(cid, item, fromPosition, itemEx, toPosition)
local storage = config.STORAGE
if getGlobalStorageValue(storage) >= os.time() then
doPlayerSendCancel(cid, "You need to wait "..globalexhaustion.get(storage).." seconds before you can use lever for this instance.")
else
local pplAllowedIN = config.PEOPLE
local thing = doCreateTeleport(config.tpID, config.TPTOpos, config.TPCREpos)
doItemSetAttribute(thing, "description", 'Only '..pplAllowedIN..' people can enter this instance.')
doItemSetAttribute(thing, "aid", 502+pplAllowedIN)
doItemSetAttribute(thing, "uid", 5002)
globalexhaustion.set(storage, config.time)
if item.itemid == 1945 then
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 then
doTransformItem(item.uid, 1945)
end
end
return true
end
Movements/questTp.lua
Code:
local STORAGE = 9855
function onStepIn(cid, item, position, fromPosition)
local stor = STORAGE
if item.actionid > 502 then
doItemSetAttribute(item.uid, "description", 'Only 2 people can enter this instance.')
doItemSetAttribute(item.uid, "aid", item.actionid-1)
elseif item.actionid == 502 then
doBroadcastMessage("The portal is closed for "..globalexhaustion.get(stor).." seconds.", MESSAGE_EVENT_ADVANCE)
doSendMagicEffect(position, 2)
doRemoveItem(item.uid, 1)
end
return true
end