• Remove Cars if you are dead
    7 replies, posted
Hello, I would like to create a la/autorun file. If you're dead your car is removed. If you don't understand say to me. I asked you for learn how make better script and use correctly the wiki and other. Thanks for this
[quote]I asked you for learn how make better script and use correctly the wiki and other.[/quote] [quote]If you don't understand say to me.[/quote] to me
When you spawn a car, store it to a variable on the player so you can access it in the PlayerDeath hook
[sp]how do that and where put i this[/sp]
Okey tanks.
You can help me?
[code]-- Whenever car is spawned... local tCars = PlayerWhoSpawnedCar.m_tCars if ( not tCars ) then tCars = {} PlayerWhoSpawnedCar.m_tCars = tCars end tCars[#tCars + 1] = CarEntity -- On death of player... hook.Add( "PostPlayerDeath", "RemoveCar", function( pPlayer ) local tCars = pPlayer.m_tCars for i = 1, #tCars do tCars[i]:Remove() tCars[i] = nil end end )[/code]
Thanks
Sorry, you need to Log In to post a reply to this thread.