legolas23
New Member
- Joined
- Jan 8, 2009
- Messages
- 537
- Reaction score
- 3
Hello
I just started to learn lua and I'm realsing my leverscript.
So just a small explaination how does it work.
If the player pull the lever he will be teleported to the room where some monsters spawn and he won't be able to use this lever anymore.
Here's the code:
Add it to ots directory/data/actions/scripts and save as lever.lua
And paste this somewhere in
ots directory/data/actions/actions.xml
Enjoy!
I just started to learn lua and I'm realsing my leverscript.
So just a small explaination how does it work.
If the player pull the lever he will be teleported to the room where some monsters spawn and he won't be able to use this lever anymore.
Here's the code:
Add it to ots directory/data/actions/scripts and save as lever.lua
Code:
---Lever Script by Legolas23---
function onUse(cid, item, fromPosition, itemEx, toPosition)
local creature1 = {x = 527, y = 310, z = 11, stackpos = 1} --- write your positions for creature1 to spawn
local creature2 = {x = 527, y = 310, z = 11, stackpos = 1} --- write your positions for creature2 to spawn
local creature3 = {x = 527, y = 310, z = 11, stackpos = 1} --- write your positions for creature3 to spawn
local creature4 = {x = 527, y = 310, z = 11, stackpos = 1} --- write your positions for creature4 to spawn
local creature1name = Demon ---- name of creatures to spawn
local creature2name = Demon
local creature3name = Demon
local creature4name = Demon
local tpPos = {x = 527, y = 310, z = 11, stackpos = 1} --- position where the player will be teleported
if item.itemid == 1945 then
if getPlayerLevel(cid) >= 800 then
queststatus = getPlayerStorageValue(cid,33933)
if queststatus == -1 then
doCreateMonster(creature1name,creature1)
doCreateMonster(creature2name,creature2)
doCreateMonster(creature3name,creature3)
doCreateMonster(creature4name,creature4)
doTeleportThing(cid,tpPos)
setPlayerStorageValue(cid,33933,1)
doPlayerSendTextMessage(cid,22,"Welcome to the hell!!") ---- message when you pull the lever
else
doPlayerSendTextMessage(cid,22,"You have already pulled this lever!") --- message when you have already pulled it
end
end
elseif item.itemid == 1946 then
if getPlayerLevel(cid) >= 800 then
queststatus = getPlayerStorageValue(cid,33933)
if queststatus == -1 then
doCreateMonster(creature1name,creature1)
doCreateMonster(creature2name,creature2)
doCreateMonster(creature3name,creature3)
doCreateMonster(creature4name,creature4)
doTeleportThing(cid,tpPos)
setPlayerStorageValue(cid,33933,1)
doPlayerSendTextMessage(cid,22,"Welcome to the hell!!") ---- message when you pull the lever
doTransformItem(item.uid, 1945)
else
doPlayerSendTextMessage(cid,22,"You have already pulled this lever!") --- message when you have already pulled it
end
end
return TRUE
end
end
And paste this somewhere in
ots directory/data/actions/actions.xml
Code:
<action uniqueid="33933" event="script" value="lever.lua"/>
Enjoy!
