[CODE]DHTMLPanel:RunJavascript([[document.body.style.overflow = "hidden"]])[/CODE]
Use DHTML too, not HTML
[QUOTE=ArtikNinetail;49486905]When I attempted to do that it crashed the code every time. Not sure why. And from that page it says "(Appears to be ineffective?)"
[code]
[ERROR] RunString:72: attempt to call method 'SetScrollbars' (a nil value)
1. unknown - RunString:72
2. unknown - lua/includes/modules/concommand.lua:54
[/code][/QUOTE]
You will have to append [code]
<HEAD>
<STYLE type="text/css">
body {
overflow: hidden;
}
</STYLE>
</HEAD>
[/code]
to the beginning of the DHTML panel's HTML code.
[QUOTE=BillyOnWiiU;49487192][CODE]DHTMLPanel:RunJavascript([[document.body.style.overflow = "hidden"]])[/CODE]
Use DHTML too, not HTML[/QUOTE]
Ah, I had the dumb. Switched over to DHTML and it did hide it, but I can't scroll anymore. I guess I'll just have to live with a bright white scroll bar. For reference, I am pulling a URL from other websites not just making a pop-up with HTML.
How would I go about bone merging one player model from another?
[U][B]This question is mainly aimed at Z0mb1n3, since he might be able to spot my mistake[/B][/U]
So, I have a function (tested by Z0mb1n3) that has the arguments for it as follows:
[CODE]
RaySphereIntersection(traceStart, direction, maxDistance, sphereCenter, sphereRadius)
[/CODE]
So, I wanted to calculate where the intersection vector would be on a sphere in a DModelPanel, right? So, I did:
[CODE]
local Direction = DModelPanel:GetCamPos() + ( gui.ScreenToVector( gui.MousePos() ) * 2048 )
local Colliding, Position = RaySphereIntersection( DModelPanel:GetCamPos(), Direction, 2048, DModelPanel.Entity:OBBCenter(), 45 )
[/CODE]
So, I'm setting the arguments to be as follows:
[B]Tracestart[/B] is the [B]camera position[/B] of the DModelPanel-[B]equivalent to ply:EyePos()[/B].
The [B]direction[/B] is the [B]camera position[/B] with the [B]gui.ScreenToVector's normal[/B] added on, after multiplying it by how long I wanted the trace to go for.
This would be [B]equivalent to ply:EyePos() + ( ply:GetAimVector() * 2048 )[/B].
For the [B]max distance[/B], I did [B]2048[/B], as that's how long I wanted the trace to go for.
I set the [B]sphere center[/B] as the [B]DModelPanel's entity center[/B] (which I checked to be correct).
I set the [B]size[/B] to [B]45[/B], which I checked to be correct (using render spheres).
My question is, what have I done wrong? I keep getting 'false' for my Colliding variable, and nil for the vector. And, I think I'm doing everything right, since Z0mb1n3 said:
[QUOTE=Z0mb1n3;49482577]You do ply:EyePos() + ply:GetAimVector() * (distance you want it to travel)[/QUOTE]
Please help me, I'm really confused
[QUOTE=MPan1;49490638][U][B]This question is mainly aimed at Z0mb1n3, since he might be able to spot my mistake[/B][/U]
So, I have a function (created by Z0mb1n3) that has the arguments for it as follows:
[CODE]
RaySphereIntersection(traceStart, direction, maxDistance, sphereCenter, sphereRadius)
[/CODE]
So, I wanted to calculate where the intersection vector would be on a sphere in a DModelPanel, right? So, I did:
[CODE]
local Direction = DModelPanel:GetCamPos() + ( gui.ScreenToVector( gui.MousePos() ) * 2048 )
local Colliding, Position = RaySphereIntersection( DModelPanel:GetCamPos(), Direction, 2048, DModelPanel.Entity:OBBCenter(), 45 )
[/CODE]
So, I'm setting the arguments to be as follows:
[B]Tracestart[/B] is the [B]camera position[/B] of the DModelPanel-[B]equivalent to ply:EyePos()[/B].
The [B]direction[/B] is the [B]camera position[/B] with the [B]gui.ScreenToVector's normal[/B] added on, after multiplying it by how long I wanted the trace to go for.
This would be [B]equivalent to ply:EyePos() + ( ply:GetAimVector() * 2048 )[/B].
For the [B]max distance[/B], I did [B]2048[/B], as that's how long I wanted the trace to go for.
I set the [B]sphere center[/B] as the [B]DModelPanel's entity center[/B] (which I checked to be correct).
I set the [B]size[/B] to [B]45[/B], which I checked to be correct (using render spheres).
My question is, what have I done wrong? I keep getting 'false' for my Colliding variable, and nil for the vector. And, I think I'm doing everything right, since Z0mb1n3 said:
Please help me, I'm really confused[/QUOTE]
well I don't remember creating that function?
But for starters, you're using OBBCenter, which returns local coordinates, so you'll want to convert those to world coordinates.
[QUOTE=Z0mb1n3;49490840]well I don't remember creating that function?
But for starters, you're using OBBCenter, which returns local coordinates, so you'll want to convert those to world coordinates.[/QUOTE]
It returns Vector( 0, 0, 0 ) (which is correct), so I don't really need to convert it since DModelPanels always put the model at Vector( 0, 0, 0 )
Does anyone have a solution to changing a SWEP's worldmodel causing it to cycle its worldmodel between the original and new one?
Hello, I have some questions regarding weapons:
How can I get the weapon instance by the weapon class?
How can I get the slot of a weapon? :GetSlot() is aloways returning 0.
Hey guys, I'm really new to lua. What exactly is the difference bettween a method, a function and a hook? What's an example of each?
[QUOTE=JavieroNarcos;49493072]Hey guys, I'm really new to lua. What exactly is the difference bettween a method, a function and a hook? What's an example of each?[/QUOTE]
[B][U]Hook[/U][/B]
[QUOTE=Wiki]The hook library allows scripts to interact with game or user created events. It allows you to "hook" a function onto an event created with hook.Run or hook.Call and run code when that events happens that either works independently or modifies the event's arguments. This is the preferred method instead of overriding functions to add your own code into it.[/QUOTE]
[url]http://wiki.garrysmod.com/page/Hook_Library_Usage[/url]
[B][U]Function[/U][/B]
[CODE]function this_is_a_function()
print("indent pls")
end
this_is_a_function()[/CODE]
[B][U]Method[/U][/B]
[CODE]local a_table = {}
function a_table:Destroy()
a_table = nil
end
a_table:Destroy()[/CODE]
[QUOTE=BillyOnWiiU;49493138]
[B][U]Method[/U][/B]
[CODE]local a_table = {}
function a_table:Destroy()
a_table = nil
end
a_table:Destroy()[/CODE][/QUOTE]
There are no methods in lua. Indexing with a colon is just sugar syntax in lua and
[CODE]
Table:Index()
-- is the same as doing
Table.Index(Table)
[/CODE]
The "methods" defined like so
[CODE]
function Class:Method(args)
end
[/CODE]
are actually just ordinary functions defined like so
[CODE]
function Class.Method(self,args) -- where self is the instance of the class, and is passed in through a call to this method by indexing with a colon.
end
[/CODE]
-snip- fixed
Right, I need some help. I'm trying to give vehicles collision damage in a script, but I can't get the collision data to do what it's supposed to (Namely, give collision data such as speed). The first time I tested my script, it kept throwing up errors that I was trying to compare a number with a nil. Upon further testing, I found that data.Speed was coming up as nil.
I tried printing the table and this is what I got:
[CODE]Vehicle [430][prop_vehicle_jeep][/CODE]
This is what my callback looks like. It's definitely running.
[CODE]function Arctic_VehicleDamage_Collide( data, collider )
if ( data.Speed >= 125 ) then
local DamageTable = DamageInfo()
DamageTable:SetDamage( data.Speed )
DamageTable:SetDamageType( DMG_CRUSH )
DamageTable:SetInflictor( collider )
self:TakeDamageInfo( DamageTable )
end
end[/CODE]
And here's how I set up the callback, inside a hook for "PlayerSpawnedVehicle":
[CODE]ent:AddCallback( "PhysicsCollide", Arctic_VehicleDamage_Collide )[/CODE]
Can someone help me?
[QUOTE=MPan1;49491203]It returns Vector( 0, 0, 0 ) (which is correct), so I don't really need to convert it since DModelPanels always put the model at Vector( 0, 0, 0 )[/QUOTE]
Well I have no idea how your function actually works, so I can't tell you what's going wrong.
[editline]9th January 2016[/editline]
[QUOTE=ArcticWinter;49493316]Right, I need some help. I'm trying to give vehicles collision damage in a script, but I can't get the collision data to do what it's supposed to (Namely, give collision data such as speed). The first time I tested my script, it kept throwing up errors that I was trying to compare a number with a nil. Upon further testing, I found that data.Speed was coming up as nil.
I tried printing the table and this is what I got:
[CODE]Vehicle [430][prop_vehicle_jeep][/CODE]
This is what my callback looks like. It's definitely running.
[CODE]function Arctic_VehicleDamage_Collide( data, collider )
if ( data.Speed >= 125 ) then
local DamageTable = DamageInfo()
DamageTable:SetDamage( data.Speed )
DamageTable:SetDamageType( DMG_CRUSH )
DamageTable:SetInflictor( collider )
self:TakeDamageInfo( DamageTable )
end
end[/CODE]
And here's how I set up the callback, inside a hook for "PlayerSpawnedVehicle":
[CODE]ent:AddCallback( "PhysicsCollide", Arctic_VehicleDamage_Collide )[/CODE]
Can someone help me?[/QUOTE]
You're using the wrong arguments for PhysicsCollide.
First argument is the ent you added the callback to, the second argument is the collision data.
Also, self does not exists inside that function.
[QUOTE=Z0mb1n3;49493455]Well I have no idea how your function actually works, so I can't tell you what's going wrong.
[editline]9th January 2016[/editline]
You're using the wrong arguments for PhysicsCollide.
First argument is the ent you added the callback to, the second argument is the collision data.
Also, self does not exists inside that function.[/QUOTE]
Great, thanks!
I got confused because of the wiki: [url]http://wiki.garrysmod.com/page/ENTITY/PhysicsCollide[/url]
Says that the first argument is collision data.
[QUOTE=ArcticWinter;49493710]Great, thanks!
I got confused because of the wiki: [url]http://wiki.garrysmod.com/page/ENTITY/PhysicsCollide[/url]
Says that the first argument is collision data.[/QUOTE]
Because that's the Scripted Entity hook, not the Callback hook. [url]http://wiki.garrysmod.com/page/Entity_Callbacks[/url]
I'm looking for some advice on how to go about optimizing my Nextbots.
Background - My servers are very heavy on medium-intricacy nextbot NPCs. I am sure the most expensive calculations are to do with finding possible targets extremely often. Whether you do ents find in sphere, ents find by class, etc, I feel that because of the game having to search through basically all entities to compile a list, it's pretty heavy on the performance hit.
What I am wondering was, if I know that the only "entities" my NPC's care about will be players and other NPCs, would it be better to maintain a global table manually that has all the entities I actually care about, and always look through that? It would mean clipping entities and players into the table whenever they are created, and removing them from the table once they are no longer valid, but would this give me a performance gain to be worth the effort?
More of a question than a problem.
If I wanted to create vgui elements but draw them at a later time (in my case, from a function), should I use vgui.Register?
[QUOTE=nulls;49498901]More of a question than a problem.
If I wanted to create vgui elements but draw them at a later time (in my case, from a function), should I use vgui.Register?[/QUOTE]
What Shenesis said. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/vgui/Register]vgui.Register[/url] is for adding new types of panels.
[QUOTE=Shenesis;49498932]Use :SetVisible(false) when the panels are created and :SetVisible(true) when the function is called. If you're planning to draw those panels from a HUDPaint hook, use this example:
[code]
pPanel = vgui.Create("DPanel")
pPanel:SetPaintedManually(true)
pPanel:SetSize(500, 500)
pPanel:Center()
hook.Add("HUDPaint", "DrawPanel", function()
if (IsValid(pPanel) and LocalPlayer():Health() <= 50) then -- Draws the panel only when player's health is under 50
pPanel:SetPaintedManually(false)
pPanel:PaintManual()
pPanel:SetPaintedManually(true)
end
end)
[/code]
[/QUOTE]
You shouldn't use HUDPaint to Paint panels, overwrite the paint function instead.
[code]
function pPanel:Paint(w,h)
--your code here
end
[/code]
[QUOTE=LUModder;49500015]You shouldn't use HUDPaint to Paint panels, overwrite the paint function instead.
[code]
function pPanel:Paint(w,h)
--your code here
end
[/code][/QUOTE]
pretty sure its
[lua]
pPanel.paint = function()
[/lua]
Oh nvm ignore me, either way works XD
[QUOTE=Mrkrabz;49478416]Being plagued with CUtlLinkedList overflow! (exhausted index range) (65535)
I've made sure on all of my particles finish is being called correctly, this only seems to be triggered on certain maps with 60+ players.
I've tried Matts fix here: [url]https://facepunch.com/showthread.php?t=1350845[/url] however It's just causing errors
[lua]Tried to use invalid object (type CLuaEmitter) (Object was NULL or not of the right type)[/lua]
It was apparently also fixed in a gmod update? The only thing we use is custom models and trails (util.SpriteTrail)[/QUOTE]
It appears to be limited to some maps, is there any sort of updated fix that can fix this:
[lua]CUtlLinkedList overflow! (exhausted index range) (65535)[/lua]
Even with all addons disabled, having 60 people on two or three certain maps causes this error and everything to disappear.
More vehicle damage problems!
I'm trying to make a little bit of HUD in the corner above the health box to tell you how much health you vehicle has remaining. You can clearly see why.
Trouble is, the number doesn't update properly; I need to get out and get back in for it to update, and if I get back in too soon it might not even do that. Here's my code:
[CODE]
function Arctic_VehicleDamage_DrawHUD()
local ply = LocalPlayer()
if LocalPlayer():InVehicle() then
local DangerPoint = ( ply:GetVehicle():GetMaxHealth() )
local VehicleHPPercent = "VEH ".. LocalPlayer():GetVehicle():Health()
local VehicleHPColor = Color( 255, 220, 0, 255 )
surface.SetFont( "CloseCaption_Normal" )
surface.SetTextColor( VehicleHPColor )
surface.SetTextPos( ScrW()/50, ScrH() * 0.86 )
surface.DrawText( VehicleHPPercent )
end
end
hook.Add( "HUDPaint", "Arctic_VehicleDamage_HUD", Arctic_VehicleDamage_DrawHUD )
[/CODE]
It's showing up, and it displays the vehicle health fine, but it doesn't update properly.
EDIT: It works fine in a listen server or multiplayer, but not in singleplayer.
What is the difference between setting a SWEPs hold type using
[lua]SWEP.HoldType = "rpg"[/lua]
vs
[lua]function SWEP:Initialize()
self:SetHoldType("rpg")
end[/lua]
[QUOTE=Revenge282;49501993]What is the difference between setting a SWEPs hold type using
[lua]SWEP.HoldType = "rpg"[/lua]
vs
[lua]function SWEP:Initialize()
self:SetHoldType("rpg")
end[/lua][/QUOTE]
You'd usually use SWEP.HoldType and call it in SWEP:Init() if you're using a weapon base
----
I have a file with a global table that doesn't want to update (without being reincluded) for some reason
[url=https://github.com/LUModder/FWP/blob/master/lua/autorun/fwp_registry.lua]File[/url]
Output:
[code]
[14:33] [GCompute GLua STEAM_0:0:58178275 (<color=0,150,130>Flex) -> STEAM_0:0:58178275 (<color=0,150,130>Flex)]
[14:33] -- 0x2f525b48
[14:33] -- FWP
[14:33] {
[14:33] AddNewTabGroup = function (tab, icon) --[[ addons/fwp/lua/autorun/fwp_registry.lua: 34-47, FWP.AddNewTabGroup ]],
[14:33] WeaponsList = FWP.WeaponsList --This is the problem right here, it should be a table and it's just calling itself
[14:33] }
[14:33] -- 2 total entries.
[/code]
Result of the empty table:
[t]https://my.mixtape.moe/gfuesu.png[/t]
[QUOTE=LUModder;49502313]You'd usually use SWEP.HoldType and call it in SWEP:Init() if you're using a weapon base[/QUOTE]
That's not true, and that also doesn't answer my question.
I'm having trouble converting a 3D space into a 2D space.
Its like what most games have for displaying objective locations, if the objective location is off the screen and close to the right, it will display an arrow on the side of the screen like this screenshot
[t]http://i.imgur.com/4ZV94Tk.jpg[/t]
Center right, there's a defend logo. I don't know how I would specifically go about doing this.
I had a rough Idea but I don't know how I could corporate the x axis (forward) into all this.
[code]
local Pos, Ang = WorldToLocal(v.Position,Angle(0,0,0),ply:EyePos(),ply:EyeAngles())
print(math.floor(Pos.y),math.floor(Pos.z))
[/code]
[QUOTE=ROFLBURGER;49503006]I'm having trouble converting a 3D space into a 2D space.
Its like what most games have for displaying objective locations, if the objective location is off the screen and close to the right, it will display an arrow on the side of the screen like this screenshot
[t]http://i.imgur.com/4ZV94Tk.jpg[/t]
Center right, there's a defend logo. I don't know how I would specifically go about doing this.
I had a rough Idea but I don't know how I could corporate the x axis (forward) into all this.
[code]
local Pos, Ang = WorldToLocal(v.Position,Angle(0,0,0),ply:EyePos(),ply:EyeAngles())
print(math.floor(Pos.y),math.floor(Pos.z))
[/code][/QUOTE]
I think you might be looking for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/ToScreen]Vector:ToScreen[/url] - Then just clamp the x and y coordinates you get so it's always shown on screen.
[QUOTE=MPan1;49503137]I think you might be looking for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/ToScreen]Vector:ToScreen[/url] - Then just clamp the x and y coordinates you get so it's always shown on screen.[/QUOTE]
Amazing, thank you. You saved me a headache.
Sorry, you need to Log In to post a reply to this thread.