• How to make DarkRP functions work in an NPC?
    2 replies, posted
Hello, recently I have been working on my own gamemode that derives from the DarkRP gamemode, and I wanted to create an NPC (Entity) that, when the player presses their use key on, the F4 menu (Job menu) will pop up. I know what the function is, I just don't know how I could link the two up since the NPC/Entity is in the addons folder, and the gamemode is in the gamemode folder. Everything else I can figure out. Thanks for your time!
Generally unless a function has 'local' in front of it, they are global and can be called from any lua file regardless of it's location. If DarkRP's function name to bring up the job menu is OpenDarkRPMenu() then you just call that in your entity. If the function is local then you need to create some kind of link. For example: local function OpenDarkRPMenu() -- this is local and can't be called from an external file print('opened') end function OpenDarkRPMenuRemotely() -- this is global and inside it calls the local function above. print('opening remotely') OpenDarkRPMenu() end Ideally you want to reduce the amount of global functions a gamemode has however, so using a concommand may be better.
Alright! I'll be sure to try it! up until this point I never knew what local meant. Thanks for teaching me!
Sorry, you need to Log In to post a reply to this thread.