Heya guys.
I just recently started learning lua and stuff and i followed some random persons lua guide to make a custom gamemode. and im stumped. i got an error after trying my gamemode. Could you guys help me out?
its a custom team deathmatch gamemode. And if you guys find the problem, could you point a way i could make it so that when people join they are automatically spectator and have to choose a team?
shared.lua
[CODE]
//teams
team.SetUp( 1, 'Silverfang', Color( 220, 110, 110 ) )
team.SetUp( 2, 'Yellowfang', Color( 50, 50, 50 ) )
local Class = {}
Class.WalkSpeed = 250
Class.RunSpeed = 350
Class.MaxHealth = 200
Class.StartHealth = 100
Class.TeammateNoCollide = true
Class.JumpPower = 200
Class.WepLoadout = function ( info )
info.Player:Give( "weapon_crowbar" )
info.Player:Give( "weapon_357" )
info.Player:ChatPrint( 'Here are some weapons! Goodluck!' )
end
player_manager.RegisterClass( "normalclass", Class, "player_default" )
[/CODE]
init.lua
[CODE]AddCSLuaFile( 'shared.lua' )
AddCSLuaFile( 'cl_init.lua' )
include( 'shared.lua' )
--Fades in when joining--
function GM:PlayerInitialSpawn(player)
umsg.Start("FadeToStart",player)
umsg.End()
end
-- What happens when someones spawns.--
player_manager.SetPlayerClass( ply, "normalclass" )
player_manager.OnPlayerSpawn ( ply )
player_manager.RunClass( ply, "WepLoadout" )
ply.cando = 0
timer.Simple( 5, function()
MsgN( "You're name is "..ply:Nick().."! And your steam id is "..ply:SteamID().."!" )
end )
end
local function CanDoThis( ent )
local ct = CurTime()
if ( ct > ent.cando ) then
ent.cando = ct + 5
return true
end
return false
end
local function NoFriendFire ( ply, attacker )
if ( attacker:IsPlayer() ) && ( attacker:Team() == ply:Team() ) then
return false
end
return true
end
hook.Add( 'PlayerShouldTakeDamage', 'ubuttsoftwo', NoFriendFire )
hook.Add( 'PlayerSay', 'some secret chat command', function( ply, text, is_team )
text = string.lower( text )
if ( string.sub( text, 1 ) == "!kill" ) then
ply:Kill()
ply:ChatPrint( 'You commit suicide! Stupid emo' )
end
end )[/CODE]
cl_init.lua
[CODE]include( 'shared.lua' )
-- hide hud
local hide = {
CHudHealth = true,
CHudBattery = true,
}
hook.Add( "HUDShouldDraw", "HideHUD", function( hidehudpls )
if ( hide[ hidehudpls ] ) then
return false
end
-- Don't return anything here, it may break other addons that rely on this hook.
end )
-- end of hide hud
-- LEFT BOTTOM BOX
surface.CreateFont( "seagull_font", { font = "Arial", size = 23, weight = 400 } )
surface.CreateFont( "nez_font", { font = "HL2MPTypeDeath", size = 23, weight = 10 } )
hook.Add( 'HUDPaint', 'cool drawings son', function()
local ply = LocalPlayer()
// ply:PS_GetPoints() //
surface.SetFont( "nez_font" )
surface.SetTextPos( 120, 780 )
surface.SetTextColor( Color( 219, 39, 207 ) )
surface.DrawText ( "Nez's Team Deathmatch" )
surface.SetTextPos( 120, 820 )
surface.SetTextColor( Color( 0, 235, 0 ) )
surface.DrawText( ply.PS_Points .. " Pointshop points" )
surface.SetFont( "seagull_font" )
surface.SetTextPos( 120, 840 )
surface.SetTextColor( Color( 10, 10, 255 ) )
surface.DrawText( ply:Armor() )
surface.DrawText( " Armor! " )
draw.SimpleText( "You have " .. ply:Frags().." Kill/s" , 'seagull_font', 120, 880, Color( 255, 120, 50 ) )
draw.SimpleText( "You have " .. ply:Deaths().." Death/s" , 'seagull_font', 120, 900, Color( 255, 120, 50 ) )
draw.RoundedBox( 2, 100, 780, 250, 150, Color( 62, 78, 132, 100 ) )
surface.SetTextColor( Color( 70, 220, 110) )
surface.SetTextPos( 120, 860 )
surface.SetTextColor( Color( 160, 20, 20) )
surface.DrawText( ply:Health() )
surface.SetTextColor( Color( 70, 220, 110) )
surface.DrawText( " health!" )
end)
-- END OF LEFT BOTTOM BOX--
//Team menu GUI
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_1 = vgui.Create( "DButton", frame )
team_1:SetPos( frame:GetTall() / 2, 5 ) --Place it half way on the tall and 5 units in horizontal
team_1:SetSize( 50, 100 )
team_1:SetText( "Silverfang" )
team_1.DoClick = function() --Make the player join team 1
RunConsoleCommand( "team_1" )
end
team_2 = vgui.Create( "DButton", frame )
team_2:SetPos( frame:GetTall() / 2, 105 ) --Place it next to our previous one
team_2:SetSize( 50, 100 )
team_2:SetText( "Yellowfang" )
team_2.DoClick = function() --Make the player join team 2
RunConsoleCommand( "team_2" )
end
end
concommand.Add( "team_menu", set_team )
// ENd of team menu gui
--Test fade script--
local intro = false
local alpha = 255
usermessage.Hook("FadeToStart",function()
intro = true
end)
timer.Create("EndFade",0.1,0,function()
if intro && alpha > 0 then
alpha = alpha - 1
end
if alpha < 1 then
timer.Destroy("EndFade")
end
end)
function FadeEffect()
draw.RoundedBoxEx(1,0,0,ScrW(),ScrH(),Color(0,0,0,alpha))
end
hook.Add("HUDPaint","FadeEffect",FadeEffect)
--END OF SCRIPT--
[/CODE]
Sorry, you need to Log In to post a reply to this thread.