Hello, Is there a way to be able to stop a single weapon from dropping? For example the drop weapon key in my gamemode is q but people are able to drop thier fists when they press q. Is there a way I can stop them from dropping?
Like a swep hook?
Any help would be appreciated.
[LUA]if dropping_weapon_entity:GetClass() == "weapon_fists" then return end[/LUA] ??
[QUOTE=rejax;42921258][LUA]if dropping_weapon_entity:GetClass() == "weapon_fists" then return end[/LUA] ??[/QUOTE]
would i put that into the fists code?
Like the shared.lua?
[QUOTE=Bordermick;42921277]would i put that into the fists code?[/QUOTE]
It would go in the code that does the actual dropping.
SWEP.AllowDrop = false
This is what my drop weapon code looks like:
[lua]function JB:OnSpawnMenuOpen()
RunConsoleCommand("jb_dropweapon");
end[/lua]
Would I make it look Like this?
[lua]function JB:OnSpawnMenuOpen()
RunConsoleCommand("jb_dropweapon");
if dropping_weapon_entity:GetClass() == "weapon_fists" then return end
end[/lua]
[editline]20th November 2013[/editline]
That does not work.[QUOTE=Sm63;42921566]SWEP.AllowDrop = false[/QUOTE]
That's what the hook that calls your drop weapon code looks like. If you did it there then people could still drop there weapon through the console.
Look to see where jb_dropweapon is defined and do it in there.
[quote]
[editline]20th November 2013[/editline]
That does not work.[/QUOTE]
How did you use it?
[QUOTE=Bordermick;42923824]
Would I make it look Like this?
[lua]function JB:OnSpawnMenuOpen()
RunConsoleCommand("jb_dropweapon");
if dropping_weapon_entity:GetClass() == "weapon_fists" then return end
end[/lua]
That does not work.[/QUOTE]
Seriously? That was just example code. Look at what you're doing.
First, you run the command, then you check to see if the weapon is fists. You're not even using a real weapon.
Of course it doesn't work.
[lua]function JB:OnSpawnMenuOpen()
if LocalPlayer():GetActiveWeapon():GetClass() == "weapon_fists" then return end
RunConsoleCommand("jb_dropweapon");
end[/lua]
give us the actual jb_dropweapon concommand function.
otherwise we can't help. the post above me would work, but that is not how it should be done.
[QUOTE=Sm63;42923913]How did you use it?[/QUOTE]
Isn't AllowDrop only for TTT?
OP:
Make a table containing each weapon you can't drop. Before executing the drop function, check if the dropped weapon is contained in the table.
Thanks everyone for your help. But I got it working where the concommand code is I will now marked the thread as solved
Sorry, you need to Log In to post a reply to this thread.