Ive been trying to make a drop weapon script for certain weapons, if they have the dropweapon bool = true, any help much appreciated.
Script:
[lua]
ahighcaliber = {
"weapon_crowbar"
}
function Droptheweapon( ply )
for k, v in pairs( player.GetAll() ) do
heavyweapon = tostring(ahighcaliber)
if ( v:GetNetworkedBool( "Dropweapon" ) == true ) then
if (v:GetActiveWeapon():GetClass() == heavyweapon) then
v:DropWeapon(v:GetActiveWeapon())
end
end
end
end
timer.Create( "Droptheweapon", 1, 0, Droptheweapon, v )
[/lua]
The problem I am finding with it, is that it doesnt drop the weapon at all and continues to stay in your hand.
Any ideas anyone?
[QUOTE=iRzilla;25273093] ahighcaliber = { "weapon_crowbar" "weapon_anotherweapon" } function Droptheweapon(ply) for _, ply in pairs(player.GetAll()) do for _, wep in pairs(ahighcaliber) do if ply:GetNetworkedBool("Dropweapon") then if ply:GetActiveWeapon():GetClass() == wep then ply:DropWeapon(wep) end end end end end timer.Create( "Droptheweapon", 1, 0, Droptheweapon)
I did have a massive long post with loads of reasons why your code was wrong but Facepunch went down or something.[/QUOTE]
Thanks iRzilla, I see exactly where I went wrong.
[editline]09:38PM[/editline]
Only one problem is that its getting the error on:
[lua]
ply:DropWeapon(wep)
[/lua]
Error is:
[code]
(Entity expected, got string)
[/code]
Here's how it's done on the wiki
[lua]v:DropWeapon(v:GetWeapon("weapon_physgun"))
[/lua]
Just do.
[lua]ply:DropWeapon(ply:GetWeapon(wep))
[/lua]
Thanks Cubar, Why didnt I see that? :S
You're welcome
[QUOTE=iRzilla;25276293]You're welcome.[/QUOTE]
Lol jelous, and stupid.
Sorry, you need to Log In to post a reply to this thread.