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

Remove storage

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
135
Location
Sweden
Code:
function onKill(cid, target, damage, flags)
   for v, k in pairs(t) do
     local master = getCreatureMaster(target)
     if(master and master ~= target) then
       return true
     end
     if(bit.band(flags, 1) == 1 and isMonster(target) and isInArray(v, getCreatureName(target))) then
       if getCreatureStorage(cid, k.y_storage) < 1 then
         doCreatureSetStorage(cid, k.y_storage, 1)
         doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)
       end
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated " .. getCreatureName(target):lower() .. "!")
       addEvent(teleport_loop, 1000, cid, 15)
     end
   end
   return true
end

like
Lua:
doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) - 1)
?
I dont even know what the Y storage is doing.. i didnt write the code :p
 
Last edited:
Solution
E
I suppose the y storage is set to 1 to tell you killed the creature and the x storage is the amount of times you did it, os if you want to remove the y storage just change this:
Lua:
       if getCreatureStorage(cid, k.y_storage) < 1 then
         doCreatureSetStorage(cid, k.y_storage, 1)
         doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)
       end
to this:
Lua:
doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)
I suppose the y storage is set to 1 to tell you killed the creature and the x storage is the amount of times you did it, os if you want to remove the y storage just change this:
Lua:
       if getCreatureStorage(cid, k.y_storage) < 1 then
         doCreatureSetStorage(cid, k.y_storage, 1)
         doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)
       end
to this:
Lua:
doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)
 
Solution
I suppose the y storage is set to 1 to tell you killed the creature and the x storage is the amount of times you did it, os if you want to remove the y storage just change this:
Lua:
       if getCreatureStorage(cid, k.y_storage) < 1 then
         doCreatureSetStorage(cid, k.y_storage, 1)
         doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)
       end
to this:
Lua:
doCreatureSetStorage(cid, k.x_storage, getCreatureStorage(cid, k.x_storage) + 1)

Works great, thank you! :)
 
I will give you this, its not tested because I don't work with anything under TFS 1.x anymore but your code is unsafe and is messy.

Lua:
local t = {
   ["Demodras"] = 55555,
   ["The Old Widow"] =  66666,
   ["Dracola"] = 77777,
   ["Rotworm Queen"] = 88888   
}

local teleport_position = {x = 1000, y = 1000, z = 7} -- where player will be sent after killing boss

function onKill(cid, target, damageMap, flags)
    local BOSS = t[target:getName()]
    
    if not BOSS then return true end
    
    doCreatureSetStorage(cid, BOSS, getCreatureStorage(cid, BOSS) + 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated " ..getCreatureName(target).. "!")
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You will be teleported out in 5 seconds.")
    addEvent(teleportBossPlayer, 5000, getCreatureName(cid))
return true
end

function teleportBossPlayer(name)
    local player = getPlayerByName(name)
    
    if isPlayer(player) then
        doTeleportThing(player, teleport_position)
        doSendMagicEffect(getPlayerPosition(player), CONST_ME_TELEPORT)
    end
end
 
I will give you this, its not tested because I don't work with anything under TFS 1.x anymore but your code is unsafe and is messy.

Lua:
local t = {
   ["Demodras"] = 55555,
   ["The Old Widow"] =  66666,
   ["Dracola"] = 77777,
   ["Rotworm Queen"] = 88888 
}

local teleport_position = {x = 1000, y = 1000, z = 7} -- where player will be sent after killing boss

function onKill(cid, target, damageMap, flags)
    local BOSS = t[target:getName()]
  
    if not BOSS then return true end
  
    doCreatureSetStorage(cid, BOSS, getCreatureStorage(cid, BOSS) + 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated " ..getCreatureName(target).. "!")
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You will be teleported out in 5 seconds.")
    addEvent(teleportBossPlayer, 5000, getCreatureName(cid))
return true
end

function teleportBossPlayer(name)
    local player = getPlayerByName(name)
  
    if isPlayer(player) then
        doTeleportThing(player, teleport_position)
        doSendMagicEffect(getPlayerPosition(player), CONST_ME_TELEPORT)
    end
end

Thats very kind of you. I got this error when i kill it tho.

Lua:
[18:16:54.424] [Error - CreatureScript Interface]
[18:16:54.428] data/creaturescripts/scripts/taskboss/boss_kill_script.lua:onKill
[18:16:54.433] Description:
[18:16:54.435] ...reaturescripts/scripts/taskboss/boss_kill_script.lua:11: attempt to index local 'target' (a number value)
[18:16:54.440] stack traceback:
[18:16:54.441]  ...reaturescripts/scripts/taskboss/boss_kill_script.lua:11: in function <...reaturescripts/scripts/taskboss/boss_kill_script.lua:10>

I suppose it should be like
Lua:
getMonsterInfo(name)
doSummonMonster(cid, name)
getCreatureByName(name)

Or something like that?
 
Last edited:
Back
Top