• GM:PlayerLoadout Never Called
    1 replies, posted
Hello, I am having problems with overriding the GM:PlayerLoadout function. For some reason it is never called (or atleast, I never see the "---Loadout Called" message that I attempt to print within the function), and therefore I spawn without having any weapons that I attempt to give myself. Here is the code for the gamemode: [b]cl_init.lua[/b] [lua]// Includes include("shared.lua") // Setup an about box function about() local frame = vgui.Create("DFrame") frame:Center() frame:SetSize(210,220) frame:SetTitle("About") frame:SetVisible(true) frame:SetDraggable(false) frame:SetSizable(false) frame:ShowCloseButton(true) frame:SetDeleteOnClose(true) frame:MakePopup() local text = vgui.Create("DTextEntry",frame) text:SetPos(20,30) text:SetSize(170,170) text:SetMultiline(true) text:SetEditable(false) text:SetEnterAllowed(false) text:SetText("Welcome to TestGm." .. "\n" .. "This is for testing.") end // Add console command concommand.Add("tg_about", about)[/lua] [b]init.lua[/b] [lua]// Required client downloads AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") // Includes include("shared.lua") // Overloaded Functions function GM:PlayerInitialSpawn(ply) -- Upon inital player spawn print("---Init Spawn Called") ply:ConCommand("tg_about") ply:SetTeam(1) ply:Spawn() end function GM:PlayerLoadout(ply) -- Default spawn weapons print("---Loadout Called") // Give default weapons ply:RemoveAllAmmo() ply:StripWeapons() ply:Give("gmod_tool") ply:Give("gmod_camera") ply:Give("weapon_physgun") end function GM:PlayerSpawn(ply) -- Everytime the player spawns print("---Player Spawn Called") // Select random model local mdlNumber = math.random(3) if(mdlNumber == 1) then ply:SetModel("models/Player/Group01/male_01.mdl") elseif(mdlNumber == 2) then ply:SetModel("models/Player/Group01/male_02.mdl") else ply:SetModel("models/Player/Group01/male_03.mdl") end end[/lua] [b]shared.lua[/b] [lua]//Gamemode Info GM.Name = "TestGm" GM.Author = "" GM.Email = "" GM.Website = "" function GM:PlayerConnect(name,addr) // Notify all players MsgAll("Player " .. name .. " at " .. addr .. " has connected.") end function GM:CreateTeams() -- Setup Teams team.SetUp(1,"Tester",Color(0,255,0,255)) end[/lua] Thanks.
Your PlayerSpawn is supposed to call PlayerLoadout. Look at how the Base gamemode works.
Sorry, you need to Log In to post a reply to this thread.