I'm trying to make teams so when it assigns you to a team it turns your model red or blue depending on team but in game it turns out as a grey player model.
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
include("player.lua")
function GM:PlayerConnect( name, ip)
print("Player " .. name .. " has joined the game")
end
function GM:PlayerInitialSpawn(ply)
print("Player " .. ply:Nick() .. " has spawned")
BroadcastMsg(Color(0,255,255),"Player " .. ply:Nick() .. " has joined the game")
function GM:PlayerAuthed(ply, steamID, uniqueID)
print("Player " .. ply:Nick() .. " has recieved Authed")
end
function GM:PlayerLoadout(ply)
local teamID = team.BestAutoJoinTeam()
ply:SetTeam(teamID)
if teamID == TEAM_RED then
ply:SetPlayerColor(Vector(1,0,0))
else
ply:setPlayerColor(Vector(0,0,1))
end
end[/CODE]
[CODE]GM.Name = "Skeleton"
GM.Author = "N/A"
GM.Email = "N/A"
GM.Website = "N/A"
function GM:Initialize()
self.BaseClass.Initialize( self )
end
if SERVER then
AddCSLuaFile()
local PLAYER = FindMetaTable("Player")
util.AddNetworkString( "ColoredMessage" )
function BroadcastMsg(...)
local args = {...}
net.Start("ColoredMessage")
net.WriteTable(args)
net.Broadcast()
end
function PLAYER:PlayerMsg(...)
local args = {...}
net.Start("ColoredMessage")
net.WriteTable(args)
net.Send(self)
end
elseif CLIENT then
net.Receive("ColoredMessage",function(len)
local msg = net.ReadTable()
chat.AddText(unpack(msg))
chat.PlaySound()
end)
end
team.SetUp(TEAM_RED, "Red Team", Color(0, 0, 255))
team.SetUp(TEAM_BLUE, "Blue Team", Color(255, 0, 0))
[/CODE]
That's because you aren't asigning them a model. Player's get the Grey Model when they aren't given a player model.
[CODE]function GM:PlayerSetModel(ply)
ply:SetModel("models/player/group01/male_07.mdl")
end
[/CODE]
I added this to init but it still didn't make any difference
PlayerSetModel doesn't get called if you overwrite PlayerSpawn. You can try calling the ply:SetModel() functions in your Loadout function, right before you set the player's color.
Thanks the model is working now but the color of the model still isn't working ( red and blue) for the teams.
[QUOTE=alex578344;45843854]Thanks the model is working now but the color of the model still isn't working ( red and blue) for the teams.[/QUOTE]
Change 'setPlayerColor' to '[B]S[/B]etPlayerColor'.
Oh it turns out both PlayerLoadout and PlayerSetModel don't get called when you override PlayerSpawn. Either move your stuff there you can call GAMEMODE:PlayerLoadout( ply ) inside PlayerSpawn.
I tried to understand what to do but it still doesn't work.
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
include("player.lua")
function GM:PlayerConnect( name, ip)
print("Player " .. name .. " has joined the game")
end
function GM:PlayerSpawn(ply)
ply:SetModel("models/player/group01/male_07.mdl")
local teamID = team.BestAutoJoinTeam()
ply:SetTeam(teamID)
if teamID == TEAM_RED then
ply:SetPlayerColor(Vector(1,0,0))
else
ply:SetPlayerColor(Vector(0,0,1))
end
end
function GM:PlayerInitialSpawn(ply)
print("Player " .. ply:Nick() .. " has spawned")
BroadcastMsg(Color(0,255,255),"Player " .. ply:Nick() .. " has joined the game")
end
function GM:PlayerAuthed(ply, steamID, uniqueID)
print("Player " .. ply:Nick() .. " has recieved Authed")
end
[/CODE]
Can anyone help me?
Sorry, you need to Log In to post a reply to this thread.