2013martin1212 Posted June 1, 2015 Share Posted June 1, 2015 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) Link to comment
..:D&G:.. Posted June 1, 2015 Share Posted June 1, 2015 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 "()" Link to comment
2013martin1212 Posted June 2, 2015 Author Share Posted June 2, 2015 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 ? Link to comment
TAPL Posted June 2, 2015 Share Posted June 2, 2015 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 Link to comment
2013martin1212 Posted June 2, 2015 Author Share Posted June 2, 2015 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 Link to comment
Walid Posted June 2, 2015 Share Posted June 2, 2015 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() Link to comment
TAPL Posted June 2, 2015 Share Posted June 2, 2015 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 Link to comment
2013martin1212 Posted June 2, 2015 Author Share Posted June 2, 2015 now works fine thanks man a lot 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 ? Link to comment
TAPL Posted June 2, 2015 Share Posted June 2, 2015 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now