Mr_Moose Posted May 23, 2014 Share Posted May 23, 2014 It is possible, create a colshape around the pickup, make it trigger whenever an elements hits it and get the vehiclecontroller to remove the wanted level from. That's also a way to do it, the most simple solutions are always easy to forget about More I can not do this, can you help me and show an example? Look at my earlier example and replace the object with a pickup, there is a colshape and an event handler in that one already. Link to comment
#RooTs Posted May 24, 2014 Author Share Posted May 24, 2014 Yes, nothing is working, can someone help me of really? Link to comment
justn Posted May 25, 2014 Share Posted May 25, 2014 All he's saying is to replace this ( from his earlier code ) star = createObject (1247, 653.35773, -1769.18567, 13.57368 ) to star = createPickup(653.35773, -1769.18567, 13.57368, 3, 1239, 60000) -- I got some of this from what you posted earlier Link to comment
</Mr.Tn6eL> Posted May 26, 2014 Share Posted May 26, 2014 Server Side local pickup = createPickup(x, y, z, 3, 1247, respawnTime) -- Position and respawnTime addEventHandler("onPickupHit", pickup, function(Hit) setPlayerWantedLevel(Hit, getPlayerWantedLevel(Hit)-1) end) Link to comment
#RooTs Posted May 26, 2014 Author Share Posted May 26, 2014 FAIL IN VEHICLE MY FRIEND, NO DESTROY IN VEHICLE Link to comment
justn Posted May 26, 2014 Share Posted May 26, 2014 Just try this and tell me if the pickup destroys now function onHit() setTimer(function() test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) addEventHandler("onPickupHit",test, function(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) destroyElement(test) else setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) destroyElement(test) end end,60000,0) end) end addEventHandler("onResourceStart",resourceRoot, onHit) Link to comment
Chronic Posted May 26, 2014 Share Posted May 26, 2014 Just try this and tell me if the pickup destroys now function onHit() setTimer(function() test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) addEventHandler("onPickupHit",test, function(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) destroyElement(test) else setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) destroyElement(test) end end,60000,0) end) end addEventHandler("onResourceStart",resourceRoot, onHit) Don't destroy test, if you do it won't spawn again. Use usePickup instead. function onHit() test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) addEventHandler("onPickupHit",test, function(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) usePickup ( test, player ) setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) else setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) usePickup ( test, player ) end end) end addEventHandler("onResourceStart",resourceRoot, onHit) Also, what is the point of having the timer Link to comment
justn Posted May 26, 2014 Share Posted May 26, 2014 Also, what is the point of having the timer If you read my code, i think you would see, what the timer is for Link to comment
Chronic Posted May 26, 2014 Share Posted May 26, 2014 Ohhh to make a new pickup every 60 seconds, so that's why you used destroyElement. It all makes sense now Link to comment
#RooTs Posted May 27, 2014 Author Share Posted May 27, 2014 (Chronic) worked is possible create one table for elsewhere coordinates EXAMPLE: local Positions = { { 653.35773, -1769.18567, 13.57368 }, { 664.65936, -1755.74182, 13.45477 }, } for index = 1, #Positions do local test = createPickup ( Positions [ index ] [ 1 ], Positions [ index ] [ 2 ], Positions [ index ] [ 3 ], 3, 1239, 10000 ) end ( I tested it, and it only worked in one pickup ) ADD: function onHit() test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) addEventHandler("onPickupHit",test, function(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) usePickup ( test, player ) setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) else setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) usePickup ( test, player ) end end) end addEventHandler("onResourceStart",resourceRoot, onHit) Link to comment
Chronic Posted May 31, 2014 Share Posted May 31, 2014 local Positions = { { 653.35773, -1769.18567, 13.57368 }, { 664.65936, -1755.74182, 13.45477 }, } local pickups = { pickup = { } } function onHit ( ) for _, v in ipairs ( Positions ) do local x, y, z = unpack ( v ) local pickups.pickup[v] = createPickup ( x, y, z, 3, 1247, 10000 ) end addEventHandler ( "onPickupHit", test, function ( player ) if isPedInVehicle ( player ) then local vehicle = getPedOccupiedVehicle ( player ) usePickup ( test, player ) setPlayerWantedLevel ( getVehicleController ( vehicle ), getPlayerWantedLevel ( getVehicleController ( vehicle ) )-1 ) else setPlayerWantedLevel ( player, getPlayerWantedLevel ( player )-1 ) usePickup ( test, player ) end end) end addEventHandler ( "onResourceStart", resourceRoot, onHit ) Link to comment
Karuzo Posted May 31, 2014 Share Posted May 31, 2014 local Positions = { { 653.35773, -1769.18567, 13.57368 }, { 664.65936, -1755.74182, 13.45477 }, } local pickups = { pickup = { } } function onHit ( ) for _, v in ipairs ( Positions ) do local x, y, z = unpack ( v ) local pickups.pickup[v] = createPickup ( x, y, z, 3, 1247, 10000 ) end addEventHandler ( "onPickupHit", test, function ( player ) if isPedInVehicle ( player ) then local vehicle = getPedOccupiedVehicle ( player ) usePickup ( test, player ) setPlayerWantedLevel ( getVehicleController ( vehicle ), getPlayerWantedLevel ( getVehicleController ( vehicle ) )-1 ) else setPlayerWantedLevel ( player, getPlayerWantedLevel ( player )-1 ) usePickup ( test, player ) end end) end addEventHandler ( "onResourceStart", resourceRoot, onHit ) Where is test defined? Link to comment
Chronic Posted May 31, 2014 Share Posted May 31, 2014 Ah, my bad I was using his other script and forgot to change test to pickups.pickup[v] Thanks for letting me know local Positions = { { 653.35773, -1769.18567, 13.57368 }, { 664.65936, -1755.74182, 13.45477 }, } local pickups = { pickup = { } } function onHit ( ) for _, v in ipairs ( Positions ) do local x, y, z = unpack ( v ) pickups.pickup[v] = createPickup ( x, y, z, 3, 1247, 10000 ) addEventHandler ( "onPickupHit", pickups.pickup[v], function ( player ) if isPedInVehicle ( player ) then local vehicle = getPedOccupiedVehicle ( player ) usePickup ( pickups.pickup[v], player ) setPlayerWantedLevel ( getVehicleController ( vehicle ), getPlayerWantedLevel ( getVehicleController ( vehicle ) )-1 ) else setPlayerWantedLevel ( player, getPlayerWantedLevel ( player )-1 ) usePickup ( pickups.pickup[v], player ) end end) end end addEventHandler ( "onResourceStart", resourceRoot, onHit ) 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