• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Kill boss open door script help

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
746
Solutions
9
Reaction score
125
Hello, i've made this script on creaturesripts, set the storage value to the door, and the script on creaturescripts.xml but i dont know why its not working! Any help please? Im using TFS 1.2

door actionid=21983

boss door.lua
Code:
local config = {
     storage = 21983,
     exstorage = 21982,
}

function onDeath(cid, creature, damage, flags)
     if player:getStorageValue(config.storage) == tonumber(os.date("%w")) and player:getStorageValue(config.exstorage) > os.time() then
         return player:sendCancelMessage("You can't access the door until you kill the boss.")
     end
if getPlayerStorageValue(cid, 21983) == 0 and (bit.band(flags, 1)) == 1 and isMonster(target) and getCreatureName(cid).target == 'demon skeleton' then
         text = "You have received " .. text .. "."
         player:setStorageValue(config.storage, tonumber(os.date("%w")))
         player:setStorageValue(config.exstorage, os.time() + 1*60)
     end
     player:sendTextMessage(MESSAGE_INFO_DESCR, text)
     return true
end

creaturescript.xml
Code:
<event type="death" name="boss door" script="boss door.lua"/>
The script is supposed to let you open the door for 1 minute to everybody who hitted the boss, after 1 minute, you have to kill the boss again to let you open the door.
i've got a demon skeleton close to the door with a spawn. So, what im doing wrong?
 
Last edited:
2. Double Post:
- You have to wait 24 hours to post after your own post in a thread.
- There is 1 exception to this rule. If you solved a problem you can post it with the solution in the thread regardless of the amount of time between your new post and your last one.
If your thread isn't on the first page anymore by the time you solved it, set your thread prefix to solved and edit your first or last post and add the solution.

https://otland.net/threads/rules-for-the-support-board.217087/
 
player isnt declared yet.
Put: local player = Player(cid) at the beginning
And one more thing, add the event in your login.lua with the name: "boss door".
In every creaturescript that includes the player, must be added as event on the login.lua
 
I've got this now

boss door.lua
Code:
local config = {
     storage = 21983,
     exstorage = 21982,
}

local player = Player(cid)
function onDeath(cid, creature, damage, flags)
     if player:getStorageValue(config.storage) == tonumber(os.date("%w")) and player:getStorageValue(config.exstorage) > os.time() then
         return player:sendCancelMessage("You can't access the door until you kill the boss.")
     end
if getPlayerStorageValue(cid, 21983) == 0 and (bit.band(flags, 1)) == 1 and isMonster(target) and getCreatureName(cid).target == 'demon skeleton' then
         text = "You have received " .. text .. "."
         player:setStorageValue(config.storage, tonumber(os.date("%w")))
         player:setStorageValue(config.exstorage, os.time() + 1*60)
     end
     player:sendTextMessage(MESSAGE_INFO_DESCR, text)
     return true
end

on creaturescripts.xml

Code:
<event type="death" name="boss door" script="boss door.lua"/>

on login.lua

Code:
player:registerEvent("Boss door")

at the map door actionid = 21983

Nothing happens after i kill the demon skeleton.. no erros on console. Am i missing something here? shall i change something in the demon skeleton.xml?
 
I've got this now

boss door.lua
Code:
local config = {
     storage = 21983,
     exstorage = 21982,
}

local player = Player(cid)
function onDeath(cid, creature, damage, flags)
     if player:getStorageValue(config.storage) == tonumber(os.date("%w")) and player:getStorageValue(config.exstorage) > os.time() then
         return player:sendCancelMessage("You can't access the door until you kill the boss.")
     end
if getPlayerStorageValue(cid, 21983) == 0 and (bit.band(flags, 1)) == 1 and isMonster(target) and getCreatureName(cid).target == 'demon skeleton' then
         text = "You have received " .. text .. "."
         player:setStorageValue(config.storage, tonumber(os.date("%w")))
         player:setStorageValue(config.exstorage, os.time() + 1*60)
     end
     player:sendTextMessage(MESSAGE_INFO_DESCR, text)
     return true
end

on creaturescripts.xml

Code:
<event type="death" name="boss door" script="boss door.lua"/>

on login.lua

Code:
player:registerEvent("Boss door")

at the map door actionid = 21983

Nothing happens after i kill the demon skeleton.. no erros on console. Am i missing something here? shall i change something in the demon skeleton.xml?

You put "Boss door" instead "boss door"!! The name of the event should be the same that you put on creaturescripts <event type="death" name="boss door" script="boss door.lua"/>
 
You don't want to ever declare player outside the scope of an interface, besides cid isn't global its only local to onDeath.

So this is wrong.
Code:
local player = Player(cid)
function onDeath(cid, creature, damage, flags)

It should be defined like this.
Code:
function onDeath(cid, creature, damage, flags)
local player = Player(cid)
 
You don't want to ever declare player outside the scope of an interface, besides cid isn't global its only local to onDeath.

So this is wrong.
Code:
local player = Player(cid)
function onDeath(cid, creature, damage, flags)

It should be defined like this.
Code:
function onDeath(cid, creature, damage, flags)
local player = Player(cid)
You put "Boss door" instead "boss door"!! The name of the event should be the same that you put on creaturescripts <event type="death" name="boss door" script="boss door.lua"/>


Did both changes, and still getting nothing after killing the demon skeleton! could it be something wrong with my script? Im going crazy here! >.<
 
Did both changes, and still getting nothing after killing the demon skeleton! could it be something wrong with my script? Im going crazy here! >.<
You might have made the changes, but it doesn't mean you understand the changes you made.

Programming isn't just a matter of copying and pasting code or changing some values around until you have it working or almost working the way you want it to, it is about understanding how it works.

Please check out some of the tutorials online either at http://www.lua.org/pil/contents.html or http://tutorialspoint.com/lua/ for a better understanding of the language.
 
Back
Top