Just curious, how would I make it so when a player joins a team they are given a random player model from a list.
This is the base code I'm using.
[lua]
function plymodels( ply )
if ply:Team() == 1 then
ply:SetModel( "models/justgolf/temale_02.mdl" )
end
if ply:Team() == 4 then
ply:SetModel( "models/justgolf/tale_09.mdl" )
end
end
[/lua]
Untested, place the models in the table Models.
[lua]
local function plymodels( ply )
local Models = {
"Place your models here"
}
if ( ply:Team() == 1 ) then
ply:SetModel( table.Random( Models ) )
elseif ( ply:Team() == 4 ) then
ply:SetModel( table.Random( Models ) )
end
end
[/lua]
Thank you very much!
[editline]01:00AM[/editline]
Now I get a gamemode error.
[lua]
local function plymodels( ply )
local Models = { "models/justgolf/tale_07.mdl", "models/justgolf/tale_03.mdl", "models/justgolf/temale_02.mdl", "models/justgolf/temale_07.mdl" }
if ( ply:Team() == 1 ) then
ply:SetModel( table.Random( Models ) )
elseif ( ply:Team() == 4 ) then
ply:SetModel( "models/justgolf/tale_09.mdl" )
end
end
[/lua]
And it doesn't tell me where lol
(and yes the models are named tale and temale)
[editline]01:05AM[/editline]
Wait.. found it.
Not model related.
Get it sorted out?
Yeah, now I just need to get the rest of my gamemode to work.
I think my codes all screwed up.
Post any questions here, we are glad to help.
Well for starters my intro menu doesn't show
My cl_init.lua
[lua]
include( 'shared.lua' )
function set_team()
Ready = vgui.Create( "DFrame" )
Ready:SetPos( ScrW() / 2, ScrH() / 2 )
Ready:SetSize( 175, 75 )
Ready:SetTitle( "Are you ready to golf?" )
Ready:SetVisible( true )
Ready:SetDraggable( false )
Ready:ShowCloseButton( false )
Ready:MakePopup()
ready1 = vgui.Create( "DButton", Ready )
ready1:SetPos( 20, 25 )
ready1:SetSize( 140, 40 )
ready1:SetText( "Let's golf!" )
ready1.DoClick = function()
RunConsoleCommand( "sb_team1" )
end
end
concommand.Add( "sb_start", set_team )
[/lua]
and my base gamemode works as far as teams goes but not the camera
init.lua
[lua]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "special.lua" )
function GM:PlayerSpawn( ply ) //What happens when the player spawns
self.BaseClass:PlayerSpawn( ply )
ply:SetGravity( 0.75 )
ply:SetMaxHealth( 100, true )
ply:SetWalkSpeed( 225 )
ply:SetRunSpeed( 325 )
end
local function plymodels( ply )
local Models = { "models/justgolf/tale_07.mdl", "models/justgolf/tale_03.mdl", "models/justgolf/temale_02.mdl", "models/justgolf/temale_07.mdl" }
if ( ply:Team() == 1 ) then
ply:SetModel( table.Random( Models ) )
elseif ( ply:Team() == 4 ) then
ply:SetModel( "models/justgolf/tale_09.mdl" )
end
end
function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?
ply:Give( "weapon_physcannon" )
ply:Give( "weapon_physgun" )
ply:Give( "golfclub" )
ply:Give( "gmod_tool" )
end
function sb_team1( ply )
ply:UnSpectate()
ply:SetTeam( 1 )
ply:Spawn()
ply:PrintMessage( HUD_PRINTTALK, "Don't forget to patch your chips " .. ply:Nick() )
end
function sb_team2( ply )
ply:Spectate( 5 )
ply:SetTeam( 2 )
end
concommand.Add( "sb_team1", sb_team1 )
function joining( ply )
ply:Spectate( 5 )
ply:SetTeam( 3 )
RunConsoleCommand( "sb_start" )
end
function GM:CalcView(ply, origin, angles, fov)
if (!ply:Alive() || !ply.ThirdPersonB) then
return;
end
local viewdistance = 126;
local vec = ply:GetAimVector();
local org = (vec * -viewdistance);
local tr = util.QuickTrace(origin, org, ply);
org = ((tr.Hit && (tr.HitPos + (vec * 8))) || tr.HitPos);
local view = {};
view.origin = org;
view.angles = angles;
return view;
end
local function ToggleTP(ply, cmd, args)
ply.ThirdPersonB = (!ply.ThirdPersonB || true);
end
concommand.Add("ToggleTP", ToggleTP);
[/lua]
Add this to GM:PlayerSpawn
[lua]
ply:ConCommand( "sb_start" )
[/lua]
Not sure about the thirdperson, I will have to look at it some more.
now my intro dframe won't dissapear
Ready:ShowCloseButton( false )
You don't let it show the CloseButton. Take that part out and you can exit out of the frame.
but that defeats the purpose of my other button to set team
Sorry, you need to Log In to post a reply to this thread.