I've created a message to show the player when they join the server but the message is in blue. I'm trying to change the color to white but I keep getting errors.
Code:
[lua] function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() then
ply:PrintMessage( HUD_PRINTTALK, "Admin, " .. ply:Nick() .. " is now playing. \nTheir SteamID is \n" .. ply:SteamID() )
else
ply:PrintMessage( HUD_PRINTTALK, "Welcome, " .. ply:Nick() .. " is now playing. \nTheir SteamID is " ..ply:SteamID() )
ply:ConCommand( "team_change_menu" )
end[/lua]
Not sure if there's a way to do it server--side, but there's a client side chat.AddText() that takes any number of colour and string arguments
eg chat.AddText( Color(255,0,0), "This is red! ", Color(0,255,0), "This is green!")
You could use usermessages to trigger it on the client, but there's probably a more efficient way
lua/autorun/util.lua
[lua]
if SERVER then
AddCSLuaFile("util.lua")
chat = { }
function chat.AddText( ... )
if ( type( arg[1] ) == "Player" ) then ply = arg[1] end
if !ply:IsValid() then return end
umsg.Start( "AddText", ply )
umsg.Short( #arg )
for _, v in pairs( arg ) do
if ( type( v ) == "string" ) then
umsg.String( v )
elseif ( type ( v ) == "table" ) then
umsg.Short( v.r )
umsg.Short( v.g )
umsg.Short( v.b )
umsg.Short( v.a )
end
end
umsg.End( )
end
else
usermessage.Hook( "AddText", function( um )
local argc = um:ReadShort( )
local args = { }
for i = 1, argc / 2, 1 do
table.insert( args, Color( um:ReadShort( ), um:ReadShort( ), um:ReadShort( ), um:ReadShort( ) ) )
table.insert( args, um:ReadString( ) )
end
chat.AddText( unpack( args ) )
end )
end
[/lua]
Server: chat.AddText(player, Color(), text, Color(), text, ...)
Credits to Overv.
[QUOTE=SammyServers;34342343]lua/autorun/util.lua
[snip]
Server: chat.AddText(player, Color(), text, Color(), text, ...)
Credits to Overv.[/QUOTE]
So would this go like, Deathrun/lua/autorun/util.lua?
If you include util.lua in your gamemode, yes.
Sorry, you need to Log In to post a reply to this thread.