GMOD-Custom Gamemode-Teams& VGUI

时间:2016-07-27 04:59:28

标签: lua garrys-mod

我一直在为Gmod编写一个新的自定义游戏模式,它将类似于DarkRP。但是,我撞墙了。当我尝试包含lua文件时,我不断收到错误:

这是错误:

Couldn't include file '\modules\team\teammenu.lua' (File not found) <@gamemode/spacerp/cl_init.lua> (line 2)

以下是我的文件中的代码:

Init.lua:

&#13;
&#13;
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "modules/team/teamsetup.lua" )
AddCSLuaFile( "modules/team/teamMenu.lua" )

include( "shared.lua" )
include( "/modules/team/teamsetup.lua" )
include( "modules/team/teamMenu.lua" )

function GM:PlayerInitialSpawn( ply )
 
    ply:ConCommand( "team_menu" )
 
end 

function GM:PlayerSpawn( ply )
	print( "Player: " .. ply:Nick() .. " has spawned!")
	ply:StripWeapons()
	ply:SetupHands()
	
	
end

function GM:PlayerSetHandsModel( ply, ent )

	local simplemodel = player_manager.TranslateToPlayerModelName( ply:GetModel() )
	local info = player_manager.TranslatePlayerHands( simplemodel )
	if ( info ) then
		ent:SetModel( info.model )
		ent:SetSkin( info.skin )
		ent:SetBodyGroups( info.body )
	end

end

function team_red( ply )
 
    ply:SetTeam( 0 )
 
end
 
function team_blue( ply )
 
    ply:SetTeam( 1 )
end
 
concommand.Add( "team_red", team_red )
concommand.Add( "team_blue", team_blue )
&#13;
&#13;
&#13;

cl_init.lua:

&#13;
&#13;
include( "shared.lua" )
include( "/modules/team/teamMenu.lua" )
&#13;
&#13;
&#13;

shared.lua

&#13;
&#13;
GM.Name = "SpaceRP"
GM.Author = "Dicknanigans"
GM.Email = "N/A"
GM.Website = "N/A"

team.SetUp( 0, "Red", Color(255,0,0) )
team.SetUp( 1, "Blue", Color(0,0,255) )
&#13;
&#13;
&#13;

teamMenu.lua

&#13;
&#13;
function set_team()
 
local frame = vgui.Create( "DFrame" )
frame:SetPos( ScrW() / 2, ScrH() / 2 ) --Set the window in the middle of the players screen/game window
frame:SetSize( 200, 210 ) --Set the size
frame:SetTitle( "Change Team" ) --Set title
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()
 
team_red = vgui.Create( "DButton", frame )
team_red:SetPos( frame:GetTall() / 2, 5 ) --Place it half way on the tall and 5 units in horizontal
team_red:SetSize( 50, 100 )
team_red:SetText( "Team Red" )
team_red.DoClick = function() --Make the player join team 1
    RunConsoleCommand( "team_red" )
end
 
team_blue = vgui.Create( "DButton", frame )
team_blue:SetPos( frame:GetTall() / 2, 105 ) --Place it next to our previous one
team_blue:SetSize( 50, 100 )
team_blue:SetText( "Team Blue" )
team_blue.DoClick = function() --Make the player join team 2
    RunConsoleCommand( "team_blue" )
end
 
end
concommand.Add( "team_menu", set_team )
 
&#13;
&#13;
&#13;

teamsetup.lua

&#13;
&#13;
local ply = FindMetaTable( "Player" )

local teams = {}


/*
	THIS IS THE TEAM INIT AREA
*/
teams[0] = {
			name = "red",
			description = "You are on the red team",
			color = Vector(1.0, 0,0),
			weapons = {  "weapon_smg1", "weapon_revolver", "weapon_frag" },
			model = ("models/player/Group01/male_0" .. math.random(1,9) .. ".mdl")
			}
teams[1] = {
			name = "blue",
			description = "You are on the blue team",
			color = Vector(0, 0,1.0),
			weapons = { "weapon_smg1", "weapon_revolver", "weapon_frag" },
			model = ("models/player/Group01/male_0" .. math.random(1,9) .. ".mdl")
			}
			
/* 
	END
*/

function GM:PlayerLoadout( ply ) 
 
	ply:StripWeapons() 
 
	ply:SetupTeam( n )
 
end


function ply:SetupTeam( n )
	if ( not teams[n] ) then return end
	
	self:SetTeam( n )
	self:SetPlayerColor( teams[n].color )
	self:SetHealth( 150 )
	self:SetMaxHealth( 200 )
	self:SetWalkSpeed( 200 )
	self:SetRunSpeed( 400 )
	self:SetModel( teams[n].model )
	
	self:GiveWeapons( n )
end

function ply:GiveWeapons( n )
	for k, weapon in pairs( teams[n].weapons ) do
		self:Give( weapon )
	end
end
&#13;
&#13;
&#13;

我可能做错了什么?

0 个答案:

没有答案