[QUOTE=P4sca1;48964156]Thanks!
Also, I found this on the GMod Wiki: [url]http://wiki.garrysmod.com/page/Basic_scoreboard_creation[/url]
I'm wondering how to hide the default scoreboard and only show mine?[/QUOTE]
It says there how to? Just override the GM:ScoreboardShow function with your scoreboard drawing code. I guess GM:ScoreboardHide only gets called when the scoreboard is hidden, but you shouldn't need to override that (?)
[QUOTE=MPan1;48964293]It says there how to? Just override the GM:ScoreboardShow function with your scoreboard drawing code. I guess GM:ScoreboardHide only gets called when the scoreboard is hidden, but you shouldn't need to override that (?)[/QUOTE]
So, when I'm not using a hook, I will override that function right?
Didn't thought about that, thanks! :)
Edit: Will hook.Add("ScoreboardShow") still works fine?
If you return true in a ScoreboardShow hook then apparrently it disables the default scoreboard, according to this [URL="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7673.html"]old website[/URL].
Also, what do you mean "when I'm not using a hook, I will override that function right"?
If you're talking about the GM:ScoreboardHide function, you shouldn't need to override it unless you want your scoreboard to draw all the time or something (rather than just when the scoreboard key is pressed).
Note I've never attempted even starting a scoreboard (or tested anything I've said so far) so what I said might be completely wrong, but I'll test it if I need to.
[QUOTE=MPan1;48964442]If you return true in a ScoreboardShow hook then apparrently it disables the default scoreboard, according to this [URL="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7673.html"]old website[/URL].
Also, what do you mean "when I'm not using a hook, I will override that function right"?
If you're talking about the GM:ScoreboardHide function, you shouldn't need to override it unless you want your scoreboard to draw all the time or something (rather than just when the scoreboard key is pressed).
Note I've never attempted even starting a scoreboard (or tested anything I've said so far) so what I said might be completely wrong, but I'll test it if I need to.[/QUOTE]
I'll just try it out when I'm back home. Thanks for your information! :)
[QUOTE=MPan1;48964442]
Note I've never attempted even starting a scoreboard (or tested anything I've said so far) so what I said might be completely wrong, but I'll test it if I need to.[/QUOTE]
Nah, you're right.
Also the logic of making a scoreboard makes a lot more sense once you start working with registered panels.
I was used to just creating a panel within a function with a bunch of local variables, so the first time I tried to make one and referenced the default code, I was really confused.
Once I started experimenting and playing around with [URL="http://wiki.garrysmod.com/page/vgui/RegisterTable"]vgui.RegisterTable[/URL], it sort of clicked for me.
Just thought I'd share in case you're like me and didn't really know where to start.
[QUOTE=DeathWard;48964634]
Once I started experimenting and playing around with [URL="http://wiki.garrysmod.com/page/vgui/RegisterTable"]vgui.RegisterTable[/URL], it sort of clicked for me.
[/QUOTE]
Thanks for the advice! :)
So this function registers a table to use as a panel, but how can I call this panel after registering?
Maybe a dumb question, but I did not get the point of that function yet.
[QUOTE=P4sca1;48964745]Thanks for the advice! :)
So this function registers a table to use as a panel, but how can I call this panel after registering?
Maybe a dumb question, but I did not get the point of that function yet.[/QUOTE]
The default scoreboard has a pretty good example of it. You basically "clone" your template panel by calling it in a variable.
[CODE]panel = vgui.CreateFromTable(PANEL_NAME)[/CODE]
It works identical to the vgui.Create() hook, just with your predefined tables instead.
1.How do I make it so that upon changing class it plays a soundfile clientside.
2.And how do I make it so that you need to become said job, to be another job, NeedToChangeFrom = TEAM_POLICEC doesn't work
[QUOTE=DestroFromPS;48965023]1.How do I make it so that upon changing class it plays a soundfile clientside.[/QUOTE]
I don't think there's a clientside hook for team changing. OnPlayerChangedTeam is serversided unless that's an error.
This is for DarkRP though, right? I haven't hosted it before, but I think you can use [URL="http://wiki.darkrp.com/index.php/Hooks/Client/teamChanged"]teamChanged[/URL] since it says it's a client hook.
[CODE]
hook.Add("ScoreboardShow", "PSB_CL_ScoreboardShow", function()
PSB:show()
return true
end)
hook.Add("ScoreboardHide", "PSB_CL_ScoreboardHide", function()
PSB:hide()
return true
end)
[/CODE]
I tried this. The scoreboard is working, but every other "ScoreboardHide" or "ScoreboardShow" hook, will fail. If I don't return true, the default scoreboard still shows.
I also tried overriting GM:ScoreboardShow() but that end up giving me an error, saying that GM is a nil value.
So what can I do, to just hide the default scoreboard, but keep the Scoreboard Hooks working?
EDIT:
Also, I have a Update function for the PlayerList (DListView).
I want it to be updated all the time, but when I implement it in a PANEL:Think() it is flickering really strange.
Is there any better method?
[QUOTE=DeathWard;48965061]I don't think there's a clientside hook for team changing. OnPlayerChangedTeam is serversided unless that's an error.
This is for DarkRP though, right? I haven't hosted it before, but I think you can use [URL="http://wiki.darkrp.com/index.php/Hooks/Client/teamChanged"]teamChanged[/URL] since it says it's a client hook.[/QUOTE]
It is for DarkRP but in response to the first question, all I want to is how to make it play a soundfile if you change your job
Is there a way to check if a trace is intersecting with a plane?
I don't want util.IntersectRayWithPlane, because that doesn't allow me to specify how long the trace is.
Is ENT:GetNWVarTable() still only available on the development branch (for 10 months+), or has it been scrapped? I want to see all the variables available, but that just errors out.
[QUOTE=P4sca1;48965345][CODE]
hook.Add("ScoreboardShow", "PSB_CL_ScoreboardShow", function()
PSB:show()
return true
end)
hook.Add("ScoreboardHide", "PSB_CL_ScoreboardHide", function()
PSB:hide()
return true
end)
[/CODE]
I tried this. The scoreboard is working, but every other "ScoreboardHide" or "ScoreboardShow" hook, will fail. If I don't return true, the default scoreboard still shows.
I also tried overriting GM:ScoreboardShow() but that end up giving me an error, saying that GM is a nil value.
So what can I do, to just hide the default scoreboard, but keep the Scoreboard Hooks working?
EDIT:
Also, I have a Update function for the PlayerList (DListView).
I want it to be updated all the time, but when I implement it in a PANEL:Think() it is flickering really strange.
Is there any better method?[/QUOTE]
[CODE]function GM:ScoreboardShow()
end
function GM:ScoreboardHide()
end[/CODE]
That should work. You sure your code is completely clientsided?
Regarding the flickering, like I said before, referencing the default scoreboard is a pretty good step in the right direction.
[CODE]if ( self.PName == nil || self.PName != self.Player:Nick() ) then
self.PName = self.Player:Nick()
self.Name:SetText( self.PName )
end[/CODE]
Basically, have it run an if-check to see if there's a difference between the existing value and the real value. If there is, THEN you update/replace it.
[QUOTE=DeathWard;48967759]
That should work. You sure your code is completely clientsided?[/QUOTE]
lua/psb/client/cl_psb.lua:
[CODE]
function GM:ScoreboardShow()
PSB:show()
PSB:PlayerUpdate()
end
function GM:ScoreboardHide()
PSB:hide()
end
[/CODE]
Error:
[CODE]
[ERROR] addons/pscoreboard/lua/psb/client/cl_psb.lua:29: attempt to index global 'GM' (a nil value)
1. unknown - addons/pscoreboard/lua/psb/client/cl_psb.lua:29
2. include - [C]:-1
3. unknown - addons/pscoreboard/lua/autorun/psb_load.lua:47
[/CODE]
Am I dumb? :o
[QUOTE=P4sca1;48969474]lua/psb/client/cl_psb.lua:
[CODE]
function GM:ScoreboardShow()
PSB:show()
PSB:PlayerUpdate()
end
function GM:ScoreboardHide()
PSB:hide()
end
[/CODE]
Error:
[CODE]
[ERROR] addons/pscoreboard/lua/psb/client/cl_psb.lua:29: attempt to index global 'GM' (a nil value)
1. unknown - addons/pscoreboard/lua/psb/client/cl_psb.lua:29
2. include - [C]:-1
3. unknown - addons/pscoreboard/lua/autorun/psb_load.lua:47
[/CODE]
Am I dumb? :o[/QUOTE]
Use hooks for non-gamemode stuff and be sure to add sanity checks to see if the scoreboard element is valid.
----
Is there anyway to offset a dock margin for only one panel and have the rest be normal?
Why won't files named config.lua run when placed in autorun. But does run if I rename them to something else.
Maybe, you already have a file this name.
[QUOTE=LUModder;48969499]Use hooks for non-gamemode stuff and be sure to add sanity checks to see if the scoreboard element is valid.
[/QUOTE]
Then I have the problem, that the default scoreboard is still showing.
[QUOTE=Z0mb1n3;48967036]Is there a way to check if a trace is intersecting with a plane?
I don't want util.IntersectRayWithPlane, because that doesn't allow me to specify how long the trace is.[/QUOTE]
You do want to use that. Just check if the distance between your trace origin and intersection
is bigger than your original trace distance.
[QUOTE=deinemudda32;48971130]Maybe, you already have a file this name.[/QUOTE]Nope.
[QUOTE=CoreWaffle;48971268]Nope.[/QUOTE]
Then Include the file via AddCSLuaFile() and include it in the file you need it.
[QUOTE=deinemudda32;48971939]Then Include the file via AddCSLuaFile() and include it in the file you need it.[/QUOTE]It's in autorun, you don't need to include it.
Does anybody know if the "pp/rt" material used for render target cameras is the same on all clients or only the same on a single client?
How would I make this:
[lua]
local pos = LocalPlayer():EyePos()
hook.Add( "CalcView", "GotoPlayer", function()
local view = {}
local vec = Vector( -50, 0, 0 )
vec:Rotate( att:EyeAngles() )
pos = LerpVector( 0.25, pos, att:EyePos() )
view.origin = pos + vec
view.angles = ( att:GetEyeTrace().HitPos - ( att:GetShootPos() + vec ) ):Angle()
return view
end )
[/lua]
Look at att's face instead of the back of their head?
[QUOTE=meharryp;48974517]How would I make this:
[lua]
local pos = LocalPlayer():EyePos()
hook.Add( "CalcView", "GotoPlayer", function()
local view = {}
local vec = Vector( -50, 0, 0 )
vec:Rotate( att:EyeAngles() )
pos = LerpVector( 0.25, pos, att:EyePos() )
view.origin = pos + vec
view.angles = ( att:GetEyeTrace().HitPos - ( att:GetShootPos() + vec ) ):Angle()
return view
end )
[/lua]
Look at att's face instead of the back of their head?[/QUOTE]
do something like this
[code]vec:Rotate( (att:EyeAngles() + Angle(0, 180, 0)) )[/code]
tweak it a bit and try it out, eventually it should work
[QUOTE=P4sca1;48971208]Then I have the problem, that the default scoreboard is still showing.[/QUOTE]
Return true after the code
I'm trying to put an overlay for CPs in DarkRP but I get this Lua error below [code][ERROR] addons/darkrpmodification-master/lua/darkrp_modules/cphud/cl_cphud.lua:21: attempt to call method 'Team' (a nil value) 1. fn - addons/darkrpmodification-master/lua/darkrp_modules/cphud/cl_cphud.lua:21 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:110 [/code]
Here's the original code
[code]local lastTexture = nil
local mat_Overlay = nil
local lp = LocalPlayer()
local function DrawMaterialOverlay2( texture, refractamount )
if ( texture ~= lastTexture or mat_Overlay == nil ) then
mat_Overlay = Material( texture )
lastTexture = texture
end
if ( mat_Overlay == nil || mat_Overlay:IsError() ) then return end
render.UpdateScreenEffectTexture()
// FIXME: Changing refract amount affects textures used in the map/models.
mat_Overlay:SetFloat( "$envmap", 0 )
mat_Overlay:SetFloat( "$envmaptint", 0 )
mat_Overlay:SetFloat( "$refractamount", refractamount )
mat_Overlay:SetInt( "$ignorez", 1 )
render.SetMaterial( mat_Overlay )
render.DrawScreenQuad()
end
local function DrawInternal2()
local overlay = "effects/combine_binocoverlay"
if lp:Team() != TEAM_POLICE then return end
DrawMaterialOverlay2( overlay, 0.3 )
end
hook.Add( "RenderScreenspaceEffects", "RenderMaterialOverlay", DrawInternal2 )[/code]
[QUOTE=SimonDEV;48974802]I'm trying to put an overlay for CPs in DarkRP but I get this Lua error below [code][ERROR] addons/darkrpmodification-master/lua/darkrp_modules/cphud/cl_cphud.lua:21: attempt to call method 'Team' (a nil value) 1. fn - addons/darkrpmodification-master/lua/darkrp_modules/cphud/cl_cphud.lua:21 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:110 [/code]
Here's the original code
[code]local lastTexture = nil
local mat_Overlay = nil
local lp = LocalPlayer()
local function DrawMaterialOverlay2( texture, refractamount )
if ( texture ~= lastTexture or mat_Overlay == nil ) then
mat_Overlay = Material( texture )
lastTexture = texture
end
if ( mat_Overlay == nil || mat_Overlay:IsError() ) then return end
render.UpdateScreenEffectTexture()
// FIXME: Changing refract amount affects textures used in the map/models.
mat_Overlay:SetFloat( "$envmap", 0 )
mat_Overlay:SetFloat( "$envmaptint", 0 )
mat_Overlay:SetFloat( "$refractamount", refractamount )
mat_Overlay:SetInt( "$ignorez", 1 )
render.SetMaterial( mat_Overlay )
render.DrawScreenQuad()
end
local function DrawInternal2()
local overlay = "effects/combine_binocoverlay"
if lp:Team() != TEAM_POLICE then return end
DrawMaterialOverlay2( overlay, 0.3 )
end
hook.Add( "RenderScreenspaceEffects", "RenderMaterialOverlay", DrawInternal2 )[/code][/QUOTE]
you're probably calling LocalPlayer before InitPostEntity is called, make sure this stuff is called after
[QUOTE=LUModder;48974785]Return true after the code[/QUOTE]
Tried that.
Other "ScoreboardShow" hooks semmed not to work afterwards anymore.
Sorry, you need to Log In to post a reply to this thread.