Jump to content

Dead Peds


Bonsai

Recommended Posts

  • Moderators

You sure all peds are serverside?

As far I know they are all always destroy able. I have build something similar to slotboth and I never had any problems with it.

How do you save those peds? Because holding the registration at moment of creation is the best way to destroy them all without any problems.

Also getElementHealth returns better information if a ped is dead then isPedDead. (depends if you are freezing your peds or disable their col)

Link to comment

Peds are created by spawnPlayer, get warped into vehicles, normal race stuff.

At some point they either drown, explode or just get killed by killPed.

I got a function attached to onPlayerWasted, that does killPed (because its same function for pressing enter) and destroyElement and takes care of the player vehicle. Destroying vehicles works fine this way, but I don't know whats wrong with the peds.

Link to comment
  • Moderators
Alright, It turned out that function doesn't have any positive effect.

I'll try to just loop through all Peds and destroy them when they are dead.

Dirty solution but this should work.

Just put them per vehicle in a table.

--[[ 
vehicleTable = {[vehicle]= {ped1,ped2,ped3,ped4} 
]] 
  
local vehicleTable = {} 
addEventHandler ( "onVehicleExplode",root, 
function () 
    local vehicleData = vehicleTable[source] 
    if vehicleData and #vehicleData > 0 then 
        for i=1,#vehicleData do 
            local ped = vehicleData[i] 
            if isElement(ped) then 
                destroyElement(ped) 
            end 
        end  
        vehicleTable[source] = nil 
    end 
end) 

Link to comment

Maybe there was a misunderstanding here.

The peds I want to destroy were controlled by players before.

I tried creating some random peds and kill/destroy them, it worked fine.

But player peds just don't disappear. And 5 seconds after they died this "death floating camera" starts,

even if I setCameraMatrix to somewhere else.

Link to comment
  • Moderators

Ah you are talking about the player element. :o

The player element can't be destroy,

See wiki:

This function destroys an element and all elements within it in the hierarchy (its children, the children of those children etc). Player elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked. The root element also cannot be destroyed, however, passing the root as an argument will wipe all elements from the server, except for the players and clients, which will become direct descendants of the root node, and other elements that cannot be destroyed, such as resource root elements.

Players are not the only elements that cannot be deleted. This list also includes remote clients and console elements.

The best way is using: setElementPosition() to a position which can't be reached.

Link to comment
  • 2 years later...

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