Bonsai Posted February 7, 2014 Share Posted February 7, 2014 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 Link to comment
Anubhav Posted February 7, 2014 Share Posted February 7, 2014 what do you mean by destroyed? Link to comment
myonlake Posted February 7, 2014 Share Posted February 7, 2014 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. Link to comment
Bonsai Posted February 7, 2014 Author Share Posted February 7, 2014 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. Link to comment
Moderators IIYAMA Posted February 7, 2014 Moderators Share Posted February 7, 2014 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
Bonsai Posted February 7, 2014 Author Share Posted February 7, 2014 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 IIYAMA Posted February 7, 2014 Moderators Share Posted February 7, 2014 did you tried to remove them first from the vehicle before deleting them? Link to comment
Bonsai Posted February 7, 2014 Author Share Posted February 7, 2014 did you tried to remove them first from the vehicle before deleting them? removePedFromVehicle I'll try that, thanks Link to comment
Bonsai Posted February 7, 2014 Author Share Posted February 7, 2014 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. Link to comment
Deepu Posted February 8, 2014 Share Posted February 8, 2014 just use this friend ----- if isPedDead(thePed) Link to comment
Saml1er Posted February 9, 2014 Share Posted February 9, 2014 just use this friend ----- if isPedDead(thePed) He already used that as much as I know. Link to comment
Moderators IIYAMA Posted February 9, 2014 Moderators Share Posted February 9, 2014 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
Bonsai Posted February 11, 2014 Author Share Posted February 11, 2014 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 IIYAMA Posted February 11, 2014 Moderators Share Posted February 11, 2014 Ah you are talking about the player element. 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
Bonsai Posted February 11, 2014 Author Share Posted February 11, 2014 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? Link to comment
Moderators IIYAMA Posted February 11, 2014 Moderators Share Posted February 11, 2014 AFAIK, the player element exist when you join, but is somehow hidden. You can try: 0,0,-1000 or try a differed dimension. Link to comment
Bonsai Posted February 11, 2014 Author Share Posted February 11, 2014 Hmm, the camera keeps focusing the player... Link to comment
Moderators IIYAMA Posted February 11, 2014 Moderators Share Posted February 11, 2014 local x, y, z, lx, ly, lz = getCameraMatrix (player) setCameraMatrix ( player, x, y, z, lx, ly, lz ) setElementPosition(player,0,0,1000) Link to comment
Bonsai Posted February 11, 2014 Author Share Posted February 11, 2014 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.. Link to comment
Saml1er Posted May 5, 2016 Share Posted May 5, 2016 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now