• Entities saving on a map as a World Prop?
    5 replies, posted
Is that even possible? I've seen on a server, they have a youtube player, and some other ent's stuck in a place, where they spawn even if the server restarted. I just wanted this for my server, so if you could, direct me to one maybe? Thanks. If this is non-existent, could you maybe go about scripting it FOR me, or teaching me how to script it? Thanks alot FP.
There is an addon called PermaProps,it will automatically recreate all the entities saved on map switching or whatever. [url]http://www.facepunch.com/threads/960173-PermaProps[/url] It might be what you were looking for.
Oh, i've tried, but it leaves the prop unfrozen. I've also tried Falco's thingy, but it saves as a prop.
You can probably use [b][url=http://wiki.garrysmod.com/?title=Ents.Create]Ents.Create [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] I haven't tested it but i think it's limited to props.
[QUOTE=Moey;26168131]You can probably use [b][url=http://wiki.garrysmod.com/?title=Ents.Create]Ents.Create [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b] I haven't tested it but i think it's limited to props.[/QUOTE] What I would do an Ents.FindByClass("prop_physics") and then get several attributes about said props, like the model, position, and rotation. Possibly if it's frozen or not. Send it to a number of different tables and a var indicating the total number of prop_physics should also be there. Save all of it to a .txt file. To spawn them, parse the .txt file and do a for-loop. Spawn all of them using Ents.Create(prop_physics) and apply their attributes accordingly. That's how I would do it. [editline]19th November 2010[/editline] To not add props that were already there, I believe you could do a check on the current number phys props and get the last one's ent index. Check that against the newer highest number and then tell it to disregard saving any ent with a lower ent index than the highest original.
[b][url=wiki.garrysmod.com/?title=Gamemode.InitPostEntity]Gamemode.InitPostEntity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] So when the gamemode loads or the map loads the hook is called and then inside your function use [b][url=http://wiki.garrysmod.com/?title=Ents.Create]Ents.Create [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] to spawn the entities you want. Watch out though because I think your going to have to set some spawn flags for some but Iam unsure Example: [lua] local function EntLoad() local ent = ents.Create("npc_zombie") ent:SetPos( Vector(0,0,0) ) end hook.Add( "InitPostEntity", "MapStartTrigger", EntLoad )[/lua]
Sorry, you need to Log In to post a reply to this thread.