Sasu Posted July 26, 2013 Posted July 26, 2013 How can I destroy a pickup? Because I used destroyElement but then respawn again.
codeluaeveryday Posted July 26, 2013 Posted July 26, 2013 Keep in mind race pickups use col shapes and other crap in the middle of it, try deleteing the colshape, or getElementsByType('race-pickup')
Sasu Posted July 26, 2013 Author Posted July 26, 2013 Keep in mind race pickups use col shapes and other crap in the middle of it, try deleteing the colshape, or getElementsByType('race-pickup') I am not using race pickups. I am using weapons pickups. Anybody knows how to destroy weapon pickups?
Meshare Posted July 30, 2013 Posted July 30, 2013 test : local respawn = 2000; local pick = createPickup(x,y,z,type,id,respawn); setTimer(function(); respawn = nil; destroyElement(pick); end,6000,1); destroy after 6 scn
xXMADEXx Posted July 30, 2013 Posted July 30, 2013 test : local respawn = 2000; local pick = createPickup(x,y,z,type,id,respawn); setTimer(function(); respawn = nil; destroyElement(pick); end,6000,1); destroy after 6 scn That wouldn't work.. local respawn = 2000 local pick = createPickup(x,y,z,type,id,respawn) setTimer(function() if ( isElement ( pick ) ) then destroyElement(pick) end end,6000,1)
Sasu Posted July 30, 2013 Author Posted July 30, 2013 I have this script: local pickups = {} addEvent("onPlayerTrash", true) addEventHandler("onPlayerTrash", root, function(wName, wAmmo) local x,y,z = getElementPosition(source) local pickup = createPickup(x, y, z, 2, getWeaponIDFromName(wName), 1000, tonumber(wAmmo)) table.insert(pickups, pickup) if pickup then addEventHandler("onPickupHit", pickup, isRecentlyPickup) outputChatBox("*Has tirado correctamente el arma "..wName, source, 0, 255, 0) takeWeapon(source, getWeaponIDFromName(wName), tonumber(wAmmo)) else outputChatBox("*Ha ocurrido un error al tirar el arma. Reporta este bug en /report.", source, 255, 0, 0) end end ) function isRecentlyPickup() addEventHandler("onPickupHit", source, destroy) removeEventHandler("onPickupHit", source, isRecentlyPickup) cancelEvent() end function destroy() destroyElement(pickups[source]) pickups[source] = nil end But It's still respawn.
Meshare Posted July 30, 2013 Posted July 30, 2013 I have this script: local pickups = {} addEvent("onPlayerTrash", true) addEventHandler("onPlayerTrash", root, function(wName, wAmmo) local x,y,z = getElementPosition(source) local pickup = createPickup(x, y, z, 2, getWeaponIDFromName(wName), 1000, tonumber(wAmmo)) table.insert(pickups, pickup) if pickup then addEventHandler("onPickupHit", pickup, isRecentlyPickup) outputChatBox("*Has tirado correctamente el arma "..wName, source, 0, 255, 0) takeWeapon(source, getWeaponIDFromName(wName), tonumber(wAmmo)) else outputChatBox("*Ha ocurrido un error al tirar el arma. Reporta este bug en /report.", source, 255, 0, 0) end end ) function isRecentlyPickup() addEventHandler("onPickupHit", source, destroy) removeEventHandler("onPickupHit", source, isRecentlyPickup) cancelEvent() end function destroy() destroyElement(pickups[source]) pickups[source] = nil end But It's still respawn. this is fuill code ?
Sasu Posted July 30, 2013 Author Posted July 30, 2013 I have this script: local pickups = {} addEvent("onPlayerTrash", true) addEventHandler("onPlayerTrash", root, function(wName, wAmmo) local x,y,z = getElementPosition(source) local pickup = createPickup(x, y, z, 2, getWeaponIDFromName(wName), 1000, tonumber(wAmmo)) table.insert(pickups, pickup) if pickup then addEventHandler("onPickupHit", pickup, isRecentlyPickup) outputChatBox("*Has tirado correctamente el arma "..wName, source, 0, 255, 0) takeWeapon(source, getWeaponIDFromName(wName), tonumber(wAmmo)) else outputChatBox("*Ha ocurrido un error al tirar el arma. Reporta este bug en /report.", source, 255, 0, 0) end end ) function isRecentlyPickup() addEventHandler("onPickupHit", source, destroy) removeEventHandler("onPickupHit", source, isRecentlyPickup) cancelEvent() end function destroy() destroyElement(pickups[source]) pickups[source] = nil end But It's still respawn. this is fuill code ? Of course no. But the full code it isn't needed.
Meshare Posted July 30, 2013 Posted July 30, 2013 try : local pickups = {} addEvent("onPlayerTrash", true) addEventHandler("onPlayerTrash", root, function(wName, wAmmo) local x,y,z = getElementPosition(source) pickups[source] = createPickup(x, y, z, 2, getWeaponIDFromName(wName), 1000, tonumber(wAmmo)) if pickups[source] then addEventHandler("onPickupHit",root,onHitPickup) outputChatBox("*Has tirado correctamente el arma "..wName, source, 0, 255, 0) takeWeapon(source, getWeaponIDFromName(wName), tonumber(wAmmo)) else outputChatBox("*Ha ocurrido un error al tirar el arma. Reporta este bug en /report.", source, 255, 0, 0) end end ) function onHitPickup(player) if ( source == pickups[player] ) then destroyElement(pickups[player]) pickups[player] = nil removeEventHandler("onPickupHit",root,onHitPickup) end end
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