0

我一直在为 Gmod 编写一个新的自定义游戏模式,它类似于 DarkRP。然而,我已经碰壁了。当我尝试包含一个 lua 文件时,我不断收到错误消息:

这是错误:

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

这是我文件中的代码:

初始化.lua:

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 )

cl_init.lua:

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

共享.lua

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) )

teamMenu.lua

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 )
 

teamsetup.lua

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

我可能做错了什么?

4

0 回答 0