Sasu Posted July 26, 2013 Share Posted July 26, 2013 How can I destroy a pickup? Because I used destroyElement but then respawn again. Link to comment
codeluaeveryday Posted July 26, 2013 Share 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') Link to comment
Sasu Posted July 26, 2013 Author Share 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? Link to comment
Meshare Posted July 30, 2013 Share 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 Link to comment
xXMADEXx Posted July 30, 2013 Share 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) Link to comment
Sasu Posted July 30, 2013 Author Share 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. Link to comment
Meshare Posted July 30, 2013 Share 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 ? Link to comment
Sasu Posted July 30, 2013 Author Share 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. Link to comment
Meshare Posted July 30, 2013 Share 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 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