1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

[Solved] Entity Spawn on server start?

Discussion in 'DarkRP Modding Questions & Help' started by [TXG] Church, Oct 12, 2016.

  1. [TXG] Church

    [TXG] Church New Member

    I've got the code for an entity to spawn and it works fine, however I'm trying to get it to be run on server startup so when you get in-game, the entities are already there for you.

    I've looked into
    Code (Text):
    function GM:InitPostEntity()
    ... my stuff ...
    but that doesn't do anything but toss this error
    Code (Text):
    attempt to index global 'GM' (a nil value)
    So I was wondering what the function is to make it load the entities on server start?
    And I'm guessing the file is
    Code (Text):
    for where to put it?
    --- Double Post Merged, Oct 12, 2016 ---
    I figured it out :p

    Correct method is like this

    Code (Text):

    -- Function name doesn't matter
    function SpawnNPCFunction()
    ... spawn whatever code ...

    hook.Add("InitPostEntity", "unique_name", SpawnNPCFunction)
    It calls the function after the gamemode default clears the map of entities, allowing it to spawn stuff.
    Last edited: Oct 12, 2016

Share This Page