local inColShape = { }
function bindStart ( )
for _, v in ipairs ( getElementsByType ( "player" ) ) do
bindKey ( v, "n", "down", pickupWeapon )
end
end
addEventHandler ( "onResourceStart", resourceRoot, bindStart )
function login ( )
bindKey ( source, "n", "down", pickupWeapon )
end
addEventHandler ( "onPlayerLogin", getRootElement(), login )
function pullItem ( item, ammo )
local x, y, z = getElementPosition ( source )
theWeapon = createObject ( 358, x, y, z - 1, 70, 0, 0 )
colshape = createColTube ( x, y, z, 1, 1 )
setElementData ( colshape, "Arma", 34 )
setElementData ( colshape, "Municion", ammo )
takeWeapon ( source, 34 )
addEventHandler ( "onColShapeHit", root, onColShape )
addEventHandler ( "onColShapeLeave", root, onColShape )
end
addEvent ( "onPlayerPullSniper", true )
addEventHandler ( "onPlayerPullSniper", getRootElement(), pullItem )
function onColShapeHit ( hitElement, matchDim )
if ( getElementType ( hitElement ) == "player" and matchDim ) then
if ( eventName == "onColShapeHit" ) then
inColShape [ hitElement ] = source
else
inColShape [ hitElement ] = nil
end
end
end
function pickupWeapon ( player )
local colshape = inColShape [ player ]
if isElement ( colshape ) then
if isElementWithinColShape ( player, colshape ) then
outputChatBox ( "/recoger", player, 0, 255, 255 )
giveWeapon ( player, getElementData ( colshape, "Arma" ), getElementData ( colshape, "Municion" ) )
destroyElement ( source )
destroyElement ( theWeapon )
inColShape [ player ] = nil
end
end
end