Jump to content

I have problems with the pickups


Recommended Posts

Posted

When i drop my weapon then create a pickup which is works fine but after someone picked up then some sec later the pickup comes back again can be some way destroy the pickup after the player picked up and dont come back again?

There is my script

addCommandHandler("drop",function(player)

local x,y,z = getElementPosition(player)

local weapon,ammo = getPedWeapon(player),getPedTotalAmmo(player)

takeWeapon(player,weapon,ammo)

local pickup = createPickup(x+4,y,z+1,2,weapon,5000,ammo)

addEventHandler("onPickupHit", pickup, destroyElement) -- destroy the pickup on hit

end)

Posted
addCommandHandler("drop", 
function(player) 
    local x,y,z = getElementPosition(player) 
    local weapon,ammo = getPedWeapon(player),getPedTotalAmmo(player) 
    takeWeapon(player,weapon,ammo) 
    pickup = createPickup(x+4,y,z+1,2,weapon,5000,ammo) 
end) 
  
function destroyPickup(thePlayer) 
    destroyElement(pickup) 
    outputChatBox("You picked up a weapon!", thePlayer, 255, 0, 0) 
end 
addEventHandler("onPickupHit", pickup, destroyPickup) 

"destroyElement is a function where you need to add the element that you want to destroy in the brackets "()"

Posted

the pickup was still coming back over and over again :( any other idea to make weapon pickup or just a drop which i was pick up or click it then the give me the weapon then doesn come back the pickup ?

Posted
addCommandHandler("drop", 
function(player) 
    local x, y, z = getElementPosition(player) 
    local weapon, ammo = getPedWeapon(player), getPedTotalAmmo(player) 
    takeWeapon(player, weapon, ammo) 
    local pickup = createPickup(x+4, y, z+1, 2, weapon, 5000, ammo) 
    addEventHandler("onPickupHit", pickup, destroyPickup) 
end) 
  
function destroyPickup(thePlayer) 
    destroyElement(source) 
    outputChatBox("You picked up a weapon!", thePlayer, 255, 0, 0) 
end 

Posted

not works again :( it destroy the pickup but doesnt give me a weapon :( or can be maked by like in the dayz version take down some item or something and i click it than i get the weapon or something like that

Posted
not works again :( it destroy the pickup but doesnt give me a weapon :( or can be maked by like in the dayz version take down some item or something and i click it than i get the weapon or something like that

Use giveWeapon() when the player Hit the pickup.

giveWeapon() 

Posted
addCommandHandler("drop", 
function(player) 
    local x, y, z = getElementPosition(player) 
    local weapon, ammo = getPedWeapon(player), getPedTotalAmmo(player) 
    if weapon > 0 then 
        takeWeapon(player, weapon, ammo) 
        pickup = createPickup(x+4, y, z+1, 2, weapon, -1, ammo) 
        addEventHandler("onPickupHit", pickup, destroyPickup) 
    end 
end) 
  
function destroyPickup(thePlayer) 
    setTimer(destroyElement, 50, 1, source) 
    outputChatBox("You picked up a weapon!", thePlayer, 255, 0, 0) 
end 

Posted

now works fine thanks man a lot :D

but when i drop a katana then the script drop it and create a pickup but stay on my hand as well :( so i think i need to make this some different way any idea ? make it like setelementData each item then ad the item ids like in the DayZ server ? or which way is the easyest ?

Posted
addCommandHandler("drop", 
function(player) 
    local x, y, z = getElementPosition(player) 
    local weapon, ammo = getPedWeapon(player), getPedTotalAmmo(player) 
    if weapon > 0 then 
        takeWeapon(player, weapon) 
        local pickup = createPickup(x+4, y, z+1, 2, weapon, -1, ammo) 
        addEventHandler("onPickupHit", pickup, destroyPickup) 
    end 
end) 
  
function destroyPickup(thePlayer) 
    setTimer(destroyElement, 50, 1, source) 
    outputChatBox("You picked up a weapon!", thePlayer, 255, 0, 0) 
end 

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...