Server Data To Client File - Restricting Respawn

1. Server Data To Client File
For this I was trying to use the OnPlayerChangedTeam hook so that when the player changes team, it will send the players nickname and name of the new team to a client file so that I can then run
[lua]chat.AddText(
Color(50,50,50), LocalPlayer():Nick(),
Color(255,255,255), " Joined Team ",
team.GetColor( LocalPlayer():Team() ), team.GetName( LocalPlayer():Team() )
)[/lua]

Because as it stand I have this running fine, but when someone presses my change team derma button and the function is run, this will print the players own name and team, not who changed

2. Restricting Respawn
I’m trying to make it so that when a player dies, a spawn timer will be shown and the player cannot respawn themselves until the time is up and I know that I need to run the code in THIS hook
However they are still able to press keys and respawn manually before the timer has finished, so any help with disabling that please?

Hope people have some ideas, thanks :slight_smile:

player.OnPlayerChangedTeam is serverside
chat.Addtext is clientside

[lua]
if SERVER then
hook.Add(“OnPlayerChangedTeam”,“PrintStuff”,function(p,o,n)
umsg.Start(“pct”)
umsg.String(p:Nick())
umsg.String(team.GetColor(n))
umsg.String(team.GetName(n))
umsg.End()
end
elseif CLIENT then
local function ChatTeamHook(um)
chat.AddText(
Color(50,50,50),
um:ReadString(), – p = player nick
Color(255,255,255),
" Joined Team ",
um:ReadString(), – the color of the new team
um:ReadString() – the name of the new team
)
end
usermessage.Hook(“pct”,ChatTeamHook)
end
[/lua]
Untested.

Yeah, I know that they are different sides, that’s why I needed to know how to send the server data to the client
Didn’t realise I could do it with usermessages, seeing as though thats how I’m sending it at the moment
Anyways, I’ll try it later, thanks a lot :slight_smile:

EDIT
It didn’t work :l

1 Day Bump

Please people, the code Zzaacckk gave me doesn’t work, any tips on fixing it

And also what about my second point?

Return anything but nil in the PlayerDeathThink hook to stop people from spawning.

Nice, I’ll give that a go thanks :smiley: