Hello, Sorry if the title is not really precise.
I created a NPC that spawns a car on the Simfphys base, but I want to prevent the player for spawning more than one car at a time because last time a player spammed the npc, my game just crashed.
Here’s a small part of my code (the code is in lua/entities/npc_car/init.lua):
function ENT:AcceptInput( Name, Activator, Caller ) if shouldOccur == true then simfphys.SpawnVehicleSimple( "sim_fphys_bak_taxi", Vector(-1000,1300,320), Angle(0, 0, 0) ) -- Spawn the car using simfphys Caller:PrintMessage( HUD_PRINTTALK, "Your car appears." ) shouldOccur = false -- Prevents from spaming timer.Simple( 1, function() shouldOccur = true end ) end end
I tried to remove the previous car spawned by the player using Entity:Remove but I don’t know how to select the entity to remove (and I don’t really know if I can remove simfphys cars using Entity:Remove).