I want to add chat tags for dark rp, but it didnt work:
local function AddToChat(msg)
local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())
local name = msg:ReadString()
local ply = msg:ReadEntity()
local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())
local text = msg:ReadString()
local rank_str, rank_col
if ply:IsSuperAdmin() then
rank_str = " [Superadmin]"
rank_col = Color( 255, 0, 0 ) -- red for example
elseif ply:IsAdmin() then
rank_str = " [Admin] "
rank_col = Color( 0, 255, 0 ) -- green
else
rank_str = ""
rank_col = Color( 255, 255, 255 )
end
if text and text ~= "" then
chat.AddText(col1, name, rank_col, rank_str, col2, ": " .. text)
if ValidEntity(ply) then
hook.Call("OnPlayerChat", nil, ply, text, false, ply:Alive())
end
else
chat.AddText(col1, name)
hook.Call("ChatText", nil, "0", name, name, "none")
end
chat.PlaySound()
end
usermessage.Hook( "DarkRP_Chat", AddToChat )
Whats wrong with this? i added it in cl_init.lua
its from an old facepunch thread....
help please
Also tell me how to add custom groups :D
[editline]23rd December 2012[/editline]
help :D
First off, stop with the ":D" please.
Secondly, post the entire cl_init.lua file in [ code ] brackets.
Thirdly, make sure that you indent properly, as it is, that looks horrendous and just looking at it I can see multiple little errors because it's just plain not-right lua syntax. For instance, ValidEntity was changed to IsValid pretty recently.
I'll ignore my unending hatred for DarkRP and help, but you need to post it in code brackets so it's even remotely readable.
[lua]GM.Version = "2.4.3"
GM.Name = "DarkRP"
GM.Author = "By Rickster, Updated: Pcwizdan, Sibre, philxyz, [GNC] Matt, Chrome Bolt, FPtje Falco, Eusion, Drakehawke"
DeriveGamemode("sandbox")
util.PrecacheSound("earthquake.mp3")
CUR = "Hullas: "
/*---------------------------------------------------------------------------
Fonts
---------------------------------------------------------------------------*/
surface.CreateFont ("DarkRPHUD1", {
size = 16,
weight = 600,
antialias = true,
shadow = true,
font = "DejaVu Sans"})
surface.CreateFont ("DarkRPHUD2", {
size = 23,
weight = 400,
antialias = true,
shadow = false,
font = "coolvetica"})
/*---------------------------------------------------------------------------
Names
---------------------------------------------------------------------------*/
-- Make sure the client sees the RP name where they expect to see the name
local pmeta = FindMetaTable("Player")
pmeta.SteamName = pmeta.SteamName or pmeta.Name
function pmeta:Name()
if not self or not self.IsValid or not IsValid(self) then return "" end
self.DarkRPVars = self.DarkRPVars or {}
if not GAMEMODE.Config.allowrpnames then
return self:SteamName()
end
return self.DarkRPVars.rpname and tostring(self.DarkRPVars.rpname) or self:SteamName()
end
pmeta.GetName = pmeta.Name
pmeta.Nick = pmeta.Name
-- End
function GM:DrawDeathNotice(x, y)
if not GAMEMODE.Config.showdeaths then return end
self.BaseClass:DrawDeathNotice(x, y)
end
local function DisplayNotify(msg)
local txt = msg:ReadString()
GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
surface.PlaySound("buttons/lightswitch2.wav")
-- Log to client console
print(txt)
end
usermessage.Hook("_Notify", DisplayNotify)
local function LoadModules()
local root = GAMEMODE.FolderName.."/gamemode/modules/"
local _, folders = file.Find(root.."*", "LUA")
for _, folder in SortedPairs(folders, true) do
for _, File in SortedPairs(file.Find(root .. folder .."/cl_*.lua", "LUA"), true) do
include(root.. folder .. "/" ..File)
end
for _, File in SortedPairs(file.Find(root .. folder .."/sh_*.lua", "LUA"), true) do
include(root.. folder .. "/" ..File)
end
end
end
LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
for k,v in pairs(player.GetAll()) do
v.DarkRPVars = v.DarkRPVars or {}
end
GM.Config = {} -- config table
include("config.lua")
include("client/help.lua")
include("client/DRPDermaSkin.lua")
include("client/helpvgui.lua")
include("client/hud.lua")
include("client/showteamtabs.lua")
include("client/vgui.lua")
include("shared/animations.lua")
include("shared/commands.lua")
include("shared/entity.lua")
include("shared/language.lua")
include("shared/MakeThings.lua")
include("shared/Workarounds.lua")
include("shared.lua")
include("addentities.lua")
include("ammotypes.lua")
include("fpp/sh_settings.lua")
include("fpp/client/FPP_Menu.lua")
include("fpp/client/FPP_HUD.lua")
include("fpp/client/FPP_Buddies.lua")
include("fpp/sh_CPPI.lua")
surface.CreateFont("AckBarWriting", {
size = 20,
weight = 500,
antialias = true,
shadow = false,
font = "akbar"})
-- Copy from FESP(made by FPtje Falco)
-- This is no stealing since I made FESP myself.
local vector = FindMetaTable("Vector")
function vector:RPIsInSight(v, ply)
ply = ply or LocalPlayer()
local trace = {}
trace.start = ply:EyePos()
trace.endpos = self
trace.filter = v
trace.mask = -1
local TheTrace = util.TraceLine(trace)
if TheTrace.Hit then
return false, TheTrace.HitPos
else
return true, TheTrace.HitPos
end
end
function GM:HUDShouldDraw(name)
if name == "CHudHealth" or
name == "CHudBattery" or
name == "CHudSuitPower" or
(HelpToggled and name == "CHudChat") then
return false
else
return true
end
end
function GM:HUDDrawTargetID()
return false
end
function GM:FindPlayer(info)
if not info or info == "" then return nil end
local pls = player.GetAll()
for k = 1, #pls do -- Proven to be faster than pairs loop.
local v = pls[k]
if tonumber(info) == v:UserID() then
return v
end
if info == v:SteamID() then
return v
end
if string.find(string.lower(v:SteamName()), string.lower(tostring(info)), 1, true) ~= nil then
return v
end
if string.find(string.lower(v:Name()), string.lower(tostring(info)), 1, true) ~= nil then
return v
end
end
return nil
end
local GUIToggled = false
local HelpToggled = false
local HelpVGUI
local function ToggleHelp()
if not HelpVGUI then
HelpVGUI = vgui.Create("HelpVGUI")
end
HelpToggled = not HelpToggled
HelpVGUI.HelpX = HelpVGUI.StartHelpX
HelpVGUI:SetVisible(HelpToggled)
gui.EnableScreenClicker(HelpToggled)
end
usermessage.Hook("ToggleHelp", ToggleHelp)
local function ToggleClicker()
GUIToggled = not GUIToggled
gui.EnableScreenClicker(GUIToggled)
end
usermessage.Hook("ToggleClicker", ToggleClicker)
local function DoSpecialEffects(Type)
local thetype = string.lower(Type:ReadString())
local toggle = tobool(Type:ReadString())
if toggle then
if thetype == "motionblur" then
hook.Add("RenderScreenspaceEffects", thetype, function()
DrawMotionBlur(0.05, 1.00, 0.035)
end)
elseif thetype == "dof" then
DOF_SPACING = 8
DOF_OFFSET = 9
DOF_Start()
elseif thetype == "colormod" then
hook.Add("RenderScreenspaceEffects", thetype, function()
local settings = {}
settings[ "$pp_colour_addr" ] = 0
settings[ "$pp_colour_addg" ] = 0
settings[ "$pp_colour_addb" ] = 0
settings[ "$pp_colour_brightness" ] = -1
settings[ "$pp_colour_contrast" ] = 0
settings[ "$pp_colour_colour" ] =0
settings[ "$pp_colour_mulr" ] = 0
settings[ "$pp_colour_mulg" ] = 0
settings[ "$pp_colour_mulb" ] = 0
DrawColorModify(settings)
end)
elseif thetype == "drugged" then
hook.Add("RenderScreenspaceEffects", thetype, function()
DrawSharpen(-1, 2)
DrawMaterialOverlay("models/props_lab/Tank_Glass001", 0)
DrawMotionBlur(0.13, 1, 0.00)
end)
elseif thetype == "deathpov" then
hook.Add("CalcView", "rp_deathPOV", function(ply, origin, angles, fov)
local Ragdoll = ply:GetRagdollEntity()
if not IsValid(Ragdoll) then return end
local head = Ragdoll:LookupAttachment("eyes")
head = Ragdoll:GetAttachment(head)
if not head or not head.Pos then return end
local view = {}
view.origin = head.Pos
view.angles = head.Ang
view.fov = fov
return view
end)
end
elseif toggle == false then
if thetype == "dof" then
DOF_Kill()
return
elseif thetype == "deathpov" then
if hook.GetTable().CalcView and hook.GetTable().CalcView.rp_deathPOV then
hook.Remove("CalcView", "rp_deathPOV")
end
return
end
hook.Remove("RenderScreenspaceEffects", thetype)
end
end
usermessage.Hook("DarkRPEffects", DoSpecialEffects)
local Messagemode = false
local playercolors = {}
local HearMode = "talk"
local isSpeaking = false
local GroupChat = false
local function RPStopMessageMode()
Messagemode = false
hook.Remove("Think", "RPGetRecipients")
hook.Remove("HUDPaint", "RPinstructionsOnSayColors")
playercolors = {}
end
local function CL_IsInRoom(listener) -- IsInRoom function to see if the player is in the same room.
local tracedata = {}
tracedata.start = LocalPlayer():GetShootPos()
tracedata.endpos = listener:GetShootPos()
local trace = util.TraceLine( tracedata )
return not trace.HitWorld
end
local PlayerColorsOn = CreateClientConVar("rp_showchatcolors", 1, true, false)
local function RPSelectwhohearit(group)
if PlayerColorsOn:GetInt() == 0 then return end
Messagemode = true
GroupChat = group
hook.Add("HUDPaint", "RPinstructionsOnSayColors", function()
local w, l = ScrW()/80, ScrH() /1.75
local h = l - (#playercolors * 20) - 20
local AllTalk = GAMEMODE.Config.alltalk
if #playercolors <= 0 and ((HearMode ~= "talk through OOC" and HearMode ~= "advert" and not AllTalk) or (AllTalk and HearMode ~= "talk" and Hea
When I said [ lua ] tags, it means but them in between [ lua ] and [ /lua ], without the spaces between the words 'lua' and the ends of the bracket, you'll get something like
[lua] this.
as you can see
it saves the style,
function( so its easy to read) [/lua]
happy?
You totally don't understand lua at all and I recommend you don't try to set up a server, we have tons of DarkRP servers run by little kids that you can flock to that don't have issues like this. It's nice to know this is the quality of server owner that makes up Gmod still. There are a couple of issues with the code, first of all, the entire structure isn't indented which makes it a pain to read, secondly, the function isn't set up correctly at all, because you're missing like half of the ';'s and so on, thirdly, I'll fix it for you but please, I implore you, don't run a DarkRP server, or a server at all.
@ Loriborn Pardon the accidental 'dissagree'. I completley agree with you.
why would i post it here if i knew Lua? You're basicly saying everyone who's not good at lua cant run a dark rp server. I dont like that at all.
why dont u go play lego if you dont like the servers?
[QUOTE=levicheater;38945146]why would i post it here if i knew Lua? You're basicly saying everyone who's not good at lua cant run a dark rp server. I dont like that at all.
why dont u go play lego if you dont like the servers?[/QUOTE]
No he's saying we already have enough darkrp servers filled with people who can't code for shit.
Also samg381 you can just rerate the post
0But why u say it on my thread? There are tons of questions such like how to make a job...
So anyone ?
Bump
-snip-
because poorly expressed as an opinion
Idea of previous message: stop being rude.
Sorry, you need to Log In to post a reply to this thread.