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

RevScripts Kill monster and get storage

Belfahar

New Member
Joined
Jul 21, 2016
Messages
25
Reaction score
3
Hello everyone!

The idea is that the player, when killing the Brokul, receives storage 640001 and each time he kills he receives the value +1 in this same storage. The message on the screen is just to confirm that the script works. But it is not working.

Lua:
local killingBrokul = CreatureEvent("killingBrokul")

function onMonsterKill(player, monster)
    local monsterName = monster:getName()
    if monsterName == "Brokul" then
        player:setStorageValue(640001, player:getStorageValue(640001) + 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You killed the boss Brokul.")
    end
end

function onCreatureDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    if killer:isPlayer() then
        onMonsterKill(killer, creature)
    end
end

function onStartup()
    registerCreatureEvent(CREATURE_EVENT_DEATH, "onCreatureDeath")
end

onStartup()
killingBrokul:register()
 
Solution
Lua:
local creatureEvent = CreatureEvent("killBossTest")
function creatureEvent.onKill(player, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end
    if target:getName() == "Brokul" then
        player:setStorageValue(640001, player:getStorageValue(640001) + 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You killed the boss Brokul.")
    end
    return true
end
creatureEvent:register()

local loginEvent = CreatureEvent("killBossTestLogin")
function loginEvent.onLogin(player)
    player:registerEvent("killBossTest")
    return true
end
loginEvent:register()
Lua:
local creatureEvent = CreatureEvent("killBossTest")
function creatureEvent.onKill(player, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end
    if target:getName() == "Brokul" then
        player:setStorageValue(640001, player:getStorageValue(640001) + 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You killed the boss Brokul.")
    end
    return true
end
creatureEvent:register()

local loginEvent = CreatureEvent("killBossTestLogin")
function loginEvent.onLogin(player)
    player:registerEvent("killBossTest")
    return true
end
loginEvent:register()
 
Last edited:
Solution
Lua:
local creatureEvent = CreatureEvent("killBossTest")
function creatureEvent.onKill(player, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end
    if target:getName() == "Brokul" then
        player:setStorageValue(640001, player:getStorageValue(640001) + 1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You killed the boss Brokul.")
    end
    return true
end
creatureEvent:register()

local loginEvent = CreatureEvent("killBossTestLogin")
function loginEvent.onLogin(player)
    player:registerEvent("killBossTest")
    return true
end
loginEvent:register()

works perfectly, thank you!
 
Back
Top