Greetings everyone!
Today I started scripting my own annihilator. It took me quite a while to get this working halfway, haha.
This is what I have now:
I have a lever, if you pull it you get teleported to the annihilator room, 6 demons spawn aswell. You kill them and go through an exp door which sets off a timer to change a storageValue (the value handles that noone can pull the lever while another team is still inside). You pick your reward and leave. The timer will after a define ammount of time automatically reset the storageValue set by the exp door aswell as flipping back the switch.
The whole storageValue part works fine, noone can flip the lever unless someone of the team who's currently doing the quest walks through the exp door to set off the timer. Quest rewards and a playerStorage are scripted in a different file. I have scripted this whole thing so you can do the actual quest numerous times but only get a reward once. I also still have to add a timer to automatically reset the quest in case everyone on the team dies.
But there's some problems I am facing here:
All the if cases I defined at the start seem to be ignored or scripted wrongly (those don't give me an error in the console, though) because you can pull the lever no matter where you stand (supposed to be working only if you're standing on one of the 4 tiles making it impossible to reset the quest since noone can set off the exp door timer because the quest is activated but noone is teleported in) and you can flip the switch even if you are alone (it's supposed to be 4 players only; it's just giving me a "doTeleportThing: cannot find Thing" error message).
Furthermore, the doRemoveCreature lines don't seem to work either. They are supposed to remove demons players may not have killed (it's giving me a "doRemoveCreature: cannot find Creature" error message for ALL SIX creatures, even if I just kill the 2 in front).
Any help is greatly appreciated. With explanations if you can. I'll learn from it I hope. ^^
Today I started scripting my own annihilator. It took me quite a while to get this working halfway, haha.
This is what I have now:
I have a lever, if you pull it you get teleported to the annihilator room, 6 demons spawn aswell. You kill them and go through an exp door which sets off a timer to change a storageValue (the value handles that noone can pull the lever while another team is still inside). You pick your reward and leave. The timer will after a define ammount of time automatically reset the storageValue set by the exp door aswell as flipping back the switch.
The whole storageValue part works fine, noone can flip the lever unless someone of the team who's currently doing the quest walks through the exp door to set off the timer. Quest rewards and a playerStorage are scripted in a different file. I have scripted this whole thing so you can do the actual quest numerous times but only get a reward once. I also still have to add a timer to automatically reset the quest in case everyone on the team dies.
But there's some problems I am facing here:
All the if cases I defined at the start seem to be ignored or scripted wrongly (those don't give me an error in the console, though) because you can pull the lever no matter where you stand (supposed to be working only if you're standing on one of the 4 tiles making it impossible to reset the quest since noone can set off the exp door timer because the quest is activated but noone is teleported in) and you can flip the switch even if you are alone (it's supposed to be 4 players only; it's just giving me a "doTeleportThing: cannot find Thing" error message).
Furthermore, the doRemoveCreature lines don't seem to work either. They are supposed to remove demons players may not have killed (it's giving me a "doRemoveCreature: cannot find Creature" error message for ALL SIX creatures, even if I just kill the 2 in front).
Any help is greatly appreciated. With explanations if you can. I'll learn from it I hope. ^^
PHP:
local player1Pos = {x = 544, y = 723, z = 10, stackpos = STACKPOS_TOP_CREATURE}
local player2Pos = {x = 545, y = 723, z = 10, stackpos = STACKPOS_TOP_CREATURE}
local player3Pos = {x = 546, y = 723, z = 10, stackpos = STACKPOS_TOP_CREATURE}
local player4Pos = {x = 547, y = 723, z = 10, stackpos = STACKPOS_TOP_CREATURE}
local newPosition1 = {x = 542, y = 714, z = 10, stackpos = 1}
local newPosition2 = {x = 543, y = 714, z = 10, stackpos = 1}
local newPosition3 = {x = 544, y = 714, z = 10, stackpos = 1}
local newPosition4 = {x = 545, y = 714, z = 10, stackpos = 1}
local demon1Position = {x = 542, y = 712, z = 10, stackpos = 1}
local demon2Position = {x = 544, y = 712, z = 10, stackpos = 1}
local demon3Position = {x = 543, y = 716, z = 10, stackpos = 1}
local demon4Position = {x = 545, y = 716, z = 10, stackpos = 1}
local demon5Position = {x = 546, y = 714, z = 10, stackpos = 1}
local demon6Position = {x = 547, y = 714, z = 10, stackpos = 1}
local leverPos = {x = 548, y = 723, z = 10, stackpos = 1}
function onUse(cid, item, frompos, item2, topos)
local player1 = getThingfromPos(player1Pos)
local player2 = getThingfromPos(player2Pos)
local player3 = getThingfromPos(player3Pos)
local player4 = getThingfromPos(player4Pos)
local timer = 10
if item.itemid == 1945 then
if player1.itemid > 0
and player2.itemid > 0
and player3.itemid > 0
and player4.itemid > 0 then
if isPlayer(player1.uid) == TRUE
and isPlayer(player2.uid) == TRUE
and isPlayer(player3.uid) == TRUE
and isPlayer(player4.uid) == TRUE then
if getPlayerLevel(player1.uid) >= 100
and getPlayerLevel(player2.uid) >= 100
and getPlayerLevel(player3.uid) >= 100
and getPlayerLevel(player4.uid) >= 100 then
setGlobalStorageValue(5000, 1)
else
setGlobalStorageValue(5000, 0)
end
end
end
if getGlobalStorageValue(5000) == 1 then
doSummonCreature("demon", demon1Position)
doSummonCreature("demon", demon2Position)
doSummonCreature("demon", demon3Position)
doSummonCreature("demon", demon4Position)
doSummonCreature("demon", demon5Position)
doSummonCreature("demon", demon6Position)
doSendMagicEffect(player1Pos, CONST_ME_POFF)
doSendMagicEffect(player2Pos, CONST_ME_POFF)
doSendMagicEffect(player3Pos, CONST_ME_POFF)
doSendMagicEffect(player4Pos, CONST_ME_POFF)
doTeleportThing(player1.uid, newPosition1, FALSE)
doTeleportThing(player2.uid, newPosition2, FALSE)
doTeleportThing(player3.uid, newPosition3, FALSE)
doTeleportThing(player4.uid, newPosition4, FALSE)
doSendMagicEffect(newPosition1, CONST_ME_ENERGYAREA)
doSendMagicEffect(newPosition2, CONST_ME_ENERGYAREA)
doSendMagicEffect(newPosition3, CONST_ME_ENERGYAREA)
doSendMagicEffect(newPosition4, CONST_ME_ENERGYAREA)
setGlobalStorageValue(5001, 1)
elseif getGlobalStorageValue(5000) == 0 then
doPlayerSendCancel(cid, "Sorry, not possible.")
end
elseif item.itemid == 1946 and getGlobalStorageValue(5001) == 1 then
doPlayerSendCancel(cid, "Sorry, not possible.")
doPlayerSendTextMessage(cid, 22, "There is already a team being annihilated! Please wait.")
return 1
elseif item.itemid == 8555 and getGlobalStorageValue(5001) == 1 then
doPlayerSendTextMessage(cid, 22, "Congratulations! Enjoy your reward.")
addEvent(resetLever, timer*1000)
end
end
function resetLever()
local lever = getThingFromPos(leverPos)
if getGlobalStorageValue(5001) == 1 then
doRemoveCreature("demon", demon1Position)
doRemoveCreature("demon", demon2Position)
doRemoveCreature("demon", demon3Position)
doRemoveCreature("demon", demon4Position)
doRemoveCreature("demon", demon5Position)
doRemoveCreature("demon", demon6Position)
doTransformItem(lever.uid, 1945)
setGlobalStorageValue(5001, 0)
end
end