[QUOTE=TehBigA;52239275]Short answer is that it's not an option. At least not by default. You could remove the hook, but then [I]none[/I] of the drop lines would work for your whole session.
[code]hook.Remove('DrawOverlay', 'DragNDropPaint')[/code]
For some reason it was baked right into the dragdrop.lua library ([I]lua/includes/extensions/client/panel/dragdrop.lua[/I]) as a lambda added straight to the DrawOverlay hook with no option.
I'm sure if somebody made a Pull Request for a toggle that could be set on drop receivers it'd be accepted for the next update.[/QUOTE]
Removing the hook completely is an option, for my gamemode it wont be needed anywhere. This seems to only remove the drag-ghosting of the panel though, not the actual drawing of the box
EDIT: Fixed [I]garrysmod/lua/includes/extensions/client/panel/dragdrop.lua[/I] I overrode meta:DrawDragHover( x, y, w, h ) and it removed it :)
[QUOTE=DahDestroyer;52242672]Removing the hook completely is an option, for my gamemode it wont be needed anywhere. This seems to only remove the drag-ghosting of the panel though, not the actual drawing of the box
EDIT: Fixed [I]garrysmod/lua/includes/extensions/client/panel/dragdrop.lua[/I] I overrode meta:DrawDragHover( x, y, w, h ) and it removed it :)[/QUOTE]
Haha, whoops I misread the code :P Glad you found it, now I know too.
[code] function ENT:OnPlayerDeath( victim, inflictor, attacker ) -- args not needed
self.owner:SetMoveType(MOVETYPE_WALK)
self.owner:SetParent(nil)
self:setOccupied(false)
print(true) -- just testing to see if this is being run
end
hook.Add( "PlayerDeath", ENT, ENT.OnPlayerDeath ) [/code]
Anyone know how this should be setup to run the above function? I need to call self when the player dies but that won't run. The little print test I setup doesn't show up, so it isn't running.
Here's the thing, ENT doesn't make sense in this context (see [url]http://xyproblem.info/[/url] )
Remember that there can be multiple instances of your entity, and "self" is that specific instance. Do you want OnPlayerDeath to be called on [I]every entity that is spawned?[/I]
[QUOTE=bosnian_cyco;52243677][code] function ENT:OnPlayerDeath( victim, inflictor, attacker ) -- args not needed
self.owner:SetMoveType(MOVETYPE_WALK)
self.owner:SetParent(nil)
self:setOccupied(false)
print(true) -- just testing to see if this is being run
end
hook.Add( "PlayerDeath", ENT, ENT.OnPlayerDeath ) [/code]
Anyone know how this should be setup to run the above function? I need to call self when the player dies but that won't run. The little print test I setup doesn't show up, so it isn't running.[/QUOTE]
I'm not really sure what you're trying to do, and it's probably wrong. However, I think you deserve a technical answer to your technical question:
[lua]function ENT:Initialize()
-- ...
hook.Add("PlayerDeath", self, self.OnPlayerDeath)
-- ...
end[/lua]
Note that ALL your sents will run this function when ANY player dies. You probably want to have code verifying that the player that died is the entity's owner before doing stuff.
Been messing with 2D and 3D rendering functions and such and all is dandy, but is it possible to draw a cylinder?
Ideally I'd like to draw a cylinder from the players feet up to the top of the skybox with the player in the middle.
[QUOTE=fishcake;52244540]Been messing with 2D and 3D rendering functions and such and all is dandy, but is it possible to draw a cylinder?
Ideally I'd like to draw a cylinder from the players feet up to the top of the skybox with the player in the middle.[/QUOTE]
Cube is a cylinder with 4 middle edges. So yes it is possible
[QUOTE=EgrOnWire;52244545]Cube is a cylinder with 4 middle edges. So yes it is possible[/QUOTE]
But you can't specify the amount of edges you want with render.DrawBox
There's no default function for drawing a cylinder, but what you could do is draw a cylindrical model using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ClientsideModel]ClientsideModel[/url], or try something confusing using the circle drawing example with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/DrawPoly]surface.DrawPoly[/url] and try to get that to look like it's in 3D space
You could also try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Mesh]Mesh[/url], but from what I've heard, it's pretty tricky and confusing
[QUOTE=MPan1;52244568]But you can't specify the amount of edges you want with render.DrawBox
There's no default function for drawing a cylinder, but what you could do is draw a cylindrical model using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ClientsideModel]ClientsideModel[/url], or try something confusing using the circle drawing example with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/DrawPoly]surface.DrawPoly[/url] and try to get that to look like it's in 3D space
You could also try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Mesh]Mesh[/url], but from what I've heard, it's pretty tricky and confusing[/QUOTE]
Ah the model idea could work, though I'm assuming going down this route I'd be limited in terms of changing dimensions on the fly, for example growing and shrinking from the player?
Since it's a clientside model I doubt it'd be that slow if you used [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetModelScale]Entity:SetModelScale[/url] frequently
Where can i find tutorials on how to edit cars / making new ones?
Are vehicle lua based or how are they made?
[url]https://facepunch.com/showthread.php?t=880347[/url] has a few useful replies
[QUOTE=NeatNit;52244063]I'm not really sure what you're trying to do, and it's probably wrong. However, I think you deserve a technical answer to your technical question:
[lua]function ENT:Initialize()
-- ...
hook.Add("PlayerDeath", self, self.OnPlayerDeath)
-- ...
end[/lua]
Note that ALL your sents will run this function when ANY player dies. You probably want to have code verifying that the player that died is the entity's owner before doing stuff.[/QUOTE]
That won't work. "self" will then become the victim.
[QUOTE=LegoGuy;52244820]That won't work. "self" will then become the victim.[/QUOTE]
It would work as long as the function is still defined like
[code]
function ENT:OnPlayerDeath(victim, inflictor, attacker)
[/code]
[QUOTE=MPan1;52244680]Since it's a clientside model I doubt it'd be that slow if you used [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetModelScale]Entity:SetModelScale[/url] frequently[/QUOTE]
Through a lot of usage of this for my tank tracks addon, and messing with the idea of a prop -> clientside prop conversion tool, the slowest thing actually seems to be [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetModel]Entity:SetModel[/url]
Is there a way to run server/client side lua during demo recordings? My code didn't run during playdemos, as expected, and I was wondering if there's some kind of override. Thanks.
[QUOTE=VIoxtar;52244917]Is there a way to run server/client side lua during demo recordings? My code didn't run during playdemos, as expected, and I was wondering if there's some kind of override. Thanks.[/QUOTE]
There's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/engine/IsPlayingDemo]engine.IsPlayingDemo[/url], which also explains that:
[quote=engine.IsPlayingDemo]You will notice that there's no server-side version of this. That's because there is no server when playing a demo. Demos are both recorded and played back purely clientside.[/quote]
Whatever you're doing, you're gonna have to do it entirely clientside.
[QUOTE=NeatNit;52245004]There's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/engine/IsPlayingDemo]engine.IsPlayingDemo[/url], which also explains that:
Whatever you're doing, you're gonna have to do it entirely clientside.[/QUOTE]
Thing is clientside scripts failed to work as well.
What failed exactly? All client-side scripts? Client-side scripts that depend on net messages (DarkRPVars, ...)?
Why does this code keep running in a loop, and how do i fix it? Been sitting with it for a little while.
[code]
hook.Add("playerArrested","vipjailtime", function(criminal,time,arrester)
if criminal:IsUserGroup("vip") then
newtime = time / 2
timer.Simple(0.2, function() criminal:unArrest() end)
timer.Simple(0.5, function() criminal:arrest(newtime, arrester) end)
end
end)
[/code]
Thanks in advance.
[QUOTE=SkitZz;52245448]Why does this code keep running in a loop, and how do i fix it? Been sitting with it for a little while.
[code]
hook.Add("playerArrested","vipjailtime", function(criminal,time,arrester)
if criminal:IsUserGroup("vip") then
newtime = time / 2
timer.Simple(0.2, function() criminal:unArrest() end)
timer.Simple(0.5, function() criminal:arrest(newtime, arrester) end)
end
end)
[/code]
Thanks in advance.[/QUOTE]
It keeps running in a loop because it is called after the player is arrested. You unarrest him the re-arrest him, causing the hook to be called again
Also [B]newtime[/B] is a global variable, you should make it local
[QUOTE=JasonMan34;52245486]It keeps running in a loop because it is called after the player is arrested. You unarrest him the re-arrest him, causing the hook to be called again
Also [B]newtime[/B] is a global variable, you should make it local[/QUOTE]
Alright, thanks. I made the variable local now, but i am unsure how to fix the looping issue. I can't think of a better way to do it, better than unarresting the player and then rearresting again. Any idea how i can fix it?
[QUOTE=SkitZz;52245495]Alright, thanks. I made the variable local now, but i am unsure how to fix the looping issue. I can't think of a better way to do it, better than unarresting the player and then rearresting again. Any idea how i can fix it?[/QUOTE]
Assign the the arrested player a variable indicating that the time-halving event shouldn't occur.
[lua]hook.Add("playerArrested","vipjailtime", function(criminal,time,arrester)
if criminal:IsUserGroup("vip") and not criminal.justGotArrested then
local newtime = time / 2
timer.Simple(0.2, function()
criminal:unArrest()
criminal.justGotArrested = true
end)
timer.Simple(0.5, function()
criminal:arrest(newtime, arrester)
criminal.justGotArrested = false
end)
end
end)[/lua]
[QUOTE=JasonMan34;52245509]Assign the the arrested player a variable indicating that the time-halving event shouldn't occur.
[lua]hook.Add("playerArrested","vipjailtime", function(criminal,time,arrester)
if criminal:IsUserGroup("vip") and not criminal.justGotArrested then
local newtime = time / 2
timer.Simple(0.2, function()
criminal:unArrest()
criminal.justGotArrested = true
end)
timer.Simple(0.5, function()
criminal:arrest(newtime, arrester)
criminal.justGotArrested = false
end)
end
end)[/lua][/QUOTE]
Ah yes, obviously! Thank you so much.. Couldn't really wrap my head around it :)
[QUOTE=bigdogmat;52244840]It would work as long as the function is still defined like
[code]
function ENT:OnPlayerDeath(victim, inflictor, attacker)
[/code][/QUOTE]
No, it won't because ENT:OnPlayerDeath(victim, inflictor, attacker) is identical to ENT.OnPlayerDeath(self, victim influctor, attacker) and hooks don't call functions with a : or pass the entity as the first argument.
[editline]18th May 2017[/editline]
[IMG]http://puu.sh/vU4Ma/c50a4adb3a.png[/IMG]
I'm dumb shower me with boxes.
[QUOTE=NeatNit;52244063]I'm not really sure what you're trying to do, and it's probably wrong. However, I think you deserve a technical answer to your technical question:
[lua]function ENT:Initialize()
-- ...
hook.Add("PlayerDeath", self, self.OnPlayerDeath)
-- ...
end[/lua]
Note that ALL your sents will run this function when ANY player dies. You probably want to have code verifying that the player that died is the entity's owner before doing stuff.[/QUOTE]
What I'm doing is I'm making this tow missile as sort of a learning project. And basically i have the user parented to the ent so he cant move and stuff while controlling the launcher. So when player dies, he becomes null and fucks up everything. So i was trying to find a way to un-parent before he dies. You're right, this feels really wrong but its already helped me learn a lot about angles and vectors. So yea. :D
Edited because phone grammar.
Edit #2: It worked. Thanks :)
[QUOTE=LegoGuy;52245733]I'm dumb shower me with boxes.[/QUOTE]
Only doing it because you asked me to - it's fair that you didn't know.
[img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/image.php?u=205650&dateline=1393219865[/img][img]https://facepunch.com/fp/ratings/box.png[/img]
[img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img]
[img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img]
[img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img]
[img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img][img]https://facepunch.com/fp/ratings/box.png[/img]
How to make matrix transform of image with other rotation point and transform image to player position? Like on minimap. My trys doesn't brought a definite result.
[QUOTE=MPan1;52239333]Did you add .PNG to the end of the SetImage path?
[/QUOTE]
I had not, just tried it, same result. Same if I add .vmt or .vtf to the material one. (But if I change the name to "yashi_pipboy3" with or without the .vmt, .vtf or .png, it just comes up as a missing texture thats the correct size.
[t]http://i.imgur.com/g6nnyf2.jpg[/t]
Is there a good way to reload scripts when just playing around with ideas? I'm working on a SWEP and every time I make changes I have to restart my server.
Sorry, you need to Log In to post a reply to this thread.