• Basic Addon Framework Question
    0 replies, posted
Hello, I am attempting to create a basic add-on to get a feel for how they work. After tons of research/dissecting of other add-ons, I believe I have a general understanding. My problem stems from an issue with client versus server side commands, and how I can load them accordingly. Here is some of my code: [B]/lua/autorun/rem.lua[/B] [LUA] if SERVER then AddCSLuaFile("rem_server.lua") else include("rem_client.lua") end [/LUA] [B]/lua/rem_client.lua[/B] [LUA] initialized = false /* some code to implement my menu, like the REM_ShowMenu function and REM_HideMenu */ function REM_InitializeAll() if ( initialized ) then return end Msg("Initializing Client...") concommand.Add("+REM_Menu", REM_ShowMenu) concommand.Add("-REM_Menu", REM_HideMenu) initialized = true end concommand.Add("REM_CS_Initialize",REM_InitializeAll) [/LUA] [B]/lua/rem_server.lua[/B] [LUA] AddCSLuaFile("rem_client.lua") function REM_PlayerInitialSpawn( ply ) RunConsoleCommand( "REM_CS_Initialize" ) end hook.Add( "PlayerInitialSpawn", "REM_PlayerInitialSpawn", REM_PlayerInitialSpawn) [/LUA] Here is what I [I]think[/I] it is supposed to do. The /autorun/ folder loads up the module for the client and server, parsing it appropriately. The [I]client [/I] registers its own functions like REM_CS_Initialize. The [I]server [/I] loads and it hooks into the player spawn code at the console level. As soon as a player spawns the server will force the newly loaded player to execute the REM_CS_Initialize code which, in turn, binds the +/-MENU commands. And voila, a basic plugin skeleton is born. Unfortunately, I have no idea what is going on anymore. It seems like the client simply doesn't register the commands and thus, is unable to access... anything. I am simply looking for direction here. I tried to find a tutorial on addons; to no avail. So everything I know has been derrived from a few addons that I currently have code for. Thank you for reading, I really appreciate any input you may have! I am practically going insane over this... -SharpCoder
Sorry, you need to Log In to post a reply to this thread.