• 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 HELP event onKill

Mizakinha

New Member
Joined
Apr 18, 2021
Messages
38
Reaction score
4
I'm trying to get a module from a server to put on mine. I even managed to put the module in and make it work. It was a Dungeon system.

In the dungeon we have a certain amount of monsters, and when the player defeats them all, a boss should spawn. This check to know when all the monsters are killed and to have the boss spawn is done through the kill event.

The problem is that the server from which I got the module has the "kill" event type, but my server doesn't. Now I can't make the boss spawn. How do I add the kill event type to my server? Or maybe, would it be possible to adapt the code to be of another type instead of the kill event type, maybe death?

The script is this:


LUA:
function onKill(cid, target, lastHit)
  local name = getCreatureName(target)
  if (not isSummon(target) and not getPokemonSummon(target)) then
    if isPlayer(cid) and (lastHit) then
      local value = Dz.getPlayerStorage(cid)
      print(value.state, value.diff, value.mapId, value.roomId)
      if value.state == DzStateBattle then
        local Map = Dz.Diff[value.diff].Maps[value.mapId]
        local Room = Map.rooms[value.roomId]
        if getCreatureName(target) == Room.boss.name then
          Dz.teleportToPrize(value.diff, value.mapId, value.roomId)
        else
          Room.variable.pokemonCount = Room.variable.pokemonCount - 1
          if Room.variable.pokemonCount == 0 then
            table.insert(Room.variable.pokemons, doCreateMonster(Room.boss.name, Room.boss.pos))
          end
          for _, name in pairs(Room.variable.members) do
            local player = getPlayerByName(name)
            if isPlayer(player) then
              doSendPlayerExtendedOpcode(player, Dz.Opcode,
                json.encode({ protocol = "pokemoncount", count = Room.variable.pokemonCount }))
            end
          end
        end
      end
    end
    doQuestDefeat(cid, name)
    if (lastHit) then
      RangerClub.onPlayerKill(cid, name)
      --            HalloweenEvent.onPlayerKill(cid, target, lastHit)
      -- AnniversaryEvent.onPlayerKill(cid, target, lastHit)
      --EasterEvent.ThisIsEaster.onPlayerKill(cid, target, lastHit)
      --            ChristmasEvent.onPlayerKill(cid, target, lastHit)
    end
  end
  return true
end
 
Hey @Mizakinha ,
Could you provide more info on the server you are using?

Using onDeath() may work, but you will have to register that event in the monsters that you want to. Is not optimal but will do the trick.

However, if you can provide a github link to the server engine you are using we can look at better options.
 
Hello, @zyzz7omg ! Thank you in advance for trying to help.
I don't have a link to the projects on github, but I'll leave the link from where I downloaded them here.

This is the server where I got the dungeon system from: Poke Jornadas. The module is game_dungeon.

This is the server I'm using as a base to make mine, which is where I'm trying to place the system I got from the other: Poke Numb

I tried using onDeath(), but that didn't work either. Note that on this server that I am using as a base for all the monsters' xml files there is this event:
LUA:
<script>
<event name="Spawn"/>
</script>.
Is it possible to put both events at the same time, Death together with Spawn?

I await your return.
 
Last edited:
Back
Top