• Remove Serversided props
    11 replies, posted
I'm a little bit of a noob towards this and wondered if someone could help me get rid of the gas pumps on the provided pictures from rp_downtown_V33x. https://steamuserimages-a.akamaihd.net/ugc/941685795121105703/ACC4EF880373C2B37202A76A339CA8B87CD04E9C/ https://steamuserimages-a.akamaihd.net/ugc/941685795121105893/CA531B8F8C8D8877E454F52DF9F3C264849D73A9/ Thanks in regards.
They might be part of the map, but if they aren't this will sure work. -- put this in garrysmod/lua/autorun/server/deletelookat.lua hook.Add("KeyPress", "DeleteLookAt", function(ply, key) if ply:IsAdmin() and key == IN_ALT1 then -- Regular users too: if key == IN_ALT1 then local ent = ply:GetEyeTrace().Entity if IsValid(ent) then print("Removing " .. ent:GetClass() .. " on " .. ply:Nick() .. "'s accord.") if !ent:IsWorld() then ent:Remove() end print("Entity removed!") end end end ) Just look at an entity and press Left ALT. Either should work really.
Thanks will give it a try right now!
Should mention that if you are using a rank system to describe yourself as an "Admin", this code might not consider you one. Player/IsAdmin
Theres a slight problem, I have itemstore and it switched to inventory when i press alt.
-- Serverside (lua/autorun/server) hook.Add("InitPostEntity", "RemoveGasPumps", function() local tGasPumps = ents.FindByModel("gas_pump_model.mdl") for i = 1, #tGasPumps do tGasPumps[i]:Remove() end end) You can get the model by running this code in console in single-player while looking at a pump: lua_run print(Entity(1):GetEyeTrace().Entity:GetModel())
Thanks will try this in 5 mins
What did you name the file?
deletepumps.lua
Just tested the code on rp_evocity_v33x with "models/props_equipment/gas_pump.mdl" as the model and it worked correctly. Make sure you are using the correct model, the code is in the correct directory on your server, and no addon is recreating/preventing the deletion of the props.
Just to make sure -- Servers yourServerFolder/lua/autorun/server/deletePumps.lua -- Local Games Steam/steamapps/common/GarrysMod/garrysmod/lua/autorun/server/deletePumps.lua
You could, but pairs is a bit slower - while speed doesn't really matter in this case, I tend to use numeric-for as a default where appropriate.
Sorry, you need to Log In to post a reply to this thread.