#RooTs Posted May 12, 2014 Author Share Posted May 12, 2014 the first time will, over the second not Fail function delay() test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 30000 ) end setTimer ( delay, 30000, 1 ) Link to comment
Vinctus Posted May 12, 2014 Share Posted May 12, 2014 https://wiki.multitheftauto.com/wiki/Scr ... troduction Link to comment
#RooTs Posted May 12, 2014 Author Share Posted May 12, 2014 https://wiki.multitheftauto.com/wiki/Scripting_Introduction not helped much , you not is developer ? Link to comment
Toffbrown Posted May 12, 2014 Share Posted May 12, 2014 function nostar() setTimer(function() star = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 60000 ) addEventHandler("onPickupHit",star, function(player) setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) destroyElement(star) end) end,60000,0) end addEventHandler("onResourceStart",resourceRoot,nostar) Tested this and this works Link to comment
#RooTs Posted May 12, 2014 Author Share Posted May 12, 2014 ||~ToffBrown~|| it fails with time if I caught the star more than 3 times it fails Link to comment
Toffbrown Posted May 13, 2014 Share Posted May 13, 2014 /debugscript 3 what errors does this return????? it seems to work for me Link to comment
justn Posted May 13, 2014 Share Posted May 13, 2014 function nostar() setTimer(function() star = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 60000 ) addEventHandler("onPickupHit",star, function(player) if not getPlayerWantedLevel(player) == 0 then setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) destroyElement(star) end end) end,60000,0) end addEventHandler("onResourceStart",resourceRoot,nostar) Edit:// Use this code below to clear up the debug errors function nostar() setTimer(function() star = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 60000 ) addEventHandler("onPickupHit",star, function(player) if isElement( star ) and getElementType(star) == "pickup" and getElementModel(star) == 1247 then if not getPlayerWantedLevel(player) == 0 then setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) destroyElement(star) end end end) end,60000,0) end addEventHandler("onResourceStart",resourceRoot,nostar) Link to comment
Toffbrown Posted May 13, 2014 Share Posted May 13, 2014 can you please not post blank spaces? is the script working or not? Link to comment
Mr_Moose Posted May 13, 2014 Share Posted May 13, 2014 All the given examples works but not if they are used wrongly, see the wiki documentation for the event, onPickupHit: This event is triggered when a player hits a pickup. It will work for players but not if you're inside a vehicle. I would suggest creating this as an object and add a colshape around it, colshapes trigger on any type of element. The handling with respawns and stuff like that needs to be done manually but that won't be any problem, I've already seen a few samples in here which applies this kind of handling on the pickup which is just waste of server performance. Link to comment
#RooTs Posted May 13, 2014 Author Share Posted May 13, 2014 knows how to solve it? my friend Link to comment
Mr_Moose Posted May 13, 2014 Share Posted May 13, 2014 Sure, it's easy. This solution is based on the sample by Twerky with a few modifications. It's not tested thought but it should work. Good luck. local star = nil local area = nil function nostar() setTimer(function() if isElement(star) then destroyElement(star) end if isElement(area) then destroyElement(area) end star = createObject (1247, 653.35773, -1769.18567, 13.57368 ) area = createColRectangle ( 648.35773, -1774.18567, 10, 10 ) addEventHandler ( "onColShapeHit", area, function( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then if getPlayerWantedLevel(hitElement) > 0 then setPlayerWantedLevel(hitElement,getPlayerWantedLevel(hitElement)-1) destroyElement(star) end elseif getElementType ( hitElement ) == "vehicle" then local player = getVehicleOccupant(hitElement) if player and getPlayerWantedLevel(player) > 0 then setPlayerWantedLevel(hitElement,getPlayerWantedLevel(player)-1) destroyElement(star) end end end end,60000,0) end addEventHandler("onResourceStart",resourceRoot,nostar) Link to comment
justn Posted May 15, 2014 Share Posted May 15, 2014 local star = nil local area = nil function nostar() setTimer(function() if isElement(star) then destroyElement(star) end if isElement(area) then destroyElement(area) end star = createObject (1247, 653.35773, -1769.18567, 13.57368 ) area = createColRectangle ( 648.35773, -1774.18567, 10, 10 ) addEventHandler ( "onColShapeHit", area, function( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then if getPlayerWantedLevel(hitElement) > 0 then setPlayerWantedLevel(hitElement,getPlayerWantedLevel(hitElement)-1) destroyElement(star) end elseif getElementType ( hitElement ) == "vehicle" then local player = getVehicleOccupant(hitElement) if player and getPlayerWantedLevel(player) > 0 then setPlayerWantedLevel(hitElement,getPlayerWantedLevel(player)-1) destroyElement(star) end end end,60000,0) end) end addEventHandler("onResourceStart",resourceRoot,nostar) Link to comment
Mr_Moose Posted May 15, 2014 Share Posted May 15, 2014 Yeah I missed that ')' om line 27 I see. Those errors can't be taken literally obviously. local star = nil local area = nil function nostar() setTimer(function() if isElement(star) then destroyElement(star) end if isElement(area) then destroyElement(area) end star = createObject (1247, 653.35773, -1769.18567, 13.57368 ) area = createColRectangle ( 648.35773, -1774.18567, 10, 10 ) addEventHandler ( "onColShapeHit", area, function( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then if getPlayerWantedLevel(hitElement) > 0 then setPlayerWantedLevel(hitElement,getPlayerWantedLevel(hitElement)-1) destroyElement(star) end elseif getElementType ( hitElement ) == "vehicle" then local player = getVehicleOccupant(hitElement) if player and getPlayerWantedLevel(player) > 0 then setPlayerWantedLevel(hitElement,getPlayerWantedLevel(player)-1) destroyElement(star) end end end) end,60000,0) end addEventHandler("onResourceStart",resourceRoot,nostar) Link to comment
#RooTs Posted May 15, 2014 Author Share Posted May 15, 2014 star = createObject (1247, 653.35773, -1769.18567, 13.57368 ) area = createColRectangle ( 648.35773, -1774.18567, 10, 10 ) 2 errors can not be the object has to be PICKUP ( OBJECT ) FAIL createPickup (1548, -1681, 13, 3, 1239, 60000 ) Link to comment
Spajk Posted May 16, 2014 Share Posted May 16, 2014 Pickup is not destroyed when Esto inside the vehicle As far as I know, pickups don't react with vehicles on MTA. Link to comment
Mr_Moose Posted May 16, 2014 Share Posted May 16, 2014 That's true, pickups doesn't react on vehicles, that's why I suggested an object with colshape, try the latest code sequence and remember to go away a bit first and then hit the object because the colshape in my example is pretty big. Link to comment
#RooTs Posted May 18, 2014 Author Share Posted May 18, 2014 new version MTA (1.4) is not possible? you can test ? Link to comment
Mr_Moose Posted May 18, 2014 Share Posted May 18, 2014 Maybe, were currently moving all AC servers to new hardware but I might be able to test it in a few hours. Still don't think it's possible for pick ups to trigger when they getting hit by a vehicle. It doesn't work in single players and will probably not work in MTA either. Link to comment
tosfera Posted May 22, 2014 Share Posted May 22, 2014 Maybe, were currently moving all AC servers to new hardware but I might be able to test it in a few hours. Still don't think it's possible for pick ups to trigger when they getting hit by a vehicle. It doesn't work in single players and will probably not work in MTA either. 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. Link to comment
#RooTs Posted May 22, 2014 Author Share Posted May 22, 2014 More I can not do this, can you help me and show an example? 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