[QUOTE=geferon;51952309][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/AllowPlayerPickup]GM:AllowPlayerPickup[/url]
return true[/QUOTE]
On the contrary. Prohibit lifting weapons from the floor.
And not "USE".
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerCanPickupWeapon]GM:PlayerCanPickupWeapon[/url]
[editline]13th March 2017[/editline]
Next time use [url=https://facepunch.com/showthread.php?t=1548067]Problems that don't need their own thread[/url]
As for the picking up weapons with E I think the only way would be to create a custom entity, but I could be wrong.
[QUOTE=bilbasio;51953311]As for the picking up weapons with E I think the only way would be to create a custom entity, but I could be wrong.[/QUOTE]
[QUOTE=geferon;51952309][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/AllowPlayerPickup]GM:AllowPlayerPickup[/url]
return true[/QUOTE]
[QUOTE=code_gs;51953320][/QUOTE]
Isn't [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/AllowPlayerPickup]GM:AllowPlayerPickup[/url] for actually grabbing something? as in like with the grav gun?
[QUOTE=bilbasio;51953330]Isn't [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/AllowPlayerPickup]GM:AllowPlayerPickup[/url] for actually grabbing something? as in like with the grav gun?[/QUOTE]
If you read the description of AllowPlayerPickup then you'd see that it states this: Called when a player tries to pick up something using the "use" key, return to override.
[QUOTE=zacklogan;51953349]If you read the description of AllowPlayerPickup then you'd see that it states this: Called when a player tries to pick up something using the "use" key, return to override.[/QUOTE]
Have you ever tried using e on an object in gmod? It picks it up right? I'm pretty sure that function overrides this.
[editline]13th March 2017[/editline]
Read the OP again, he wants to [b]equip[/b] the weapon when you press E
[QUOTE=bilbasio;51953365]Have you ever tried using e on an object in gmod? It picks it up right? I'm pretty sure that function overrides this.
[editline]13th March 2017[/editline]
Read the OP again[/QUOTE]
The hook is called whenever an object is attempted to picked up by the player and they can pick it up.
[QUOTE=code_gs;51953382]The hook is called whenever an object is attempted to picked up by the player and they can pick it up.[/QUOTE]
I know what it does but I don't think it's what the OP wants to do, he wants to equip it when he presses E, unless I'm mistaken.
[QUOTE=bilbasio;51953389]I know what it does but I don't think it's what the OP wants to do, he wants to equip it when he presses E, unless I'm mistaken.[/QUOTE]
Oh, I read his request backward. He can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerUse]GM:PlayerUse[/url] to give the player the weapon.
[QUOTE=code_gs;51953397]Oh, I read his request backward. He can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerUse]GM:PlayerUse[/url] to give the player the weapon.[/QUOTE]
Do you think it's possible to do without a SENT? I'm pretty sure he needs to code one.
[QUOTE=bilbasio;51953408]Do you think it's possible to do without a SENT? I'm pretty sure he needs to code one.[/QUOTE]
Won't PlayerUse passed the used weapon as the entity?
[QUOTE=code_gs;51953499]Won't PlayerUse passed the used weapon as the entity?[/QUOTE]
Oh ok that makes sense thanks for answering I was wondering how to do that too.
[QUOTE=Moat;51953827]Simply returning false in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerCanPickupWeapon]GM:PlayerCanPickupWeapon[/url] won't solve the OP's issue; that would result in the player unable to pickup a weapon in all cases, even if it's given by using Give(). It'd also prevent loadout weapons from being given as well IIRC.
Here's something. The player will only be able to pickup the weapon if he's looking at it while they released USE. Released, rather than down, to prevent holding down the USE key and just walking over a ton of weapons to pick them up.
[lua]
hook.Add("PlayerCanPickupWeapon", "blahah", function(ply, wep)
local tr = ply:GetEyeTrace()
-- fixes the "Give" issue by checking the creation time of the ent and allowing it to be given if it was created shortly before checking
-- the 0.1 allows a little leway between the creation time and time it was given
if (CurTime() - wep:GetCreationTime() <= 0.1) then
return true
elseif (not ply:KeyReleased(IN_USE) or tr.Entity ~= wep) then
return false
end
end)[/lua][/QUOTE]
Oh.. Thanks.
Sorry, you need to Log In to post a reply to this thread.