• Can't Remove PD Doors
    10 replies, posted
Hello i currently own a darkrp server and i was wondering on the map rp_downtown_v4c_v2 i can't remove PD doors since i have made my own code.... I really want help with this and it's botthering me.... please help If you want to connect the ip is la-src11-243.serenityservers.net:27045
I'm sure there's a better way of doing it but here's what I do. We get the entity index of the door so we can remove it by looking at it and typing this on console. [CODE]lua_run_cl print(LocalPlayer():GetEyeTrace().Entity)[/CODE] Once that has printed we grab the number it outputs. Next we need to remove the door so we create a server side file where we hook InitPostEntity and remove the door as shown here. [CODE]function RemoveDoors() Entity(number you got before goes here):Remove() end hook.Add("InitPostEntity", "RemoveDoors", RemoveDoors)[/CODE]
[QUOTE=Dark Hood;50802862]I'm sure there's a better way of doing it but here's what I do. We get the entity index of the door so we can remove it by looking at it and typing this on console. [CODE]lua_run_cl print(LocalPlayer():GetEyeTrace().Entity)[/CODE] Once that has printed we grab the number it outputs. Next we need to remove the door so we create a server side file where we hook InitPostEntity and remove the door as shown here. [CODE]function RemoveDoors() Entity(number you got before goes here):Remove() end hook.Add("InitPostEntity", "RemoveDoors", RemoveDoors)[/CODE][/QUOTE] Nooo!!! This is completely wrong! This would make it so every time the lua file is loaded it would remove the entity with that number! And also the entity of a map doesn't always have the same id, you would remove completely different things! [editline]30th July 2016[/editline] Yo should instead use: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/MapCreationID]Entity:MapCreationID[/url] and to get the entity with that number: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url]
[QUOTE=geferon;50802903]Nooo!!! This is completely wrong! This would make it so every time the lua file is loaded it would remove the entity with that number! And also the entity of a map doesn't always have the same id, you would remove completely different things! [editline]30th July 2016[/editline] Yo should instead use: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/MapCreationID]Entity:MapCreationID[/url] and to get the entity with that number: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url][/QUOTE] It always has the same id. Only load it once?????//?/?1
It will not always have the same ID, changing the number of max players will skew entity numbers. If the file is ever reloaded on the disk it will run again, removing whatever entity has that number now.
Still not working!!!! is there another way??
[QUOTE=AcTivColonel;50803066]Still not working!!!! is there another way??[/QUOTE] I think you forgot this line. [CODE]while true do end[/CODE] [highlight](User was banned for this post ("Help or don't reply" - Craptasket))[/highlight]
[QUOTE=Dark Hood;50803151]I think you forgot this line. [CODE]while true do end[/CODE][/QUOTE] Ignore him. That will crash your server.
Can someone tell me how to do this cause im confussed.... Prop entity is this Entity [302][prop_door_rotating]
[QUOTE=AcTivColonel;50803284]Can someone tell me how to do this cause im confussed.... Prop entity is this Entity [302][prop_door_rotating][/QUOTE] Like geferon said, you want to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/MapCreationID]Entity:MapCreationID[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url]. Placing these in Dark Hood's code gives you this: [CODE]lua_run_cl print(LocalPlayer():GetEyeTrace().Entity:MapCreationID)[/CODE] [CODE]function RemoveDoors() ents.GetMapCreatedEntity(number you got before goes here):Remove() end hook.Add("InitPostEntity", "RemoveDoors", RemoveDoors)[/CODE]
The first one will give you an error. You forgot to call the metamethod. [lua]lun_run_cl print(LocalPlayer():GetEyeTrace().Entity:MapCreationID())[/lua] Then after gathering a list, I would do something like this (the numbers inside the table are examples obviously, and I recommend commenting each one so you know what it corresponds to in case you need to remove it. [lua]local tblRemoveEnts = { 87, -- PD door 1 89, -- stupid door elsewhere } hook.Add("InitPostEntity", "RemoveDoors", function() for k,v in pairs(tblRemoveEnts) do local objEnt = ents.GetMapCreatedEntity(v) if(IsValid(objEnt)) then SafeRemoveEntity(objEnt) end end end)[/lua]
Sorry, you need to Log In to post a reply to this thread.