• 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!

Lua Killboss - add storage.

Dibis

Member
Joined
Dec 1, 2022
Messages
73
Reaction score
16
Location
POLAND
Hello.
I have this script, but not working.
If kill monster with name in table and player have table storage then set storage to...

Lua:
local config = {
    ["The Horned Fox"] = {storage = 91009, value = 1000},
    ["Necropharus"] = {storage = 91054, value = 1000},
    ["Tiquandas Revenge"] = {storage = 91029, value = 1000},
    ["Ron The Ripper"] = {storage = 91053, value = 1000},
    ["Demodras"] = {storage = 91022, value = 1000}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end
if getPlayerStorageValue(cid, monster.storage) == 999 then
         setPlayerStorageValue(cid, monster.storage, monster.value)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed a '..getCreatureName(target)..' one of a task boss.')
     end
     return true
end
 
Then increase maybe this amount onkill.
Add else and do somethink like this:

setStorage(cid, monster.storage, getStorage(cid, monster.storage)+1)

Or set this storage to 999 in another script.
 
Then increase maybe this amount onkill.
Add else and do somethink like this:

setStorage(cid, monster.storage, getStorage(cid, monster.storage)+1)

I need kill only one BOSS. If kill etc. "Necropharus".

If getPlayerStorageValue(cid, CONFIG) == 999 and if kill monster name in CONFIG then
setPlayerStorageValue (cid,CONFIG,1000)
 
This script is correct on my eye.. so if you tell me that this not working then you don't have request storage value or you don't have register event to player.

Ps. remove lower()
 
Last edited:
Idk, how it's not working, to get it work, you should have for example:
While killing "The Horned Fox" you need to have storage 91009 set to 999 (equal), after that if everything is ok, you should receive storage from bosses table bounded to "The Horned Fox".
btw. I suggest to make a habit to practice "early returns" (write what a given script does not accept in order to continue executing it), with early returns code looks more clean.

It might also not work because...
I don't know from what TFS version this exist but... so far I remember some distros need to register this event in login.lua or in monster.xml in <script></script> to make it work ...but I don't know what TFS u using and I'm not anymore much into older TFS than 1.2

Lua:
local bosses = {
  ["The Horned Fox"] = {storage = 91009, value = 1000},
  ["Necropharus"] = {storage = 91054, value = 1000},
  ["Tiquandas Revenge"] = {storage = 91029, value = 1000},
  ["Ron The Ripper"] = {storage = 91053, value = 1000},
  ["Demodras"] = {storage = 91022, value = 1000}
}

function onKill(cid, target)
  local boss = bosses[getCreatureName(target)]
  -- If target is not monster or not targetName is equal to that one in table or target is summon should prevent continueing script - so - target MUST be monster and his name MUST be equal to this in table and CAN'T be summon
  if not isMonster(target) or not boss or isSummon(target) then return true end
  -- If not have storage (from table) value equal to 999, prevent continue script
  if not (getPlayerStorageValue(cid, boss.storage) == 999) then return true end

  setPlayerStorageValue(cid, boss.storage, boss.value)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed a '.. getCreatureName(target) ..' one of a task boss.')
  return true
end
 
Last edited:
It just need to add an if statement in a loop in login.lua in creaturescripts.

Lua:
for i = 91009, 91013 do
if getPlayerStorageValue(cid, i) == -1 then
setPlayerStorageValue(cid, i, 999)
end
end
I also changed the bosse's storage to make it more comfortable. The range from 91009 to 91013. Do the same in the killing script.
 
Idk, how it's not working, to get it work, you should have for example:
While killing "The Horned Fox" you need to have storage 91009 set to 999 (equal), after that if everything is ok, you should receive storage from bosses table bounded to "The Horned Fox".
btw. I suggest to make a habit to practice "early returns" (write what a given script does not accept in order to continue executing it), with early returns code looks more clean.

It might also not work because...
I don't know from what TFS version this exist but... so far I remember some distros need to register this event in login.lua or in monster.xml in <script></script> to make it work ...but I don't know what TFS u using and I'm not anymore much into older TFS than 1.2

Lua:
local bosses = {
  ["The Horned Fox"] = {storage = 91009, value = 1000},
  ["Necropharus"] = {storage = 91054, value = 1000},
  ["Tiquandas Revenge"] = {storage = 91029, value = 1000},
  ["Ron The Ripper"] = {storage = 91053, value = 1000},
  ["Demodras"] = {storage = 91022, value = 1000}
}

function onKill(cid, target)
  local boss = bosses[getCreatureName(target)]
  -- If target is not monster or not targetName is equal to that one in table or target is summon should prevent continueing script - so - target MUST be monster and his name MUST be equal to this in table and CAN'T be summon
  if not isMonster(target) or not boss or isSummon(target) then return true end
  -- If not have storage (from table) value equal to 999, prevent continue script
  if not (getPlayerStorageValue(cid, boss.storage) == 999) then return true end

  setPlayerStorageValue(cid, boss.storage, boss.value)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed a '.. getCreatureName(target) ..' one of a task boss.')
  return true
end

Work perfect ! Thank You !!! <3
 
Back
Top