Jump to content

[HELP]isPedDead


Bahoma

Recommended Posts

hi guys , i m working on shooting mission script , for that i created some Ped ( bots ) , my problem is that i wanted to use isPedDead to check if the Ped is dead or no , if the Ped is dead , the player will take 1k.

I need to create the Ped in Client or server side ? i tried a lot of way but i failed a lot of time , i hope that one of you will help me , thx

function checkkills () 
criminal5 = createPed ( 28, 293.54177856445,-147.95318603516,1004.0625 ,-90 )  
setElementFrozen   (criminal5 ,true) 
if isPedDead(criminal5) then  givePlayerMoney ( thePlayer, 1000 ) 
end 
end 
addEvent("checkkills",true) 
addEventHandler("checkkills",getRootElement(),checkkills) 
  

I trigged the event from client side , Ped will be created , but when i kill him nothing will happen.

Link to comment
So if you want sync ped for all players you should make it on server side. Also if you want detect if ped wasted use server side event onPedWasted.

i want to show the created ped only for client , but i failed .... that's why i moved it to server side .

thx for the help but "onPedWasted" must used after closing the function right ? and i created the ped into the functions , can you give me an example pliz

Link to comment
function createCriminal( res ) 
    criminal5 = createPed( 28, 293.54177856445, -147.95318603516,1004.0625, -90 ) 
    setElementFrozen( criminal5, true ) 
end 
addEventHandler("onResourceStart", resourceRoot, createCriminal) 
  
function checkKills( _, thePlayer ) 
    if ( source == criminal5 ) then  
         
        givePlayerMoney( thePlayer, 1000 ) 
    end 
end 
addEventHandler("onPedWasted", root, checkKills) 

There, I changed it all to server-side.

Link to comment
function createCriminal( res ) 
    criminal5 = createPed( 28, 293.54177856445, -147.95318603516,1004.0625, -90 ) 
    setElementFrozen( criminal5, true ) 
end 
addEventHandler("onResourceStart", resourceRoot, createCriminal) 
  
function checkKills( _, thePlayer ) 
    if ( source == criminal5 ) then  
         
        givePlayerMoney( thePlayer, 1000 ) 
    end 
end 
addEventHandler("onPedWasted", root, checkKills) 

There, I changed it all to server-side.

thank you very much Dev , but if i create another ped , how to check if those 2 ped is dead or no ? i tried :

if ( source == criminal1 )and( source == criminal2 ) then 

but i failed

Link to comment
if source == criminal1 and isPedDead( criminal2 ) or source == criminal2 and isPedDead( criminal1 ) then 
    -- code 
end 

in event onPedWasted.

thx a lot bro :D emm sorry but i have a last request , if i want to add a new ped , that mean the 3 ped must be dead not only 2 to take the money ? how to add it ? and thx a lot again for you'r help

Link to comment
You can just use
addEventHandler("onPedWasted",criminal5,checkKills) 

Which eliminates the need to check whether it was the criminal, and is a lot more efficient as the function doesn't trigger for every ped that dies.

but i want it to check many ped if they are killed or no , I prefer using Dev and Kenix way I think is better

Link to comment
You can just use
addEventHandler("onPedWasted",criminal5,checkKills) 

Which eliminates the need to check whether it was the criminal, and is a lot more efficient as the function doesn't trigger for every ped that dies.

but i want it to check many ped if they are killed or no , I prefer using Dev and Kenix way I think is better

  
  
  
  
function checkKills( _, thePlayer ) 
    if isPedDead ( criminal1) and isPedDead ( criminal2) and source == criminal3 then  
        givePlayerMoney( thePlayer, 1000 ) 
    end 
end 
addEventHandler("onPedWasted", root, checkKills) 
  
  

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...