• Script Edit: Weapon Pickup on Use
    2 replies, posted
Good afternoon, FP! I hope someone can help me. All I need is for someone to edit a "weapon-pickup-on-use" script to be able to toggle on and off. The code is as follows: [CODE]hook.Add( "PlayerSpawn", "PickupTimeout", function( ply ) ply.PickupTimeout = CurTime() + 0.5 end ) hook.Add( "PlayerCanPickupWeapon", "NoPickup", function( ply, wep ) if ( ( ply.PickupTimeout or 0 ) < CurTime() ) then return false end end ) hook.Add( "KeyPress", "PressUse", function( ply, key ) if ( key == IN_USE ) then local tr = ply:GetEyeTrace() if ( ValidEntity( tr.Entity ) and tr.Entity:IsWeapon() and tr.Entity:GetPos():Distance( ply:GetShootPos() ) < 64 ) then ply.PickupTimeout = CurTime() + 0.5 ply:Give( tr.Entity:GetClass() ) tr.Entity:Remove() end end end )[/CODE] Thanks in advance! Sincerely, Xavier Studios
[lua]CreateConVar("weapon_pickup_on_use", 1) hook.Add( "PlayerSpawn", "PickupTimeout", function( ply ) ply.PickupTimeout = CurTime() + 0.5 end ) hook.Add( "PlayerCanPickupWeapon", "NoPickup", function( ply, wep ) if (GetConVarNumber("weapon_pickup_on_use") == 0) then return; end if ( ( ply.PickupTimeout or 0 ) < CurTime() ) then return false end end ) hook.Add( "KeyPress", "PressUse", function( ply, key ) if (GetConVarNumber("weapon_pickup_on_use") == 0) then return; end if ( key == IN_USE ) then local tr = ply:GetEyeTrace() if ( ValidEntity( tr.Entity ) and tr.Entity:IsWeapon() and tr.Entity:GetPos():Distance( ply:GetShootPos() ) < 64 ) then ply.PickupTimeout = CurTime() + 0.5 ply:Give( tr.Entity:GetClass() ) tr.Entity:Remove() end end end )[/lua]
[QUOTE=Lexic;22459210]CreateConVar("weapon_pickup_on_use", 1) hook.Add( "PlayerSpawn", "PickupTimeout", function( ply ) ply.PickupTimeout = CurTime() + 0.5 end ) hook.Add( "PlayerCanPickupWeapon", "NoPickup", function( ply, wep ) if (GetConVarNumber("weapon_pickup_on_use") == 0) then return; end if ( ( ply.PickupTimeout or 0 ) < CurTime() ) then return false end end ) hook.Add( "KeyPress", "PressUse", function( ply, key ) if (GetConVarNumber("weapon_pickup_on_use") == 0) then return; end if ( key == IN_USE ) then local tr = ply:GetEyeTrace() if ( ValidEntity( tr.Entity ) and tr.Entity:IsWeapon() and tr.Entity:GetPos():Distance( ply:GetShootPos() ) < 64 ) then ply.PickupTimeout = CurTime() + 0.5 ply:Give( tr.Entity:GetClass() ) tr.Entity:Remove() end end end ) [/QUOTE] Thank you very much! You have just made my day!
Sorry, you need to Log In to post a reply to this thread.