juansanchez
Intermediate OT User
- Joined
- Apr 2, 2015
- Messages
- 217
- Reaction score
- 129
Hey guys, i was wondering if anyone could help me improve this script.
I'm using TFS 0.3.7
I created this script from scratch, but i'm not very good with scripting.
One of the problems i found was: The script checks if the Oberon is still alive to remove it if someone doesn't kill it in time/dies, but if the player kills the Oberon, when the script checks for the monster i get an error saying Creature not found (obviously). And i can't think of an way to improve this.
Also, the player has to stay in the room for 6 minutes before he gets kicked, and if the players kill it fast that can be a bit annoying. But if i just make a teleport for the player to leave the room without some sort of storage, he gets all the way to the city, and the script teleports him back to the Oberon lever. I was thinking of some sort storage on the kick time or something, but i'm not really sure what to do.
Any suggestions/improvements?
And if anyone has some other suggestions not related to the ones i said, feel free to tell me so i can improve it.
I'm using TFS 0.3.7
I created this script from scratch, but i'm not very good with scripting.
One of the problems i found was: The script checks if the Oberon is still alive to remove it if someone doesn't kill it in time/dies, but if the player kills the Oberon, when the script checks for the monster i get an error saying Creature not found (obviously). And i can't think of an way to improve this.
Also, the player has to stay in the room for 6 minutes before he gets kicked, and if the players kill it fast that can be a bit annoying. But if i just make a teleport for the player to leave the room without some sort of storage, he gets all the way to the city, and the script teleports him back to the Oberon lever. I was thinking of some sort storage on the kick time or something, but i'm not really sure what to do.
Any suggestions/improvements?
And if anyone has some other suggestions not related to the ones i said, feel free to tell me so i can improve it.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local from, to = {x = 1635, y = 1574, z = 8}, {x = 1538, y = 1620, z = 8}
local newPos = {x = 1643, y = 1585, z = 8}
local afterPos = {x = 1634, y = 1604, z = 8}
local kickTime = 6 * 60 * 1000 -- 6 Minutes
local cooldown = 720000
local reset = 60
local storage = 10123
if getPlayerReset(cid) < reset then
doSendMagicEffect(getCreaturePosition(cid), 2)
return doPlayerSendTextMessage(cid,20, 'Voce precisa de '.. reset ..' resets ou mais.') -- Checks if the player has level to use the lever.
elseif getPlayerStorageValue(cid, storage) >= os.time() then
doPlayerSendTextMessage(cid,20, 'Voce precisa esperar 20 horas por tentativa. Faltam: ' .. getPlayerStorageValue(cid, storage) - os.time()..' segundos pra tentar novamente.') -- Checks if the player has already used the lever.
doSendMagicEffect(getCreaturePosition(cid), 2)
return false
else
for x = from.x, to.x do
for y = from.y, to.y do
local creature = getTopCreature({x = x, y = y, z = from.z})
if isPlayer(creature.uid) and creature.uid ~= 0 then
doSendMagicEffect(getCreaturePosition(cid), 2)
doPlayerSendTextMessage(cid,20,"Ja existe um jogador dentro da quest. Aguarde sua vez.") -- Checks if there is someone inside already.
return true
end
end
end
local monster = doSummonCreature("grand master oberon", {x = 1643, y = 1580, z = 8})
doTeleportThing(cid, newPos)
doPlayerSendTextMessage(cid,20,"Voce tem 5 minutos para matar o Grand Master Oberon. Apos 5 minutos a criatura ira sumir e voce sera teleportado.")
setPlayerStorageValue(cid, storage, os.time() + cooldown)
addEvent(doRemoveCreature, 5 * 60 * 1000, monster) -- 5 min
local function teleport()
doTeleportThing(cid, afterPos)
stopEvent(event)
return true
end
event = addEvent(teleport, kickTime)
return true
end
end
[code]