[QUOTE=code_gs;52758977]Both can be set from the client, but they're just immediately reverted since the server's value takes priority. What you should do is set it shared so the variable is properly predicted.
If you have to set a value from just the client, then use the net library.[/QUOTE]
Yeah that's what I guessed, thanks for the help, I would give you a reputation point or something but I don't know if there's anything like that here.
[QUOTE=Ubre;52758985]Yeah that's what I guessed, thanks for the help, I would give you a reputation point or something but I don't know if there's anything like that here.[/QUOTE]
Some people do stuff like +rep in their profile messages but it doesn't do anything
[QUOTE=MPan1;52758993]Some people do stuff like +rep in their profile messages but it doesn't do anything[/QUOTE]
Thanks for clarifying! [B]+rep[/B]
[QUOTE=gmoddertr;52758398]If you mean like this;
[CODE]local myvar = 0
hook.Add("CreateMove", "IncreaseMyVar", function()
if input.IsMouseDown(MOUSE_WHEEL_DOWN) then
myvar = myvar - 1
print(myvar)
elseif input.IsMouseDown(MOUSE_WHEEL_UP) then
myvar = myvar + 1
print(myvar)
end
end)[/CODE]
still doesnt work.[/QUOTE]
If MOUSE_WHEEL_DOWN, UP are broken, why not just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerBindPress]GM:PlayerBindPress[/url]
You can just set it to
[lua]
invprev
or
invnext
[/lua]
You could maybe hook into this to have a print run to console just for testing and then set it up for what ever you need after it works.
[QUOTE=Richtofen;52759818]If MOUSE_WHEEL_DOWN, UP are broken, why not just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerBindPress]GM:PlayerBindPress[/url]
You can just set it to
[lua]
invprev
or
invnext
[/lua]
You could maybe hook into this to have a print run to console just for testing and then set it up for what ever you need after it works.[/QUOTE]
That's only if the user has the wheel binded to that, and if another addon hasn't already overwritten that bind.
[CODE]
--shared.lua
local Delta_Mod = 10;
hook.Add( "Move", "__Move", function( ply, move )
if !( ply:OnGround() ) then
local CurVelocity = move:GetVelocity();
local Delta = ( FrameTime() * Delta_Mod );
CurVelocity.x = Lerp( Delta, CurVelocity.x, 0 );
CurVelocity.y = Lerp( Delta, CurVelocity.y, 0 );
move:SetVelocity( CurVelocity );
end
end );
[/CODE]
I wanted to make a quick fix to bunny-hopping, however I'm not sure I'm doing a good job. Any suggestions?
[QUOTE=Commander11;52760253]I wanted to make a quick fix to bunny-hopping, however I'm not sure I'm doing a good job. Any suggestions?[/QUOTE]
[URL="https://github.com/thegrb93/garrysmod/blob/master/garrysmod/gamemodes/sandbox/gamemode/player_class/player_sandbox.lua#L189-L197"]Garry's Mod already attempts to fix backward and fast bunnyhopping on these lines.[/URL] Try basing your code off what it does.
[QUOTE=MPan1;52761072][URL="https://github.com/thegrb93/garrysmod/blob/master/garrysmod/gamemodes/sandbox/gamemode/player_class/player_sandbox.lua#L189-L197"]Garry's Mod already attempts to fix backward and fast bunnyhopping on these lines.[/URL] Try basing your code off what it does.[/QUOTE]
That's for ABH, only affects backwards bhopping and strafing slightly.
[QUOTE=MPan1;52758769][URL="https://facepunch.com/showthread.php?t=1548067&p=52754948&viewfull=1#post52754948"]Bumping my last question in case anyone here knows stencils[/URL]
[editline]8th October 2017[/editline]
I probably should've done this on the next page actually[/QUOTE]
Does this need to play nice with other stencils? (that would be much harder)
If not, you can do basically what bigdogmat said:
[QUOTE=bigdogmat;52755665]You're issue is the order you're drawing the circles
[code]
render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilWriteMask(255)
render.SetStencilTestMask(255)
render.SetStencilFailOperation(STENCIL_KEEP)
render.SetStencilZFailOperation(STENCIL_KEEP)
render.SetStencilPassOperation(STENCIL_INCR)
render.SetStencilCompareFunction(STENCIL_ALWAYS)
surface.SetDrawColor(0, 0, 0, 255)
DrawCircle(75, 75, 50, 10)
render.SetStencilReferenceValue(1)
render.SetStencilCompareFunction(STENCIL_EQUAL)
surface.SetDrawColor(255, 255, 255, 255)
DrawCircle(100, 100, 30, 10)
render.SetStencilEnable(false)
[/code][/QUOTE]
Except put both DrawCircles together and set the reference value to 2 instead of 1. Then, only pixels which were drawn on by both circles will have the value 2. At this point you can draw whatever you like and it would be drawn in the intersection of the circles.
If what you need is different, then be as specific as you can about exactly what you need, because you're not giving us quite enough to work with...
[editline]9th October 2017[/editline]
Do you even actually want to draw the black circle or is that just there to visualize your question?
[QUOTE=NeatNit;52761121]Does this need to play nice with other stencils? (that would be much harder)
If not, you can do basically what bigdogmat said:
Except put both DrawCircles together and set the reference value to 2 instead of 1. Then, only pixels which were drawn on by both circles will have the value 2. At this point you can draw whatever you like and it would be drawn in the intersection of the circles.
If what you need is different, then be as specific as you can about exactly what you need, because you're not giving us quite enough to work with...
[editline]9th October 2017[/editline]
Do you even actually want to draw the black circle or is that just there to visualize your question?[/QUOTE]
Sorry, I forgot to post this bit again:
[t]https://i.imgur.com/qO3wLGr.png[/t]
This image is pretty much exactly what I want to do, with the black circle being drawn, and the white bit acting as a kind of mask.
You probably already saw this, I don't need the black bit to act as anything special, but I do want to draw it.
[editline]9th October 2017[/editline]
I understand what you mean, thanks so much for the help!
[QUOTE=NeatNit;52761190]Try this:
[lua]render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilWriteMask(255)
render.SetStencilTestMask(255)
render.SetStencilFailOperation(STENCIL_KEEP)
render.SetStencilZFailOperation(STENCIL_KEEP)
render.SetStencilPassOperation(STENCIL_INCR)
render.SetStencilCompareFunction(STENCIL_ALWAYS)
surface.SetDrawColor(0, 0, 0, 255)
DrawCircle(75, 75, 50, 10)
render.SetStencilReferenceValue(1)
render.SetStencilCompareFunction(STENCIL_EQUAL)
surface.SetDrawColor(255, 255, 255, 255)
DrawCircle(100, 100, 30, 10)
render.SetStencilReferenceValue(2)
render.SetStencilPassOperation(STENCIL_KEEP)
DrawCreepyBlackMan()
render.SetStencilEnable(false)[/lua][/QUOTE]
This works absolutely perfectly, thank you so much, you saved me hours
Does anyone know why this happens after picking up ammo?
[CODE]
hook.Add("HUDAmmoPickedUp", "Ammo", function(type, amount)
print(type, amount) -- output: 5.56x45MM 256 (as expected)
print(LocalPlayer():GetAmmoCount(type)) -- output: 0 (even though ammo was literally just picked up?)
end)
[/CODE]
If there's a hook where I can get the [I]proper[/I] ammo count after adding ammo, would be nice. I tried a net message after ply:GiveAmmo serverside but it still showed 0 on the client's net.Receive (one second timer in the callback showed it properly, though)
[QUOTE=Threebow;52761270]Does anyone know why this happens after picking up ammo?
[CODE]
hook.Add("HUDAmmoPickedUp", "Ammo", function(type, amount)
print(type, amount) -- output: 5.56x45MM 256 (as expected)
print(LocalPlayer():GetAmmoCount(type)) -- output: 0 (even though ammo was literally just picked up?)
end)
[/CODE]
If there's a hook where I can get the [I]proper[/I] ammo count after adding ammo, would be nice. I tried a net message after ply:GiveAmmo serverside but it still showed 0 on the client's net.Receive (one second timer in the callback showed it properly, though)[/QUOTE]
Try this:
[CODE]
LocalPlayer():GetAmmoCount( game.GetAmmoID( type ) )
[/CODE]
I've had issue with custom ammo types not working as expected in the past and this resolved it for me, atleast.
[QUOTE=DahDestroyer;52761394]Try this:
[CODE]
LocalPlayer():GetAmmoCount( game.GetAmmoID( type ) )
[/CODE]
I've had issue with custom ammo types not working as expected in the past and this resolved it for me, atleast.[/QUOTE]
Just tried that, no dice. Still gives the same result. If I pick up more ammo of a type I had, it shows how much I had prior to picking it up.
[QUOTE=Threebow;52762552]Just tried that, no dice. Still gives the same result. If I pick up more ammo of a type I had, it shows how much I had prior to picking it up.[/QUOTE]
I believe HUDAmmoPickedUp is called before the ammo is actually given to the player.
Sometimes the weapon mm_skull is given to the player, sometimes it's not. Regardless, the entity is ALWAYS removed.
[lua]
initialize: self.Entity:SetUseType(CONTINUOUS_USE)
function ENT:Use( activator, caller )
if (activator:IsPlayer()) then
activator:Give("mm_skull",false)
if SERVER then
net.Start("MMGiveSkull",false)
net.WriteEntity( activator )
net.Broadcast()
end
self:Remove()
end
end
util.AddNetworkString("MMGiveSkull")
function MMGiveSkull(len,client)
if IsValid(client) then
local ent = net.ReadEntity()
ent:Give("mm_skull",false)
ent:GiveAmmo(1,"strider",false)
end
end
net.Receive("MMGiveSkull", MMGiveSkull)
[/lua]
Use SIMPLE_USE for what you're doing. Also, the ENT.Use hook is serverside only, and so is ENTITY.Give/GiveAmmo. That means your code can be simplified to:
[code]function ENT:Initialize()
-- Other code
if (SERVER) then
self:SetUseType(SIMPLE_USE)
end
end
if (SERVER) then
function ENT:Use(_, pCaller)
if (pCaller:IsPlayer()) then
pCaller:Give("mm_skull")
pCaller:GiveAmmo(1, "strider")
self:Remove()
end
end
end[/code]
Also, just wanted to note that strider is not a valid default ammo type, didn't know if that was a custom one you declared or not.
[QUOTE=code_gs;52763042]Use SIMPLE_USE for what you're doing. Also, the ENT.Use hook is serverside only, and so is ENTITY.Give/GiveAmmo. That means your code can be simplified to:
[code]function ENT:Initialize()
-- Other code
if (SERVER) then
self:SetUseType(SIMPLE_USE)
end
end
if (SERVER) then
function ENT:Use(_, pCaller)
if (pCaller:IsPlayer()) then
pCaller:Give("mm_skull")
pCaller:GiveAmmo(1, "strider")
self:Remove()
end
end
end[/code]
Also, just wanted to note that strider is not a valid default ammo type, didn't know if that was a custom one you declared or not.[/QUOTE]
Still no luck. The entity itself is removed but no weapon is given.
(Also the strider ammo was just to see if I would get notified of receiving it. The weapon itself doesn't use ammo).
[QUOTE=Shendow;52763181]Check if the player already has the weapon? Make a print check on [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/Initialize]SWEP:Initialize[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/OnRemove]SWEP:OnRemove[/url] to see if the SWEP is at least being created (and if it is being removed)[/QUOTE]
Interesting, you're right. The weapon is being created and then getting removed right after, according to the print.
[QUOTE=buu342;52763392]Interesting, you're right. The weapon is being created and then getting removed right after, according to the print.[/QUOTE]
Could be a hook that is not allowing the player to pickup the weapon, or it is being removed manually.
Is there a way to send models / materials to players after they've already connected?
I don't want to make them wait in a loading screen forever.
[QUOTE=angrytoiletry;52763639]Is there a way to send models / materials to players after they've already connected?
I don't want to make them wait in a loading screen forever.[/QUOTE]
One way people have sorta worked around this is by having a "You require these" upon joining, and these link to the required workshop items.
Then the users have the option to download the content or not.
Indeed there was. Found the horrid thing and made an exception for mm_skull. Works perfectly now.
[QUOTE=angrytoiletry;52763639]Is there a way to send models / materials to players after they've already connected?
I don't want to make them wait in a loading screen forever.[/QUOTE]
You can play around with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/MountGMA]game.MountGMA[/url].
[QUOTE=code_gs;52763832]You can play around with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/MountGMA]game.MountGMA[/url].[/QUOTE]
pretty sure you also need [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/steamworks/Download]steamworks.Download[/url] along with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/MountGMA]game.MountGMA[/url]
[QUOTE=MelonShooter;52764080]pretty sure you also need [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/steamworks/Download]steamworks.Download[/url] along with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/MountGMA]game.MountGMA[/url][/QUOTE]
That is listed on the page I linked.
I'm having problems with bonemerging. I'm not sure of the best way to attach two entities together.
All I want is a way to orient an entity to another while maintaining an offset.
For example, I want this bomb to stay locally or globally at Vector( 1, 2, 3 ):
[CODE]
local thing = ents.Create( "prop_physics" )
thing:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
thing:SetPos( Vector( 1, 2, 3 ) )
thing:SetAngles( Angle( 90, 180, 270 ) )
thing:Spawn()
local ent = player.GetAll()[ 1 ]:GetEyeTrace().Entity
thing:SetParent( ent )
thing:AddEffects( EF_BONEMERGE )
[/CODE]
But it always snaps to the center of whatever entity I'm looking at.
[QUOTE=MPan1;52765098]I'm having problems with bonemerging. I'm not sure of the best way to attach two entities together.
All I want is a way to orient an entity to another while maintaining an offset.
For example, I want this bomb to stay locally or globally at Vector( 1, 2, 3 ):
[CODE]
local thing = ents.Create( "prop_physics" )
thing:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
thing:SetPos( Vector( 1, 2, 3 ) )
thing:SetAngles( Angle( 90, 180, 270 ) )
thing:Spawn()
local ent = player.GetAll()[ 1 ]:GetEyeTrace().Entity
thing:SetParent( ent )
thing:AddEffects( EF_BONEMERGE )
[/CODE]
But it always snaps to the center of whatever entity I'm looking at.[/QUOTE]
I've played with that before, tried to make an entity parent to a certain bone. If you don't specify the attachment id it will just make it snap at the center. [url]https://wiki.garrysmod.com/page/Entity/GetAttachments[/url] here are the attachments.
Also another thing I noticed is that you need to change the movetype of the entity to MOVETYPE_NONE before parenting it to anything.
EDIT: Also make sure to remove the collisions or the player it's parented to will be stuck in it.
EDIT2: Also worth saying that everytime I tried to run BoneMerge it always ruins everything, not sure why, I found that it's pretty useless to use.
So I am trying to get the material type of the ground the player is standing on using something to the affect of this ply:GetGroundEntity():GetMaterialType() This works well on everything but the world. The world always returns 48 no matter what. How do I get the material type of the portion of the world the player is currently standing on? I can't even find what 48 represents when it comes to the MAT Enumerations its not listed.
Sorry, you need to Log In to post a reply to this thread.