Bonsai Posted February 3, 2014 Share Posted February 3, 2014 Hey peeps, I got a little problem with removing vehicles of dead players. It seems to work fine as long as the vehicles did not explode. But if that happened, it will stay until resource is restarted. function enterVehicle(player) playerVehicle[player] = source end addEventHandler("onVehicleEnter", root, enterVehicle) function kill(p) if p then source = p end unbindKey(source, "enter", "down", "suicide") if isPedDead(source) == false then killPed(source) destroyElement(source) end if playerVehicle[source] then setTimer(destroyPlayerVehicle, 5000, 1, playerVehicle[source]) end end addEventHandler("onPlayerQuit", root, kill) addCommandHandler("suicide", kill) addEvent("onRequestKillPlayer", true) addEventHandler("onRequestKillPlayer", root, kill) function destroyPlayerVehicle(vehicle) destroyElement(vehicle) end This is my code and most of the time its working good. But sometimes dead peds don't disappear either. Is it even possible to destroy dead peds by destroyElement? killPed only seems to kill them, but they aren't disappearing after that. Bonsai Link to comment
Moderators IIYAMA Posted February 3, 2014 Moderators Share Posted February 3, 2014 function kill(p) if p and isElement(p) and getElementType(p) == "player" then source = p end -- here was your bug. unbindKey(source, "enter", "down", "suicide") if isPedDead(source) == false then killPed(source) if getElementType(source) ~= "player" then destroyElement(source)-- you can't destroy players end end local vehicle = playerVehicle[source] if isElement(vehicle) then setTimer(destroyPlayerVehicle, 5000, 1, vehicle) end end addEventHandler("onPlayerQuit", root, kill) addCommandHandler("suicide", kill) addEvent("onRequestKillPlayer", true) addEventHandler("onRequestKillPlayer", root, kill) function destroyPlayerVehicle(vehicle) if isElement(vehicle) then destroyElement(vehicle) end end -- the big bad bug -- (BBB) --[[onPlayerQuit Serverside event This event is triggered when a player disconnects from the server. Parameters string quitType, string reason, element responsibleElement]] <<<<<<<<<<<<<< Link to comment
Bonsai Posted February 3, 2014 Author Share Posted February 3, 2014 Ahh, the quitType.. of course. Sorry. Thanks for that. About this destroyElement, I read somewhere that peds are destroyed that way. But sometimes the peds still don't disappear and keep doing some dying animation. Bonsai Link to comment
Moderators IIYAMA Posted February 3, 2014 Moderators Share Posted February 3, 2014 np. P.s: didn't we ever met in game? (I remember somebody with that nick) Link to comment
Bonsai Posted February 3, 2014 Author Share Posted February 3, 2014 Depends, if you were using a different nick maybe, at least I don't remember this one Link to comment
Moderators IIYAMA Posted February 4, 2014 Moderators Share Posted February 4, 2014 I saw your nick inside a stealth server. (probably GCC or gta.ru) Are you German? Link to comment
Bonsai Posted February 4, 2014 Author Share Posted February 4, 2014 Yeah, but actually I only play on DDC from time to time Link to comment
Moderators IIYAMA Posted February 4, 2014 Moderators Share Posted February 4, 2014 oh wait. I also played in DDC under the nick Alex-Rider. (not any more) 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