I use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetRenderOrigin]Entity:SetRenderOrigin[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetRenderAngles]Entity:SetRenderAngles[/url] in Draw to make sure client props stay where they are supposed to.
Draw the props again with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/PushFlashlightMode]render.PushFlashlightMode[/url] enabled for flashlight lightning.
[QUOTE=thejjokerr;52189823]This is what my clientsideprops (attached to the suit recharger) look like in the beginning:
[t]http://i.imgur.com/EEq0x7D.png[/t]
But when I alt-tab they all go to their parent's origin (0,0,0):
[t]http://i.imgur.com/0YNgzDl.png[/t]
Can anyone think of a nice way to prevent this from happening/correct it when it happens?
[editline]5th May 2017[/editline]
[B]Additional question[/B]: Is it possible to have Clientside props be affected by dynamic lighting? e.g: Flashlight?
I realize this may not be possible in source, let me know if it is.[/QUOTE]
Code?
My guess is: you're doing something clientside when it should be serverside. Does the same thing also happen if you noclip out of bounds and back in?
[QUOTE=thejjokerr;52190219]Yes the same thing happens. Will post code later
[editline]5th May 2017[/editline]
[lua]-- entity init
ENT.Model = Model("models/props_combine/suit_charger001.mdl");
function ENT:Initialize()
self:SetModel(self.Model);
end;
-- entity shared:
ENT.Type = "anim";
ENT.Base = "base_anim";
-- entity cl_init:
function ENT:Initialize()
self:AttachDecorativeProps(decorations);
end;
-- meta shiz for attaching the props:
local entityMeta = FindMetaTable("Entity");
function entityMeta:AttachDecorativeProps(propTable)
if not self.DecorativeProps then
self.DecorativeProps = {};
end;
for _, decoration in ipairs(propTable)do
local ent = ents.CreateClientProp();
ent:Spawn();
ent:SetParent(self);
ent:SetModel(decoration["model"]);
ent:SetLocalPos(decoration["position"]);
ent:SetLocalAngles(decoration["angles"]);
if(decoration["modelScale"])then
ent:SetModelScale(decoration["modelScale"]);
end;
self.DecorativeProps[#self.DecorativeProps + 1] = ent;
end;
end;
[/lua]
[editline]5th May 2017[/editline]
Actually it might not be the alt-tabbing. It might be the escape menu. When I escape the cs models go to the origin
[editline]5th May 2017[/editline]
It appears they unparent when I press escape or leave the PVS. How do I prevent/detect this?[/QUOTE]
I think you should just use a serverside model instead of clientside. Some weird-ass shit happens clientside when PVS is in play.
If you REALLY want to keep it clientside (don't!), you can define ENT:UpdateTransmitState and return TRANSMIT_ALWAYS.
[editline]5th May 2017[/editline]
also, you really should define AttachDecorativeProps as ENT:AttachDecorativeProps instead of entityMeta:AttachDecorativeProps.
[QUOTE=thejjokerr;52190634]I don't want to clutter the server with detail props when I can draw them fine on the client.[/QUOTE]
Keep in mind that effects, for example, are made up of 2 entities: a lua ent with class [url=https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/entities/prop_effect.lua]prop_effect[/url] and an attached [url=https://developer.valvesoftware.com/wiki/Prop_dynamic]prop_dynamic[/url]. The server really doesn't care about cheap stuff like that, and parenting is super cheap. I suggest you use the same method (also with prop_dynamic) for your detail props. It will save you a lot of massive headaches.
By the way, I'm not sure if this is part of the problem, but FYI for the future - you should use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ClientsideModel]ClientsideModel[/url] instead of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/CreateClientProp]ents.CreateClientProp[/url]. IIRC, the difference is that CreateClientProp has physics, while ClientsideModel does not. You're throwing physics out the window anyway when you parent it to something.
Working on making an icon rotate when a button is clicked, everything is working fine but I'm not too sure how to make this fast (but smooth)
[CODE] spinButt.DoClick = function()
local rot = math.random(360, 720)
timer.Create("RotTimer", 0, rot, function()
DegreesRotation = DegreesRotation + 1 -- this is global used in the Paint function with a DrawTexturedRectRotated
end)
end[/CODE]
It works but it's incredibly slow turning, if I increase the amount it increments then it starts to become choppy, I know Panels have MoveTo/SizeTo functions with Ease and that's kinda what I'm looking for except with rotation, if anyone could help me with that it'd be awesome :)
[QUOTE=DahDestroyer;52190771]Working on making an icon rotate when a button is clicked, everything is working fine but I'm not too sure how to make this fast (but smooth)
[CODE] spinButt.DoClick = function()
local rot = math.random(360, 720)
timer.Create("RotTimer", 0, rot, function()
DegreesRotation = DegreesRotation + 1 -- this is global used in the Paint function with a DrawTexturedRectRotated
end)
end[/CODE]
It works but it's incredibly slow turning, if I increase the amount it increments then it starts to become choppy, I know Panels have MoveTo/SizeTo functions with Ease and that's kinda what I'm looking for except with rotation, if anyone could help me with that it'd be awesome :)[/QUOTE]
try to not use a global, but the table of the panel instead.
e.g. spinButt.DegreesRotation = ...
and in then in spinButt.Paint you can reference it using spinButt.DegreesRotation
that way, you can have multiple of these and you won't pollute the global space.
Also, you're using a timer. you can probably fix the turning by e.g. using some predicted time like CurTime
I remember seeing a tool that showed you which function used the most 'power' in your game, kind of like a graph with the biggest function as the biggest square. It's used to know if something is coded badly and inefficient.
Anyone knows what I'm talking about?
[QUOTE=bilbasio;52191300]I remember seeing a tool that showed you which function used the most 'power' in your game, kind of like a graph with the biggest function as the biggest square. It's used to know if something is coded badly and inefficient.
Anyone knows what I'm talking about?[/QUOTE]
Sounds like you're mixing up [url=https://github.com/FPtje/FProfiler]FProfiler[/url] with [url=http://www.uderzo.it/main_products/space_sniffer/]SpaceSniffer[/url], but perhaps there really is a tool that does that that I'm not aware of.
Off topic, but that space sniffer tool is pretty good regardless of anything, check it out.
[QUOTE=NeatNit;52191326]Sounds like you're mixing up [url=https://github.com/FPtje/FProfiler]FProfiler[/url] with [url=http://www.uderzo.it/main_products/space_sniffer/]SpaceSniffer[/url], but perhaps there really is a tool that does that that I'm not aware of.
Off topic, but that space sniffer tool is pretty good regardless of anything, check it out.[/QUOTE]
Yeah honestly I'm not even 100% sure it was related to gmod. Thank you.
[editline]5th May 2017[/editline]
Fprofiler is exactly what I was looking for, albeit not the graphical part.
[QUOTE=bilbasio;52191406]Yeah honestly I'm not even 100% sure it was related to gmod. Thank you.
[editline]5th May 2017[/editline]
Fprofiler is exactly what I was looking for, albeit not the graphical part.[/QUOTE]
You are thinking of an addon by Oubliette
[QUOTE=Lilyxfce;52191633]You are thinking of an addon by Oubliette[/QUOTE]
[url]https://github.com/oubliette32/DBugR[/url]
Multiple questions :
1. Since [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vehicle/GetSpeed]Vehicle:GetSpeed[/url] is a serverside function, is there a workaround or do I have to network the speed of a vehicle?
2. How can I use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/KeyPress]GM:KeyPress[/url] with multiple keys? Say Shift + E?
3. How can I make sure that my Vector is always on the right side of an ent? Example : The exit position of my vehicle is the vehicle pos + a vector, which only works when the car is facing the right way. I'm still having trouble with angles so any help would be appreciated.
1. You have to network it. Unfortunately, Garry didn't implement IClientVehicle into the Lua state, so a lot of methods are unnecessarily serverside only.
2. You can't, you'll have to check if the key is already down when one of them is pressed.
3. You can use Angle:Forward()/Right()/Up() to get the directional vector of an entity's facing to properly scale your exit vector.
Tried [code]hook.Add("KeyPress", "RemoveProp", function(ply, key)
if key == IN_USE then
if ply:KeyDown(IN_RUN) then
print("Pressed")
end
end
end)[/code]
But it doesn't work. Any idea why?
Did you mean IN_SPEED? IN_RUN isn't bound by default
[QUOTE=code_gs;52191966]Did you mean IN_SPEED? IN_RUN isn't bound by default[/QUOTE]
Thank you, I didn't check the IN enumerations properly.
i am practicing coding and tried to make entity that gives you random weapon but i dont know how to do it any tips?
[QUOTE=RasmusG5;52193056]i am practicing coding and tried to make entity that gives you random weapon but i dont know how to do it any tips?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENT:Use[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/Random]table.Random[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/weapons/GetList]weapons.GetList[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url]
[editline]6th May 2017[/editline]
This might work:
[CODE]
function ENT:Use( activator, caller )
if IsValid( caller ) and caller:IsPlayer() then
caller:Give( table.Random( weapons.GetList() ).ClassName )
end
end
[/CODE]
[editline]6th May 2017[/editline]
With the code above however, there's a chance the player will be given a weapon they already have
[QUOTE=MPan1;52193066][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENT:Use[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/Random]table.Random[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/weapons/GetList]weapons.GetList[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url]
[editline]6th May 2017[/editline]
This might work:
[CODE]
function ENT:Use( activator, caller )
if IsValid( caller ) and caller:IsPlayer() then
caller:Give( table.Random( weapons.GetList() ).ClassName )
end
end
[/CODE]
[editline]6th May 2017[/editline]
With the code above however, there's a chance the player will be given a weapon they already have[/QUOTE]
thanks but how i make list of weapons that player can get from it
[QUOTE=bilbasio;52192028]Thank you, I didn't check the IN enumerations properly.[/QUOTE]
Could do something of the sorts, both have the same results:
[CODE]local isDown = {}
function keysDown( tbl )
if ( tbl[ IN_SPEED ] and tbl[ IN_USE ] ) then
return true
end
return false
end
hook.Add( "KeyPress", "test1", function( ply, key )
isDown[ key ] = true
if !keysDown( isDown ) then return end
....do stuff....
end )
hook.Add( "KeyRelease", "test2", function( ply, key )
isDown[ key ] = false
end )
[/CODE]
[QUOTE=RasmusG5;52193137]thanks but how i make list of weapons that player can get from it[/QUOTE]
What do you mean by list?
That could mean a table, a [URL="http://wiki.garrysmod.com/page/Category:DListView"]DListView[/URL] the player can choose from, a drop-down menu, etc.
[QUOTE=JasonMan34;52193181]What do you mean by list?
That could mean a table, a [URL="http://wiki.garrysmod.com/page/Category:DListView"]DListView[/URL] the player can choose from, a drop-down menu, etc.[/QUOTE]
i meat that i have small list of weapons and randomizer picks one of them nd gives it to player but now it choses from every gun i have and picks some of them
[QUOTE=Leystryku;52190888]try to not use a global, but the table of the panel instead.
e.g. spinButt.DegreesRotation = ...
and in then in spinButt.Paint you can reference it using spinButt.DegreesRotation
that way, you can have multiple of these and you won't pollute the global space.
Also, you're using a timer. you can probably fix the turning by e.g. using some predicted time like CurTime[/QUOTE]
Hey I took your advice and did some working on it, all works fine and it spins quite nicely, but the only issue is getting it to slow down once it's reaching the end, I know I'd need to change the 200 * FrameTime() to achieve this, but not sure how I'm going to calculate how far along it is :p
[CODE] spinButt.DoClick = function()
local rots = math.random(3,6)
local offset = math.random(0,360)
local rot = (rots * 360) + offset
local smoothspin = 0
local curspin = 0
curspin = rot
hook.Add( "HUDPaint", "SpinTheWheel", function()
local current = math.Clamp(curspin, 0, rot)
smoothspin = math.Round(math.Approach(smoothspin, current, 200 * FrameTime()))
WheelRotDG = smoothspin
if WheelRotDG == rot then
hook.Remove( "HUDPaint", "SpinTheWheel" )
end
end )
end[/CODE]
[QUOTE=RasmusG5;52193197]i meat that i have small list of weapons and randomizer picks one of them nd gives it to player but now it choses from every gun i have and picks some of them[/QUOTE]
I think I understand what you mean.
Why not just make a table with your desired weapons' class names?
I've encountered a really strange bug while working on panels. I made a custom button with text that centers itself depending on the text size, but it only seems to work when the main menu is opened:
[t]https://puu.sh/vHLeO/72b495fc84.png[/t]
[t]https://puu.sh/vHLf4/2130df3502.png[/t]
I really don't understand what's causing this weird behavior.
Here's my code:
[code]function PANEL:Paint()
local sizex, sizey = surface.GetTextSize(self.Text)
local selfx, selfy = self:GetSize()
surface.SetDrawColor(self.BColor)
surface.DrawRect(0, 0, self.x, self.y)
surface.SetTextColor(self.TextColor)
surface.SetFont(self.Font or "default")
surface.SetTextPos(selfx / 2 - sizex / 2, selfy / 2 - sizey / 2)
surface.DrawText(self.Text or "")
end[/code]
Set the font before getting the text size
[QUOTE=Teklatea;52194736]Set the font before getting the text size[/QUOTE]
Thank you that did it. Strangely enough I added other buttons and only the choose button had this behavior.
[QUOTE=thejjokerr;52197294]Does anyone have an idea on how to have the map's sky_camera ignore 3d2d elements? I'm testing on rp_c18_v1 and the skybox/sky_camera is underneath the map. Causing all my 3d2d's to appear in the sky as well.
I can remove the sky_camera but then I'm left without a skybox which looks ugly.`
Picture of problem:
[t]http://i.imgur.com/vWbaoNn.png[/t][/QUOTE]
I remember running into a similar problem on gm_flatgrass when passing a really large vector to SetRenderBounds
[editline]7th May 2017[/editline]
If you're using PostDrawOpaqueRenderables, this seems to fix it:
[CODE]
hook.Add( "PostDrawOpaqueRenderables", "bla", function(bDrawingDepth, bDrawingSkybox)
if not bDrawingSkybox then
cam.Start3D2D( ...)
cam.End3D2D()
end
end )
[/CODE]
I have another really strange bug today: I always have 64 pistol ammo when I spawn. I tried [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/RemoveAllAmmo]Player:RemoveAllAmmo[/url], [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/StripAmmo]Player:StripAmmo[/url] in PlayerSpawn but it didn't work. I tried the second argument of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url] to not spawn a SWEP with ammo but it didn't work. Is there a default value of ammunition in the sandbox gamemode??
Sorry, you need to Log In to post a reply to this thread.