Lordkrypton Posted August 3, 2015 Share Posted August 3, 2015 Hi, My script works, but i get some warning and error. I wanted to know how stop the function for avoid get this error, i try the "return" but it doesn't work. myblip1 = createBlip ( 1177,-1323,329.48090,22) -- LOS SANTOS marker1 = createMarker( 1177,-1323,13,"cylinder",1.5,255,0,0,225,getRootElement()) -- LOS SANTOS setBlipVisibleDistance( myblip1, 1500 ) myblip2 = createBlip ( -2651.3,626.7,329.48090,22) -- SF marker2 = createMarker( -2651.3,626.7,13.5,"cylinder",1.5,255,0,0,225,getRootElement()) --SF setBlipVisibleDistance( myblip2, 1500 ) myblip3 = createBlip ( 1608,1821,329.48090,22) -- LV marker3 = createMarker( 1608,1821,9.5,"cylinder",1.5,255,0,0,225,getRootElement()) -- LV setBlipVisibleDistance( myblip3, 1500 ) function health ( hitElement, matchingDimension ) if isPedInVehicle ( hitElement ) then outputChatBox ("You are in a vehicle", hitElement, 0 ,255, 0 ) else local ph = getElementHealth(hitElement) local ap = getPedArmor(hitElement) if ap < 100 then setPedArmor ( hitElement, 100 ) takePlayerMoney( hitElement, 250 ) outputChatBox ("You have set your armor to 100 for 250$.", hitElement, 0 ,255, 0 ) end if ph < 100 then outputChatBox ( "You have set your health to 100 for 250$.", hitElement, 0, 255, 0 ) setElementHealth ( hitElement, 100 ) setPedArmor ( hitElement, 100 ) takePlayerMoney( hitElement, 250) end end end addEventHandler( "onMarkerHit", marker1, health ) function health ( hitElement, matchingDimension ) if isPedInVehicle ( hitElement ) then outputChatBox ("You are in a vehicle", hitElement, 0 ,255, 0 ) else local ph = getElementHealth(hitElement) local ap = getPedArmor(hitElement) if ap < 100 then setPedArmor ( hitElement, 100 ) takePlayerMoney( hitElement, 250 ) outputChatBox ("You have set your armor to 100 for 250$.", hitElement, 0 ,255, 0 ) end if ph < 100 then outputChatBox ( "You have set your health to 100 for 250$.", hitElement, 0, 255, 0 ) setElementHealth ( hitElement, 100 ) setPedArmor ( hitElement, 100 ) takePlayerMoney( hitElement, 250) end end end addEventHandler( "onMarkerHit", marker2, health ) function health ( hitElement, matchingDimension ) if isPedInVehicle ( hitElement ) then outputChatBox ("You are in a vehicle", hitElement, 0 ,255, 0 ) else local ph = getElementHealth(hitElement) local ap = getPedArmor(hitElement) if ap < 100 then setPedArmor ( hitElement, 100 ) takePlayerMoney( hitElement, 250 ) outputChatBox ("You have set your armor to 100 for 250$.", hitElement, 0 ,255, 0 ) end if ph < 100 then outputChatBox ( "You have set your health to 100 for 250$.", hitElement, 0, 255, 0 ) setElementHealth ( hitElement, 100 ) setPedArmor ( hitElement, 100 ) takePlayerMoney( hitElement, 250) end end end addEventHandler( "onMarkerHit", marker3, health ) The error : When someone go on the marker with a vehicle, it's said : - Warning at line 55 Bad argument @ IsPedinVehicle expected ped at argument 1, got vehicle - Warning at line 59 Bad argument @ GetPedArmor expected ped at argument 1, got vehicle - Error at line 60 attempt to compare bolean with number. By the way if you can say me how to make different marker use the same function Thank you Link to comment
KariiiM Posted August 3, 2015 Share Posted August 3, 2015 About markers you have to use Table about errors/warnings try to change hitElement by source Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 Parameter "source" in onMarkerHit event returns marker, not player. The hitElement argument is correct, do not change it. This should return no warnings & I cleaned up code a bit for you. local markers = { createMarker(1177, -1323, 13, "cylinder", 1.5, 255, 0, 0, 225, getRootElement()), createMarker(-2651.3, 626.7, 13.5, "cylinder", 1.5, 255, 0, 0, 225, getRootElement()), createMarker(1608, 1821, 9.5, "cylinder", 1.5, 255, 0, 0, 225, getRootElement()) } myblip1 = createBlip(1177, -1323, 329.48090, 22) -- LOS SANTOS setBlipVisibleDistance(myblip1, 1500) myblip2 = createBlip(-2651.3, 626.7, 329.48090, 22) -- SF setBlipVisibleDistance(myblip2, 1500 ) myblip3 = createBlip(1608, 1821, 329.48090, 22) -- LV setBlipVisibleDistance(myblip3, 1500) function health(hitElement, matchingDimension) for i=1, #markers do if source == markers[i] then if getElementType(hitElement) == "player" then if isPedInVehicle(hitElement) then outputChatBox("You are in a vehicle", hitElement, 0 ,255, 0) else local ph = getElementHealth(hitElement) local ap = getPedArmor(hitElement) if ap < 100 then setPedArmor(hitElement, 100) takePlayerMoney(hitElement, 250) outputChatBox("You have set your armor to 100 for 250$.", hitElement, 0 ,255, 0) end if ph < 100 then outputChatBox("You have set your health to 100 for 250$.", hitElement, 0, 255, 0) setElementHealth(hitElement, 100) setPedArmor(hitElement, 100) takePlayerMoney(hitElement, 250) end end end break end end end addEventHandler("onMarkerHit", root, health) 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