[QUOTE=raubana;52529638]I have an entity that is meant to represent the model of a player (it's for a prop hunt type thing). I've had problems with the entity being invisible sometimes for some players, and after a bit of testing I figured out that sometimes the entity's position is not updated on the client's end.
Using this code did NOT fix it:
[CODE]
function ENT:UpdateTransmitState()
return TRANSMIT_ALWAYS
end
[/CODE]
The model has been set, but I did not initialize the physics object.
The entity originally was parented to the player, but when the bug showed up I disabled that and instead had the entity move it's position using its Think hook. As you can guess, that didn't fix it either.
Any ideas??
EDIT: Here's the code as it is at this point. It's so messy because I've been rushing to get this out for the gmod store contests, and this bug is driving me nuts.
[url]https://github.com/raubana/AttackOfTheMimics/blob/master/gamemodes/attack_of_the_mimics/entities/entities/sent_aotm_mimicbody.lua[/url]
EDIT: Bull assisted me a bit. We determined that the entity was NOT dormant. Putting SetPos in a timer didn't fix it.[/QUOTE]
I figured it out. So apparently the render origin is what is used to determine if an entity is to be rendered or not on the client's end, and since that value is set inside of the Draw hook, anytime the entity is outside of my PVS the Draw hook stops being called, and so it stops being updated.
[QUOTE=Sean Bean;52533108]How would I go about drawing a hollow circle with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/DrawPoly]surface.DrawPoly[/url] and stencils?[/QUOTE]
I'll assume you know more or less how to use stencils
1. Clear stencil, set STENCIL_NEVER, set fail operation to STENCIL_REPLACE, make sure the TestMask/WriteMask/ReferenceValue are set properly
2. Draw the inner circle (won't be visible, only writes to the stencil)
3. STENCIL_NOTEQUAL
4. Draw the outer circle
[QUOTE=NeatNit;52533531]I'll assume you know more or less how to use stencils
1. Clear stencil, set STENCIL_NEVER, set fail operation to STENCIL_REPLACE, make sure the TestMask/WriteMask/ReferenceValue are set properly
2. Draw the inner circle (won't be visible, only writes to the stencil)
3. STENCIL_NOTEQUAL
4. Draw the outer circle[/QUOTE]
[code]local alphaOne = Color(0, 0, 0, 1)
local DrawCircle = function(x, y, radius, col)
local cir = {
{x = x, y = y},
}
for i = 0, 45 do
local rad = math.rad((i / 45) * -360)
cir[#cir + 1] = {
x = x + math.sin(rad) * radius,
y = y + math.cos(rad) * radius,
}
end
local rad = math.rad(0)
cir[#cir + 1] = {
x = x + math.sin(rad) * radius,
y = y + math.cos(rad) * radius,
}
draw.NoTexture()
surface.SetDrawColor(col)
surface.DrawPoly(cir)
end
local DrawHollowCircle = function(x, y, radius, col, thickness)
render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilReferenceValue(1)
render.SetStencilWriteMask(1)
render.SetStencilTestMask(1)
render.SetStencilPassOperation(STENCILOPERATION_REPLACE)
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_NOTEQUAL)
DrawCircle(x, y, radius - thickness, alphaOne) -- Is there a reason I can't use alpha 0 here?
DrawCircle(x, y, radius, col)
render.SetStencilEnable(false)
end
hook.Add("HUDPaint", "Hollow Circle", function()
DrawHollowCircle(ScrW() * .5, ScrH() * .5, 150, color_black, 10)
end)
[/code]
This isn't quite what you said to do but it still does the job. I'm still trying to understand stencils so if there's anything wrong with this method do tell.
[QUOTE=Shorthouse06;52529394]Are you sure you're playing the custom sound on both the server and the client?
Put the sound right at the top of the fire function away from any if SERVER / CLIENT checks and see if it works.[/QUOTE]
I've already fixed it, problem was my SWEP.Base went missing... Thanks for the help anyway! :D
Can i up it?
[QUOTE=FaceSparTV;52526373]Hello.
Is there any ways to make a file of serverside errors?
For example there's a file with clientside errors in root folder of gmod.
Thanks[/QUOTE]
[QUOTE=FaceSparTV;52533878]Hello.
Is there any ways to make a file of serverside errors?
For example there's a file with clientside errors in root folder of gmod.
Thanks[/QUOTE]
Override debug.getregistry()[1], [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/error]error[/url], [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Error]Error[/url], and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ErrorNoHalt]ErrorNoHalt[/url] to write the error to a file with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Write]file.Write[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Append]file.Append[/url]. It isn't very reliable but it's the only way afaik.
[QUOTE=Sean Bean;52533776][code]local alphaOne = Color(0, 0, 0, 1)
local DrawCircle = function(x, y, radius, col)
local cir = {
{x = x, y = y},
}
for i = 0, 45 do
local rad = math.rad((i / 45) * -360)
cir[#cir + 1] = {
x = x + math.sin(rad) * radius,
y = y + math.cos(rad) * radius,
}
end
local rad = math.rad(0)
cir[#cir + 1] = {
x = x + math.sin(rad) * radius,
y = y + math.cos(rad) * radius,
}
draw.NoTexture()
surface.SetDrawColor(col)
surface.DrawPoly(cir)
end
local DrawHollowCircle = function(x, y, radius, col, thickness)
render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilReferenceValue(1)
render.SetStencilWriteMask(1)
render.SetStencilTestMask(1)
render.SetStencilPassOperation(STENCILOPERATION_REPLACE)
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_NOTEQUAL)
DrawCircle(x, y, radius - thickness, alphaOne) -- Is there a reason I can't use alpha 0 here?
DrawCircle(x, y, radius, col)
render.SetStencilEnable(false)
end
hook.Add("HUDPaint", "Hollow Circle", function()
DrawHollowCircle(ScrW() * .5, ScrH() * .5, 150, color_black, 10)
end)
[/code]
This isn't quite what you said to do but it still does the job. I'm still trying to understand stencils so if there's anything wrong with this method do tell.[/QUOTE]
test, write, ref = 1
pass = STENCIL_INCR
compare = STENCIL_ALWAYS
draw_inner at alpha 1 (reason it can't be 0 is because the source engine renderer stops rendering things at 0 alpha for a dumb reason)
compare = STENCIL_NOTEQUAL
pass = STENCIL_KEEP
draw_outer at full alpha
this is the best practice way and most optimized
Is it possible to draw the model of a ClientsideModel as translucent inside a Draw hook of a parent SENT?
I want to do draw manually because when the parent is removed there is a delay of about a second before child ClientsideModels are removed. Apparently this is because of a delay between the SENT being removed and clientside OnRemove being called.
Current method:
[lua]
ENT.RenderGroup = RENDERGROUP_BOTH
...
-- In a SENT method
local m = ClientsideModel( model, RENDERGROUP_BOTH )
m:SetParent( self )
m:SetRenderMode( RENDERMODE_TRANSALPHA )
m:SetColor( Color( 255, 255, 255, 100 ) )
m:SetModel( p.model )
m:SetNoDraw( true )
-- DrawTranslucent
m:DrawModel()
[/lua]
The models are drawn without transparency.
No difference when I try to set the color in DrawTranslucent. I suppose setting the RenderMode on the CSEnt makes no difference when you're drawing it manually.
Someone tryna give me a very brief manner of privately networking entity data?
As in, ply1 owns an ent, the ent tells only ply1 it's information from svside.
All other plys not need to know this information. ( This is strictly for networking performance )
[QUOTE=Koolaidmini;52539670]Someone tryna give me a very brief manner of privately networking entity data?
As in, ply1 owns an ent, the ent tells only ply1 it's information from svside.
All other plys not need to know this information. ( This is strictly for networking performance )[/QUOTE]
This is what net messages are for.
[QUOTE=Koolaidmini;52539670]Someone tryna give me a very brief manner of privately networking entity data?
As in, ply1 owns an ent, the ent tells only ply1 it's information from svside.
All other plys not need to know this information. ( This is strictly for networking performance )[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetPreventTransmit]Entity:SetPreventTransmit[/url]
[QUOTE=raubana;52541931][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetPreventTransmit]Entity:SetPreventTransmit[/url][/QUOTE]
ily ty
How do you find if a point is within a triangle?
[QUOTE=Exho;52543126]How do you find if a point is within a triangle?[/QUOTE]
[url]https://github.com/meepdarknessmeep/noname/blob/master/gamemode/panels/team_select.lua#L90[/url]
tl;dr
check height of triangle, if it's between top and bottom get position of left and right at that height and calculate if it's between those
Is [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScreenScale]ScreenScale[/url] not to be used because my scoreboard scaled way wrong from what I see in my ships gamemode?
[QUOTE=MeepDarknessM;52543248][url]https://github.com/meepdarknessmeep/noname/blob/master/gamemode/panels/team_select.lua#L90[/url]
tl;dr
check height of triangle, if it's between top and bottom get position of left and right at that height and calculate if it's between those[/QUOTE]
I'm not having any luck at all trying to understand what is going on in your code and how to apply it to my problem.
Basically I'm trying to see if a player is in a POV from another player and I'm trying to do it in Lua. I feel like this is basic trigonometry but the math eludes me. I've got the code written to create the triangle and I've confirmed that it works regardless of the player's orientation, I just can't seem to figure out how to detect if something is in the triangle I've created.
[CODE]local triangleHeight = (fwd * distance)
local triangleBaseHalf = (right * distance/2)
local leftVertice = self.Owner:GetPos() + (triangleHeight - triangleBaseHalf)
local rightVertice = self.Owner:GetPos() + (triangleHeight + triangleBaseHalf)
local tipVertice = self.Owner:GetPos()
local baseCenterVertice = self.Owner:GetPos() + triangleHeight[/CODE]
A la
[IMG]https://i.gyazo.com/b05a7a28998a4ac4168363a42812a10e.png[/IMG]
[QUOTE=Thermadyle;52543450]Is [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScreenScale]ScreenScale[/url] not to be used because my scoreboard scaled way wrong from what I see in my ships gamemode?[/QUOTE]
Is the Y scaling messed up? afaik ScreenScale only really scales X values properly.
Use this instead:
[code]
local w = 1920 --your res
local h = 1080 --your res
local function scaleX(sw)
return ScrW() * ((sw or 0) / w)
end
local function scaleY(sh)
return ScrH() * ((sh or 0) / h)
end
[/code]
[QUOTE=Exho;52543735]I'm not having any luck at all trying to understand what is going on in your code and how to apply it to my problem.
Basically I'm trying to see if a player is in a POV from another player and I'm trying to do it in Lua. I feel like this is basic trigonometry but the math eludes me. I've got the code written to create the triangle and I've confirmed that it works regardless of the player's orientation, I just can't seem to figure out how to detect if something is in the triangle I've created.
[CODE]local triangleHeight = (fwd * distance)
local triangleBaseHalf = (right * distance/2)
local leftVertice = self.Owner:GetPos() + (triangleHeight - triangleBaseHalf)
local rightVertice = self.Owner:GetPos() + (triangleHeight + triangleBaseHalf)
local tipVertice = self.Owner:GetPos()
local baseCenterVertice = self.Owner:GetPos() + triangleHeight[/CODE]
A la
[IMG]https://i.gyazo.com/b05a7a28998a4ac4168363a42812a10e.png[/IMG][/QUOTE]
have pos be the position being tested
have topy, bottomy be top y coordinate from all points and bottom from all points
have left, middle, right be the points relative to each other
[lua]
pos = {x = 0.5, y = 0.5}
left = {x=0, y = 0}
right= {x=1,y=0}
middle={x=0.5, y=1}
isintriangle = topy >= pos.y and pos.y >= bottomy
if (isintriangle) then
local leftx = left.x + (middle.x - left.x) * (pos.y - left.y) / (middle.y - left.y)
local rightx = middle.x + (right.x - middle.x) * (right.y - pos.y) / (right.y - middle.y)
isintriangle = leftx <= pos.x and pos.x <= rightx
end
-- isintriangle
[/lua]
but for actual field of view you may want to use Vector.Dot
Is there a good way to resize a font on the fly? Trying to resize some text based on how long the string is for a 3d2d display with SimpleText.
How do I get the player who spawned an entity?
I tried this:
[code]
ent:GetOwner():SteamID64()
-- nil
ent:GetCreator():SteamID64()
-- nil
[/code]
Both return nil, even when trying to get the name :/
They should error since both would be NULL. There is no built in prop ownership system in Garry's Mod.
how would i make a simple beat detection for FFT ?
[QUOTE=code_gs;52544832]They should error since both would be NULL. There is no built in prop ownership system in Garry's Mod.[/QUOTE]
So how is one supposed to get the owner of a prop?
[QUOTE=3rlite;52545185]So how is one supposed to get the owner of a prop?[/QUOTE]
You can set a variable in this hook to keep track of it yourself: [url]https://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnedProp[/url]
[QUOTE=code_gs;52545202]You can set a variable in this hook to keep track of it yourself: [url]https://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnedProp[/url][/QUOTE]
Sandbox only? If not how can I check if a gamemode is sandbox derived?
[QUOTE=3rlite;52545756]Sandbox only? If not how can I check if a gamemode is sandbox derived?[/QUOTE]
Yes, and GAMEMODE.IsSandboxDerived
[QUOTE=MeepDarknessM;52544304]have pos be the position being tested
have topy, bottomy be top y coordinate from all points and bottom from all points
have left, middle, right be the points relative to each other
[lua]
pos = {x = 0.5, y = 0.5}
left = {x=0, y = 0}
right= {x=1,y=0}
middle={x=0.5, y=1}
isintriangle = topy >= pos.y and pos.y >= bottomy
if (isintriangle) then
local leftx = left.x + (middle.x - left.x) * (pos.y - left.y) / (middle.y - left.y)
local rightx = middle.x + (right.x - middle.x) * (right.y - pos.y) / (right.y - middle.y)
isintriangle = leftx <= pos.x and pos.x <= rightx
end
-- isintriangle
[/lua]
but for actual field of view you may want to use Vector.Dot[/QUOTE]
Is the purpose behind using Vector.Dot to have this work no matter what the player's orientation is? Now I'll have to figure out dot products too
Anyone know how i can fix the Z layer issues with [URL="https://github.com/mattkrins/gfodder/blob/master/entities/entities/base_food_preparation.lua#L128"]3D2D[/URL]?
[t]https://puu.sh/x4CmM/f47d1f0cfe.png[/t]
[QUOTE=101kl;52550320]Anyone know how i can fix the Z layer issues with [URL="https://github.com/mattkrins/gfodder/blob/master/entities/entities/base_food_preparation.lua#L128"]3D2D[/URL]?
[t]https://puu.sh/x4CmM/f47d1f0cfe.png[/t][/QUOTE]
Use appropriate hooks and render groups.
[QUOTE=Exho;52546074]Is the purpose behind using Vector.Dot to have this work no matter what the player's orientation is? Now I'll have to figure out dot products too[/QUOTE]
Vector.Dot is basically field of fov away from other vector
Sorry, you need to Log In to post a reply to this thread.