umsg is doing something strage

Am i doing something wrong. When a player joins I want the server to print in the chat there name. Right now when i join it says “[Server]: Admin �08:���6� ,� has joined!”

The fallowing is in init.lua

[lua]
function PlayerJoinMsg(pl, command, args)
local name = args[1]

--chat.AddText( Color(0,140,255), "[Server]: ", Color(255,255,255), "Player ".. name .." has joined the server!" )
for k, v in pairs(player.GetAll()) do
	if v:Nick() == name then
		umsg.Start("PlayerJoin")
			umsg.String( v:Nick() )
			umsg.Bool( v:IsAdmin() )
		umsg.End()
	end
end

end
concommand.Add( “PlayerJoinMsg”, PlayerJoinMsg )
[/lua]

from cl_init.lua

[lua]
local function PlayerJoin( data )
if data:ReadBool() then
chat.AddText( Color(0,140,255), "[Server]: ", Color(255,255,255), "Admin “, (data:ReadString()), " has joined!” )
else
chat.AddText( Color(0,140,255), "[Server]: ", Color(255,255,255), "Player “, (data:ReadString()), " has joined!” )
end
end
usermessage.Hook( “PlayerJoin”, PlayerJoin )
[/lua]


// Server
local function PlayerJoinMessage(Player)
	 umsg.Start("PlayerJoin")
		umsg.String( Player:Nick() )
		umsg.Bool( Player:IsAdmin() )
	umsg.End()
end
hook.Add("PlayerInitialSpawn", "PlayerJoinMessage", PlayerJoinMessage)


// Client
local function PlayerJoinMessage(U)
	local Message = U:ReadString()
	local Admin = U:ReadBool()
	
	if Admin then
		chat.AddText( Color(0,140,255), "[Server]: ", Color(255,255,255), "Admin " .. Message .. " has joined!")
        else
                chat.AddText( Color(0,140,255), "[Server]: ", Color(255,255,255), "Player " .. Message .. " has joined!")
	end
end
usermessage.Hook("PlayerJoin", PlayerJoinMessage)



See if that works.

fucking ninja’d

Thanks that worked

For future reference you need to read the variables in the same order that you write them.

You don’t need to send a bool to see if the player is an admin since player:IsAdmin() is shared.