Basic Gamemode/Lua, Can't figure out what's wrong (won't launch)
4 replies, posted
Just got back into lua after a 6 month break (was never good at it to start with), and after relearning what i knew before i quit i tried making a simple gamemode. The only problem is that whenever I try to launch it, the game goes straight to sandbox and I don't get an error report.
init
[LUA]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function GM:PlayerInitialSpawn(ply)
RunConsoleCommand("sb_team2")
RunConsoleCommand("set_team")
end
function GM:PlayerLoadout(ply)
if ply:Team() == 1 then
ply:Give("weapon_crowbar")
ply:SetModel("models/player/police.mdl")
else
ply:GiveAmmo(1, "357")
ply:SetModel("models/player/police.mdl")
end
end
function sb_team1(ply)
ply:SetHealth(100)
ply:SetMaxHealth(150, true)
ply:SetRunSpeed(300)
ply:UnSpectate()
ply:SetTeam(1)
ply:Spawn()
ply:PrintMessage(HUD_PRINTTALK, "This gamemode is currently in its alpha test.\n")
end
function sb_team2(ply)
ply:Spectate()
ply:SetTeam(2)
end
concommand.Add("sb_team1", sb_team1)
concommand.Add("sb_team2", sb_team2)
concommand.Add("set_team", set_team)
[/LUA]
cl_init
[LUA]
include('shared.lua')
function set_team()
local SpawnMenu = vgui.Create("DFrame")
SpawnMenu:SetPos(200, 200)
SpawnMenu:SetSize(800, 300)
SpawnMenu:SetTitle("Unnamed Alpha")
SpawnMenu:SetVisible(true)
SpawnMenu:SetDraggable(false)
SpawnMenu:ShowCloseButton(false)
SpawnMenu:MakePopup()
local SpawnPanel = vgui.Create("DButton")
SpawnPanel:SetParent(SpawnMenu)
SpawnPanel:SetText("Spawn")
SpawnPanel:SetPos(25, 25)
SpawnPanel:SetSize(200, 100)
SpawnPanel:DoClick = function()
SpawnMenu:Close()
RunConsoleCommand("sb_team1")
end
end
concommand.Add("set_team", set_team)
[/LUA]
shared
[LUA]
GM.Name = "Unnamed Alpha"
GM.Author = "Valdor"
GM.Email = "N/A"
GM.Website = "N/A"
team.SetUp(1, "Guest", Color(0, 162, 232, 255))
team.SetUp(2, "Joining", Color(222, 237, 254, 255))
[/LUA]
[editline]27th March 2012[/editline]
I've been comparing it to another basic gamemode that I had made and that worked, and I can't find anything different between the two that would matter
You sure it isn't going into base?
uh if by going into base you mean base gamemode, I don't know. Whatever it loads I have everything I would have in sandbox, including toolgun and prop spawn.
Hows your file structure?
[QUOTE=mil0001;35327023]Hows your file structure?[/QUOTE]
The second I read that I instantly remembered that you aren't suppose to have spaces in the gamemode name and now it works.
I feel like a dumbass, but thanks. This thread can be locked/forgotten about now.
Sorry, you need to Log In to post a reply to this thread.