[QUOTE=DarthTealc;48515795]:words:[/QUOTE]
Assuming you're running that outside the gamemode folder,
[CODE]
local oSyncGlobals = GAMEMODE.SyncGlobals--no GM table outside the gamemode/ folder
GAMEMODE.SyncGlobals = function(GM,...)
local returnValue = oSyncGlobals(GM,...)--call the original function
--do stuff here
return returnValue--return what's supposed to be returned
end
[/CODE]
[QUOTE=DarthTealc;48515795]Is there a way to detour a Gamemode function but run the original function in it? TTT has a function called "GM:SyncGlobals()", I want to have additional code run at the end (without copypasting the original function, and without editing the default TTT file)for example:
[code]hook.Add("SyncGlobals", "DetourSyncGlobals", function()
hook.BaseRun() -- something to call the original function?
MsgN("Extra thing to run afterwards")
end)[/code][/QUOTE]
That's not a detour, and if you want to call the base function then call GM:SyncGlobals(). If you don't return anything in that hook of yours, the gamemode's SyncGlobals function will be called again, because that's how the hook system works.
This is a detour.
[lua]local SyncGlobals = GM.SyncGlobals
function GM:SyncGlobals(...)
local value = SyncGlobals(self, ...)
print("Hello I am ran afterwards")
return value
end[/lua]
How can I make it so when a Derma Panel is opened, it opens to a specific DPropertySheet, I can't find anything on the wiki about it
[QUOTE=Gamz365;48516138]How can I make it so when a Derma Panel is opened, it opens to a specific DPropertySheet, I can't find anything on the wiki about it[/QUOTE]
Why not just make the first Sheet the one you want them to see?
[QUOTE=JasonMan34;48516149]Why not just make the first Sheet the one you want them to see?[/QUOTE]
Becuase a lazy way to refresh a menu is to close it and reopen it.
[QUOTE=Gamz365;48516138]How can I make it so when a Derma Panel is opened, it opens to a specific DPropertySheet, I can't find anything on the wiki about it[/QUOTE]
Just call the following when your panel is opened:
[CODE]DPropertySheet:SetActiveTab(tabObj)[/CODE]
[QUOTE=Hoffa1337;48515815]Ok so colors are working as they should but I get spammed with "SetBonePosition: Bone is unwritable"
...
What am I missing ?[/QUOTE]
Great question. Never heard of that error before. But, as cheesy as it sounds, I just followed the way TTT did their death ragdolls.
[url]https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/gamemodes/terrortown/gamemode/corpse.lua#L409[/url]
[lua]-- position the bones
local num = rag:GetPhysicsObjectCount()-1
local v = ply:GetVelocity()
-- bullets have a lot of force, which feels better when shooting props,
-- but makes bodies fly, so dampen that here
if dmginfo:IsDamageType(DMG_BULLET) or dmginfo:IsDamageType(DMG_SLASH) then
v = v / 5
end
for i=0, num do
local bone = rag:GetPhysicsObjectNum(i)
if IsValid(bone) then
local bp, ba = ply:GetBonePosition(rag:TranslatePhysBoneToBone(i))
if bp and ba then
bone:SetPos(bp)
bone:SetAngles(ba)
end
-- not sure if this will work:
bone:SetVelocity(v)
end
end[/lua]
:snip:
[QUOTE=Wob wob wob!;48517483]Been dabbling with [URL="http://wiki.garrysmod.com/page/DColorMixer"]DColorMixer[/URL] and trying to use it with setting team colors. It works fine when I don't touch the "Mixer". But as soon as I drag the color-mixer around, [URL="http://wiki.garrysmod.com/page/DColorMixer/GetColor"]DColorMixer:GetColor()[/URL] will return a table. When printing this table with [URL="http://wiki.garrysmod.com/page/table/ToString"]table.ToString[/URL] I see it doesn't really change either. It's still just the default, red, starting color.
Am I using DColorMixer the wrong way when trying to do GetColor()?[/QUOTE]
It's hard to say when you post 0 code.
Guys, I recently installed a mod that broke a lot of my soundfiles (sound of shooting, walking, and some animations). The mod was an outdated cinematic mod with fakefactory stuff. I uninstalled it, but the sounds, of course, didn't return back to normal. What do I have to do to get stuff like hl2/gmod sound and animations to work again? Reinstall hl2 or garry's mod? Or is there a simpler fix for this.
Delete scripts folder in GMod and validate the game.
Thanks, that worked.
[editline]22nd August 2015[/editline]
Wait, it didn't completely work, sound works fine but citizen's animations are still screwed up though.
This isn't too big of a problem, but for some reason specific servers don't allow me from using the Bloom effect. Whenever I try to render bloom it simply doesn't work but will work fine on a clean sandbox server. Is this some sort of setting I'm missing?
Trying to play a sound file to the client once they connect.
Tried playing it through server, returns "Create Stream Failed error 41."
Tried going into singplayer, placed sound file in garrysmod/garrysmod/sound folder. Used play sound/intro.mp3 in console to try and play sound, returned "Create Stream Failed error 41"
Idk why it's not playing it. It's telling me these files do not exist in their location, even though I point directly to its location and filename.
[QUOTE=Fujitechs;48518811]Trying to play a sound file to the client once they connect.
Tried playing it through server, returns "Create Stream Failed error 41."
Tried going into singplayer, placed sound file in garrysmod/garrysmod/sound folder. Used play sound/intro.mp3 in console to try and play sound, returned "Create Stream Failed error 41"
Idk why it's not playing it. It's telling me these files do not exist in their location, even though I point directly to its location and filename.[/QUOTE]
Pretty sure you need to remove the "sound/" part from your paths when you play the sounds.
[editline]23rd August 2015[/editline]
[QUOTE=kpjVideo;48518274]This isn't too big of a problem, but for some reason specific servers don't allow me from using the Bloom effect. Whenever I try to render bloom it simply doesn't work but will work fine on a clean sandbox server. Is this some sort of setting I'm missing?[/QUOTE]
Are you using the Bloom post processing effect? Gamemodes and addons can disable those, as well as servers can disable clientside Lua.
Tried doing that, still did not work.
[url]http://i.imgur.com/vUVofPG.png[/url]
It shows up in soundlist though:
[url]http://i.imgur.com/XuTVDn3.png[/url]
Edit: Fixed it. Learned today that hl2 sound files are .wav only. .mp3 doesn't work.
I'm dabbling in gamemode creation at the moment but have a problem I can't seem to fix. I based the gamemode off of DarkRPs module system and have gotten that to work, but in my hud file I can't get HUDPaint to be called. In the same file though HUDShouldDraw gets called perfectly fine and loaded gets printed to the clients console so I know the file has been included.[CODE]
local hudelements = {CHudHealth = true,CHudBattery = true,CHudSuitPower = true}
print("LOADED")
function GM:HUDPaint()
self.BaseClass:HUDPaint()
if not self.DrawDranHUD then return end
local maxhealth = LocalPlayer():GetMaxHealth()
local health = math.Clamp(LocalPlayer():Health(),0,maxhealth)
local ratio = health/maxhealth
surface.SetDrawColor(255*(1-ratio),255*ratio,0)
surface.DrawRect(ScrW()*0.1,ScrH()*0.9,200,50)
end
function GM:HUDShouldDraw(name)
if not self.DrawDefaultHUD then return end
if hudelements[name] then return false end
end
[/CODE]
[B]EDIT:[/B]
Fixed it, didn't realize I still needed to return true even if I didn't care about it
I've reached a write limit for creating a BSP... FML
Compiler Process Window Export:
[url]http://pastebin.com/NAcYWeiV[/url]
I guess my question is, how can I make traces still work?
They break when I add too many displacements.
This line exactly is what's the issue... I think.
[code]
physics [variable] 9719200/4194304 (231.7%) VERY FULL!
[/code]
[t]https://dl.dropboxusercontent.com/u/17839069/C_336.png[/t]
[t]https://dl.dropboxusercontent.com/u/17839069/C_337.png[/t]
The photos above are examples of how the traces don't seem to "hit" the displacement. Instead they hit the surface below it. (which in this case is flat).
I'm not entirely sure there's a solution, but traces go straight through the displacement. YET. Physics work.
If there's no solution, I may resort to...
Idk..
No traces work, but Hull traces do...
Source can be so difficult sometimes.
[B]Edit:[/B]
Found a 'hacky' solution in the next post...
I'm still looking for an alternative.
You've likely reached an engine limit - you haven't maxed your displacement verts or the number of displacements - judging by the warning you're using power 4 displacements ( WARNING: Map using power 4 displacements, terrain physics cannot be compressed, map will need additional memory and CPU. ) - it might be beyond the amount of effort accepted, but does it still break if you drop down to power 3?
( Also, you have a leak in the map )
-snip-
[QUOTE=Kogitsune;48520971]You've likely reached an engine limit - you haven't maxed your displacement verts or the number of displacements - judging by the warning you're using power 4 displacements ( WARNING: Map using power 4 displacements, terrain physics cannot be compressed, map will need additional memory and CPU. ) - it might be beyond the amount of effort accepted, but does it still break if you drop down to power 3?
( Also, you have a leak in the map )[/QUOTE]
Great input.
Thank you, for responding.
With better research, I came up to this conclusion:
Solved but not solved? Look at the code below.
[code]
/*
This works!!!!! HAHAHAHAHAAH I don't want to use it though....
....
Cuz it's unoptimized to use it how many times I'll have to use it.
*/
local ply = player.GetByID( 1 )
local tr = util.TraceHull( {
start = ply:EyePos( ),
endpos = ply:EyePos( ) + ply:EyeAngles( ):Forward( ) * 10000,
maxs = Vector( 0.05, 0.05, 0.05 ),
mins = Vector( -0.05, -0.05, -0.05 ),
/*
This would work how util.TraceLine would, but it doesn't... For the displacements....
maxs = vector_origin,
mins = vector_origin,
*/
filter = ply
} )
ply:SetPos( tr.HitPos )
// SUCCESS //
/*-- This does not work --*/
if truetrue then
local ply = player.GetByID( 1 )
ply:SetPos( ply:GetEyeTrace( ).HitPos )
end
// Failure //
[/code]
util.TraceLine doesn't work. util.TraceHull DOES work, however, I'm not entirely sure why it does.
Using util.TraceHull instead of util.TraceHull could be tricky in implementation. Imagine trying to run a util.TraceHull for every bullet shot by a weapon. (If you ask me, that's unoptimized.....).
I don't think this is a problem that I can fix.
What's say you, [B]Kogitsune?[/B]
Thanks again, for the support. I don't see an easy solution.
I'm so use to working with Source-Engine's problems. Been dealing with that for a while >_>
[B]EDIT:[/B]
I assume, because traces are such a tiny line, the displacement stops picking up important 1 cell traces.
Making the cell, 0.05 means it gets flagged again, for trace hit succession.
I really wish traceline wouldn't break on me D:
[B]EDIT2:[/B]
[code]
consolecommand: physics_budget
With HullTraces:
player (player): 0.065ms (6.478%) @ (6873.266113, 2975.471924, 153.018448)
vehicle (vehicle): 0.010ms (1.000%) @ (6080.557129, 3134.984375, 67.871384)
With TraceLine:
player (player): 0.126ms (12.576%) @ (6873.266113, 2975.471924, 153.018448)
vehicle (vehicle): 0.010ms (1.000%) @ (5417.310547, 4529.035156, 432.324768)
[/code]
Results for both:
[t]https://dl.dropboxusercontent.com/u/17839069/C_338.png[/t]
Seems like HullTrace is my best bet.
How can I allow that players can physgun entities spawned from F4 tab in DarkRP?
By default only Superadmins can do this.
[QUOTE=P4sca1;48522485]How can I allow that players can physgun entities spawned from F4 tab in DarkRP?
By default only Superadmins can do this.[/QUOTE]
[url]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/url]
[url]http://wiki.garrysmod.com/page/GM/PhysgunDrop[/url]
If you are using notepad++, press CTRL+LEFT SHIFT+F
Locate the directory of the gamemode, and search for the hooks above "PhysgunPickup" && "PhysgunDrop"
Within the code, there should be at least 1 time each of these are called...
Locate where it says IsSuperAdmin or w.e.
[QUOTE=EthanTheGreat;48522502][url]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/url]
[url]http://wiki.garrysmod.com/page/GM/PhysgunDrop[/url]
If you are using notepad++, press CTRL+LEFT SHIFT+F
Locate the directory of the gamemode, and search for the hooks above "PhysgunPickup" && "PhysgunDrop"
Within the code, there should be at least 1 time each of these are called...
Locate where it says IsSuperAdmin or w.e.[/QUOTE]
I found this:
[CODE]
function ENT:CanTool(ply, trace, tool)
if ply:IsAdmin() and tool == "remover" then
self.CanRemove = true
if SERVER then FAdmin.MOTD.RemoveMOTD(self, ply) end
return true
end
return false
end
function ENT:PhysgunPickup(ply)
local PickupPos = Vector(1.8079, -0.6743, -62.3193)
if ply:IsAdmin() and PickupPos:Distance(self:WorldToLocal(ply:GetEyeTrace().HitPos)) < 7 then return true end
return false
end
[/CODE]
What's PSA?
I keep seeing it everywhere, but does it even stand for? .-.
[QUOTE=JasonMan34;48525238]What's PSA?
I keep seeing it everywhere, but does it even stand for? .-.[/QUOTE]
Public Service Announcement
PSA: google is a thing!!!
[B][I]--post removed--[/I][/B]
I'm having trouble with ents.CreateClientProp.
The prop is created just fine, but as soon as I open the menu (escape or ~) the client side prop disappears.
Is there any way to prevent this from happening? Or am I going to have to use a server side entity instead? (I'd prefer to keep it client side as the client is the only one that needs to see or interact with it)
EDIT:
Apparently it wasn't deleting itself like I thought, rather it's position is being reset. If I've parented it to something, it warps to that object's position, and if I haven't it warps to worldspawn. Still not sure how to detect and/or prevent this from happening.
How can a hook KeyPressed fuck up stencils ?
Here is the problem :
When the hook is removed, the Compass (on HUDPaint hook and using stencils) works great but when used the compass disappear.
Video showing the problem
[video=youtube;DsBgTIUtHxU]http://www.youtube.com/watch?v=DsBgTIUtHxU[/video]
Code : [url]https://github.com/ExtReMLapin/GryMod/blob/master/lua/grymod/client/cl_hud.lua[/url]
Compass code: [url]https://github.com/ExtReMLapin/GryMod/blob/master/lua/grymod/client/cl_hud.lua#L683[/url] (Line 683)
Hook's function : [url]https://github.com/ExtReMLapin/GryMod/blob/master/lua/grymod/client/cl_hud.lua#L449[/url] (Line 449)
Sometimes, removing another hook fuckup my stencils, change the stencils colors.
What the hell
Sorry, you need to Log In to post a reply to this thread.