Hi, i thought long about it if its possible to drop weapons by pressing key, 4 collect them later.I would like to use it in my game.
min 1:40
Right now we can only replace weapons and the previous weapon just dissapear.The static gun script from amenmoses allows to take a weapon and release it, but u cant move while u holding the weapon.Is there a chance to modify the script so u can walking with the weapon and drop it if u need?He wrote that the script has 2 do with the commands Hide(e) and CollisionOff(e).So if just removing the part whos responsible to freeze the player we could haave a droping weapon script?
https://forum.game-guru.com/thread/220498?page=1#msg2611710
local U = require( "scriptbank\\utillib" )
local Q = require "scriptbank\\quatlib"
local rad = math.rad
local deg = math.deg
local guns = {}
local Ekey = false
function static_gun_init_name( e, name )
Include( "utillib.lua" )
Include( "quatlib.lua" )
end
local function wrapAng( ang ) -- Euler
while ang > 180 do
ang = ang - 180
end
while ang < 180 do
ang = ang + 180
end
return ang
end
local usingEnt = nil
function PU_GetEntityCarried()
return usingEnt
end
function static_gun_main(e)
local tg = guns[ e ]
if tg == nil then
local Ent = g_Entity[ e ]
guns[ e ] = { obj = Ent.obj,
state = 'idle' }
return
end
if tg.state == 'idle' then
if U.PlayerCloserThan( e, 80 ) then
Prompt("E to use gun" )
if g_KeyPressE == 1 then
if not Ekey then
Ekey = true
tg.state = 'init'
local x, y, z, xa, ya, za = GetObjectPosAng( tg.obj )
tg.x, tg.y, tg.z = x, y, z
tg.quat = Q.FromEuler( rad( xa ), rad( ya ), rad( za ) )
end
else
Ekey = false
end
end
elseif
tg.state == 'init' then
local xr, yr, zr = Q.ToEuler( tg.quat )
local xo, yo, zo = U.Rotate3D( 0, -5, -15, xr, yr, zr )
tg.px, tg.py, tg.pz = g_PlayerPosX, g_PlayerPosY, g_PlayerPosZ
SetFreezePosition( tg.x + xo, tg.y + yo, tg.z + zo )
SetFreezeAngle( deg( xr ), deg( yr ), deg( zr ) )
TransportToFreezePosition()
usingEnt = e
Hide( e )
CollisionOff( e )
if tg.ammo == nil then tg.ammo = 1000 end
AddPlayerWeapon( e )
for index = 1, 10 do
if GetPlayerWeaponID() == GetWeaponSlot( index ) then
SetWeaponAmmo( index, tg.ammo )
break
end
end
tg.state = 'used'
elseif
tg.state == 'used' then
if g_KeyPressE == 1 then
if not Ekey then
Ekey = true
tg.state = 'idle'
RemovePlayerWeapons( e )
SetFreezePosition( tg.px, tg.py, tg.pz )
TransportToFreezePositionOnly()
usingEnt = nil
Show( e )
CollisionOn( e )
return
end
else
Ekey = false
end
local pax, pay, paz = rad( wrapAng( g_PlayerAngX ) ),
rad( wrapAng( g_PlayerAngY ) ),
rad( wrapAng( g_PlayerAngZ ) )
local xo, yo, zo = U.Rotate3D( 0, -5, -15, pax, pay, 0 )
for index = 1, 10 do
if GetPlayerWeaponID() == GetWeaponSlot( index ) then
tg.ammo = GetWeaponAmmo( index )
break
end
end
SetFreezePosition( tg.x + xo, tg.y + yo, tg.z + zo )
TransportToFreezePositionOnly()
if g_MouseClick == 1 then
SetGamePlayerStateFiringMode(1)
else
SetGamePlayerStateFiringMode(0)
end
end
end
The author of this post has marked a post as an answer.
Go to answer