1. Post #1

    April 2011
    280 Posts
    i made a simple drop weapon script and when players walk over the weapon they automatically pick the weapon up. is there a way to block players from picking up the weapon by walking over it and instead they have to pick up the weapon by pressing e on the weapon.

    (User was banned for this post ("wrong section, undescriptive thread title" - postal))
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  2. Post #2
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    I found this :

    http://www.rabidtoaster.com/scripts/.../useWeapon.lua

    Looks like it should work.

    local function PlayerCanPickupWeapon( ply, weap )
    	if ( CurTime() <= ( ply.UseWeaponSpawn or 0 ) ) then return end
    	if ( !ply:KeyDown( IN_USE ) ) then return false end
    	local trace = util.QuickTrace( ply:GetShootPos(), ply:GetAimVector() * 8192, ply )
    	if ( !trace.Entity || !trace.Entity:IsValid() || trace.Entity != weap ) then
    		return false
    	end
    end
    hook.Add( "PlayerCanPickupWeapon", "UseWeapon", PlayerCanPickupWeapon )
    
    local function PlayerSpawn( ply )
    	ply.UseWeaponSpawn = CurTime()
    end
    hook.Add( "PlayerSpawn", "UseWeapon", PlayerSpawn )
    
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Informative Informative x 1 (list)

  3. Post #3

    April 2011
    280 Posts
    I found this :

    http://www.rabidtoaster.com/scripts/.../useWeapon.lua

    Looks like it should work.

    local function PlayerCanPickupWeapon( ply, weap )
    	if ( CurTime() <= ( ply.UseWeaponSpawn or 0 ) ) then return end
    	if ( !ply:KeyDown( IN_USE ) ) then return false end
    	local trace = util.QuickTrace( ply:GetShootPos(), ply:GetAimVector() * 8192, ply )
    	if ( !trace.Entity || !trace.Entity:IsValid() || trace.Entity != weap ) then
    		return false
    	end
    end
    hook.Add( "PlayerCanPickupWeapon", "UseWeapon", PlayerCanPickupWeapon )
    
    local function PlayerSpawn( ply )
    	ply.UseWeaponSpawn = CurTime()
    end
    hook.Add( "PlayerSpawn", "UseWeapon", PlayerSpawn )
    

    thank you brandonj4. just what i was looking for
    Reply With Quote Edit / Delete Windows 7 United States Show Events