I have been working on a gamemode and I want to change the player color according to the team. How do I do this? If you need the init.lua I will happily put it in this thread.
[CODE]
testblcolour = {
1 = COLOR HERE,
2 = etc,
3 = etc,
4 = etc,
5 = etc,
6 = etc
}
function GM:PlayerSpawn(pl)
if !pl:IsValid then return end
local tm = testtblcolour[pl:Team()]
if (tm) then
local colour = tm[1]
pl:SetColor(colour)
end
end
[/CODE]
This should work, just fill in the table with the colours and add teams as nessesary.
Cant be sure though as im still a lua scrub and i cant test it right now.
[QUOTE=The_Dirty_Kek;52229182][CODE]
testblcolour = {
1 = COLOR HERE,
2 = etc,
3 = etc,
4 = etc,
5 = etc,
6 = etc
}
function GM:PlayerSpawn(pl)
if !pl:IsValid then return end
local tm = testtblcolour[pl:Team()]
if (tm) then
local colour = tm[1]
pl:SetColor(colour)
end
end
[/CODE]
This should work, just fill in the table with the colours and add teams as nessesary.
Cant be sure though as im still a lua scrub and i cant test it right now.[/QUOTE]
Sorry but it does not work! Infact it breaks my player model!
[QUOTE=benjaminpants;52229196]Sorry but it does not work! Infact it breaks my player model![/QUOTE]
[CODE]local testblcolour = {
1 = { red, green, blue },
2 = etc,
3 = etc,
4 = etc,
5 = etc,
6 = etc
}
function GM:PlayerSpawn(pl)
if !pl:IsValid then return end
local tm = testtblcolour[pl:Team()]
if (tm) then
local r = tm[1]
local g = tm[2]
local b = tm[3]
pl:SetColor(r, g, b)
end
end
[/CODE]
Try that. Though to be completely honest lad if you can figure out a simple problem like this i dont know how exactly you're going to fare making an entire game mode.
[QUOTE=The_Dirty_Kek;52229237][CODE]local testblcolour = {
1 = { red, green, blue },
2 = etc,
3 = etc,
4 = etc,
5 = etc,
6 = etc
}
function GM:PlayerSpawn(pl)
if !pl:IsValid then return end
local tm = testtblcolour[pl:Team()]
if (tm) then
local r = tm[1]
local g = tm[2]
local b = tm[3]
pl:SetColor(r, g, b)
end
end
[/CODE]
Try that. Though to be completely honest lad if you can figure out a simple problem like this i dont know how exactly you're going to fare making an entire game mode.[/QUOTE]
Its still broken. When this script is not on the playermodel is fine. But when it is on it sets the playermodel the a broken blob
[QUOTE=Promptitude;52229275]Use: [url]http://wiki.garrysmod.com/page/Player/SetPlayerColor[/url][/QUOTE]
Ummm How? I tried to copy and paste some code but it does not work.
Sorry, you need to Log In to post a reply to this thread.