Jump to content

[HELP] onBotWasted


Recommended Posts

Hello, I want to know how can I detect when a bot dies? But, not when someone kills it, only when it dies, for example when it jumped off a cliff, or another bot killed it, i mean,  only detect when it dies in a general way and give a reward by dropping  a pickup.

Link to comment
2 hours ago, Lalalu said:

Hello, I want to know how can I detect when a bot dies? But, not when someone kills it, only when it dies, for example when it jumped off a cliff, or another bot killed it, i mean,  only detect when it dies in a general way and give a reward by dropping  a pickup.

function onBotWasted(totalAmmo, killer, killerWeapon, bodypart, stealth)
  -- This function will be triggered when the bot dies.
  -- totalAmmo: total ammo of the bot at the time of death
  -- killer: the player who killed the bot
  -- killerWeapon: the weapon used by the player to kill the bot
  -- bodypart: the body part of the bot that was hit by the killing shot
  -- stealth: whether the bot was killed while in stealth mode

  -- Get the source element of the bot
  local bot = source

  -- React to the bot's death
  -- For example, you can create an object or pickup after the bot dies
  -- You can use the createPickup function to create a pickup
  createPickup(bot.position.x, bot.position.y, bot.position.z, 3, 2, 100)

end

-- Define the "onBotWasted" event to listen for bot deaths
addEvent("onBotWasted", true)
addEventHandler("onBotWasted", getRootElement(), onBotWasted)

For the second code snippet:

 
 
-- Define a table for bots
local bots = {}

-- Bot creation function
function createBot(x, y, z)
  -- Create a bot
  local bot = createPed(0, x, y, z)
  
  -- Set the bot's health value
  setElementHealth(bot, 100)

  -- Add the bot's ID to a table
  bots[bot] = true
  
  --

 

Link to comment

  

4 hours ago, Lalalu said:

Hello, I want to know how can I detect when a bot dies? But, not when someone kills it, only when it dies, for example when it jumped off a cliff, or another bot killed it, i mean,  only detect when it dies in a general way and give a reward by dropping  a pickup.

    onPedWasted

             or

onClientPedWasted

Edited by SciptNovato
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...