-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Collects Weapon local U = require "scriptbank\\utillib" local currWeap = nil local lookingAt = nil local nextCheck = 0 local contrEnt = nil local weapName = {} function weapon_onlyone2_init_name( e, name ) weapName[ e ] = name end function weapon_onlyone2_main( e ) local timeNow = g_Time if contrEnt == nil or e > contrEnt then contrEnt = e end if timeNow < nextCheck then return elseif contrEnt == e then nextCheck = timeNow + 50 -- check every 1/20th of a second end if g_PlayerGunCount == 0 then if U.PlayerLookingNear( e, 50, 20 ) and GetEntityVisibility( e ) == 1 and ( lookingAt == nil or lookingAt == e ) then PromptLocal( e, "Press E to pick up " .. weapName[ e ] ) lookingAt = e if g_KeyPressE == 1 then PromptLocal( e, "" ) currWeap = e AddPlayerWeapon( e ) Hide( e ) lookingAt = nil nextCheck = timeNow + 500 -- delay to allow message to disappear end elseif lookingAt == e then lookingAt = nil PromptLocal( e, "" ) end return end if U.PlayerLookingNear( e, 50, 20 ) and GetEntityVisibility( e ) == 1 and ( lookingAt == nil or lookingAt == e ) then PromptLocal( e, "Press E to swap " .. g_PlayerGunName .. " with " .. weapName[ e ] ) lookingAt = e if g_KeyPressE == 1 then PromptLocal( e, "" ) ReplacePlayerWeapon( e ) Show( currWeap ) currWeap = e Hide( e ) lookingAt = nil nextCheck = timeNow + 500 -- delay to allow message to disappear end elseif lookingAt == e then lookingAt = nil PromptLocal( e, "" ) end end