I am new at making gamemodes, however I ma familiar with Lua, sense I have been using it for a year, my first attempt at a Gamemode, but why isn't this working like it should...
----init.lua----
//Starting the Server and Client Download Files
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
//Spawning and Determining Team
function GM:PlayerInitialSpawn( ply )
ply:ConCommand( "team_menu" )
end
//Giving specif team members their respective weapons
function GM:PlayerSpawn(ply)
if ply:Team() == 1 then
ply:SetModel( "models/player/combine_soldier.mdl" )
ply:SetMaxHealth(150,true)
elseif ply:Team() == 3 then
ply:SetModel( "models/player/gman_high.mdl" )
ply:SetMaxHealth(500,true)
elseif ply:Team() == 2 then
ply:SetModel( "models/player/group01/male_05.mdl" )
ply:SetMaxHealth(200,true)
else
ply:SetMaxHealth(100,true)
end
end
function GM:PlayerLoadout(ply)
if ply:Team() == 1 then
ply:Give("weapon_smg1")
ply:GiveAmmo(1275, "smg1")
elseif ply:Team() == 3 then
ply:Give("weapon_crowbar")
ply:Give("weapon_pistol")
ply:GiveAmmo(255, "pistol")
elseif ply:Team() == 2 then
ply:Give("weapon_smg1")
ply:Give("weapon_pistol")
ply:GiveAmmo(55, "pistol")
ply:GiveAmmo(1275, "smg1")
else
ply:Give("weapon_crowbar")
end
end
//Change Teams by ConCommand
function team_1( ply )
if team.NumPlayers( 1 ) < 8 then
ply:SetTeam( 1 )
ply:Spawn()
end
end
function team_2( ply )
if team.NumPlayers( 2 ) < 6 then
ply:SetTeam( 2 )
ply:Spawn()
end
end
function team_3( ply )
if team.NumPlayers( 3 ) < 1 then
ply:SetTeam( 3 )
ply:Spawn()
end
end
concommand.Add( "team_1", team_1 )
concommand.Add( "team_2", team_2 )
concommand.Add( "team_3", team_3 )
----cl_init.lua----
//Client should load Shared as well
include("shared.lua")
//Miss. Variables and Commands
function GM:Initialize( )
surface.CreateFont("Tahoma", 16, 1000, true, false, "HUDFontAA")
end
//Elaborate, but more enthusiastic way of giving players a team...
function set_team()
local frame = vgui.Create( "DFrame" )
frame:SetPos( ScrH() / 2, ScrW() / 2 )
frame:SetSize( 115, 100 )
frame:SetTitle( "Change Team" )
frame:SetVisible( true )
frame:SetDraggable( true )
frame:ShowCloseButton( true )
frame:MakePopup()
team_1 = vgui.Create( "DButton", frame )
team_1:SetPos( 10, 25 )
team_1:SetSize( 100, 20 )
team_1:SetText( "Terrorists" )
team_1.DoClick = function()
RunConsoleCommand( "team_1" )
end
team_2 = vgui.Create( "DButton", frame )
team_2:SetPos( 10, 45 )
team_2:SetSize( 100, 20 )
team_2:SetText( "Secret Service" )
team_2.DoClick = function()
RunConsoleCommand( "team_2" )
end
team_3 = vgui.Create( "DButton", frame )
team_3:SetPos( 10, 65 )
team_3:SetSize( 100, 20 )
team_3:SetText( "President" )
team_3.DoClick = function()
RunConsoleCommand( "team_3" )
end
end
concommand.Add( "team_menu", set_team )
function showhelp()
local help = vgui.Create( "DFrame" )
help:SetPos( ScrH() / 2, ScrW() / 2 )
help:SetSize( 400, 410 )
help:SetTitle( "Help" )
help:SetVisible( true )
help:SetDraggable( true )
help:ShowCloseButton( true )
help:MakePopup()
text = vgui.Create( "DLabel", help )
text:SetPos(10, 25)
text:SetSize(380, 360)
text:SetText([[MyTextishere]])
end
concommand.Add("gm_help", showhelp)
//Draw Current Team Data
function GM:HUDPaintBackground()
end
function GM:HUDPaint()
h = ScrH()
w = ScrW()
surface.SetDrawColor(255, 255, 255, 180)
//Team Score Count
local terrorist = 0
local secret = 0
local president = 0
terrorist = team.GetScore( 1 )
secret = team.GetScore( 2 )
president = team.GetScore( 3 )
draw.RoundedBox(16, 0, 0, w*0.25, h*0.11, color_black_alpha90)
local w05 = w * 0.05
local h05 = h * 0.05
surface.SetDrawColor(235, 235, 235, 255)
surface.DrawRect(0, 0, w05, h05)
surface.DrawRect(0, h05, w05, h05)
draw.DrawText(terrorist, "HUDFontAA", w05, 0, COLOR_RED, TEXT_ALIGN_LEFT)
draw.DrawText(secret, "HUDFontAA", w05, h05, COLOR_GREEN, TEXT_ALIGN_LEFT)
draw.DrawText(president, "HUDFontAA", w05, h05, COLOR_BLUE, TEXT_ALIGN_LEFT)
end
----shared.lua----
//Setting the Gamemode Info up
GM.Name = "Blah"
GM.Author = "blah"
GM.Email = "blah"
GM.Website = "N/A"
GM.TakeFragOnSuicide = false
GM.PlayerCanNoClip = false
GM.AllowAutoTeam = false
GM.NoPlayerSuicide = false
GM.NoPlayerDamage = false
GM.NoPlayerSelfDamage = true
GM.NoPlayerTeamDamage = true
GM.NoPlayerPlayerDamage = false
GM.NoNonPlayerPlayerDamage = false
GM.NoPlayerFootsteps = false
GM.AutomaticTeamBalance = false
GM.AddFragsToTeamScore = true
//Setting up Teams
team.SetUp( 1, "Taliban", Color(255, 0, 0))
team.SetUp( 2, "Secret Service", Color(0, 255, 0))
team.SetUp( 3, "President", Color(0, 0, 255))
team.SetUp( 4, "Waiting", Color(0, 100, 100))
[editline]12:54AM[/editline]
I know it gives an error for the HUD, I already fixed that, but why does the max health not change at all, and why does the player not receive what he is suppose to in terms of weapons. The player doesn't get the proper health, weapons, ammo, etc. that he should. The only thing out of that that works is the player model...very frustrating when every single dang tutorial said to do it this way, and it doesn't work worth bupkiss. So, guys, please help me out here.
For [b]ply:SetMaxHealth()[/b] take out the comma and the 'true'. For [b]ply:GiveAmmo[/b], reduce the amount of ammo you are giving the players. Occasionally your ammo resets to 0 if you have too much. As for giving the players weapons...check again. Are you sure you didn't get any weapons?
Yes, I am sure I didn't get any weapons. Thanks for the reply by the way. I guess it was just old things being done the wrong way.
[editline]01:49AM[/editline]
[QUOTE=braxus;17056011]For [b]ply:SetMaxHealth()[/b] take out the comma and the 'true'. For [b]ply:GiveAmmo[/b], reduce the amount of ammo you are giving the players. Occasionally your ammo resets to 0 if you have too much. As for giving the players weapons...check again. Are you sure you didn't get any weapons?[/QUOTE]
I would also like to note, that after making the changes you suggested, it STILL didn't work! Can someone point to me why this doesn't work??
Sorry, you need to Log In to post a reply to this thread.