Jump to content

Dead Peds


Bonsai

Recommended Posts

Posted

Hey Peeps,

is there a way to make sure Peds are definitely destroyed?

Sometimes they keep doing some dying animation and don't disappear at all.

This fucks up my spectator mode for some reason.

Bonsai

Posted

And I don't understand what you mean by them being in dying animation and not disappearing.

If you really want to force-delete the dead pedestrians, you can use destroyElement and loop through all dead pedestrians.

Posted

Sometimes they either just lie on the ground dead, or they do this.. dying animation like when you kick someone who is on the ground.

Yeah, I'm using destroyElement, but it doesn't work all the time.

  • Moderators
Posted

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)

Posted

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.

Posted

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.

  • Moderators
Posted
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) 

Posted

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.

  • Moderators
Posted

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.

Posted

Yeah, I've seen that before, but when you join a server without any gamemode running, do you have a Ped somewhere?

Which position is unreachable?

  • Moderators
Posted

AFAIK, the player element exist when you join, but is somehow hidden.

You can try: 0,0,-1000 or try a differed dimension.

  • Moderators
Posted
local x, y, z, lx, ly, lz = getCameraMatrix (player) 
setCameraMatrix ( player, x, y, z, lx, ly, lz ) 
setElementPosition(player,0,0,1000) 

Posted

This is so annoying.

It's not working, camera follows to any position.

If only the race resource wasn't so fucked up so you could check things there..

  • 2 years later...
Posted

I believe bons already found the solution.

Solution: Just use setCameraMatrix in onClientRender event. That's the only way to do it. Race resource did it in this way.

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