Jump to content

Drop?


Bean666

Recommended Posts

why does the weapon drop only on the north side?if im facing south , the weapon drops behind of me how to fix that? i want it to drop in front of your player.

function drop(player,cmd,amount) 
     local x,y,z = getElementPosition(player) 
     local weapon = getPedWeapon(player) 
     local ammo = getPedTotalAmmo(player) 
     local amount = tonumber(amount) 
local x,y,z = getElementPosition(player) 
            local rot = getPedRotation(player) 
     if ammo >= amount then 
          takeWeapon(player,weapon,amount) 
          setElementID(createPickup(x,y+5,z,2,weapon,5000,amount),"WeaponPickUp") 
          outputChatBox("*You Dropped the Weapon successfuly",player,0,255,0,true) 
     else 
          outputChatBox("*You Don't Have that "..amount..".",player,255,0,0,true) 
     end 
end 
addCommandHandler("drop",drop) 
  

Edited by Guest
Link to comment
function drop(player,cmd,amount) 
     local x,y,z = getElementPosition(player) 
     local weapon = getPedWeapon(player) 
     local ammo = getPedTotalAmmo(player) 
     local amount = tonumber(amount) 
local x,y,z = getElementPosition(player) 
            local rot = getPedRotation(player) 
     if ammo >= amount then 
          takeWeapon(player,weapon,amount) 
          setElementID(createPickup(x+5,y,z,2,weapon,5000,amount),"WeaponPickUp") 
          outputChatBox("*You Dropped the Weapon successfuly",player,0,255,0,true) 
     else 
          outputChatBox("*You Don't Have that "..amount..".",player,255,0,0,true) 
     end 
end 
addCommandHandler("drop",drop) 

Link to comment

Use this function:

function getPositionInfrontOfElement(element, meters) 
    local posX, posY, posZ = getElementPosition(element) 
    local _, _, rotation = getElementRotation(element) 
    posX = posX - math.sin(math.rad(rotation)) * meters 
    posY = posY + math.cos(math.rad(rotation)) * meters 
    return posX, posY, posZ 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...