Jump to content

Markers


Recommended Posts

Posted (edited)

how to make when you hit the blue marker your gravity will be normal (0.008)

and when you hit the red marker your gravity will be half as normal (0.004)

createMarker ( 4000, -460, 25, "corona", 3, 0, 0, 255, 255 )
createMarker ( 4040, -460, 25, "corona", 3, 255, 0, 0, 255 )
 
function MarkerHit( thePed )
setPedGravity ( thePed, 0.008 )
end
addEventHandler( "onMarkerHit", getRootElement(), MarkerHit )
 
function MarkerHit( thePed )
setPedGravity ( thePed, 0.004 )
end
addEventHandler( "onMarkerHit", getRootElement(), MarkerHit )

Edited by Guest
Posted

use [lua] tags not

you have 2 functions with same name!!

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
local blueMarker = createMarker ( 4000, -460, 25, "corona", 3, 0, 0, 255, 255 )
local redMarker = createMarker ( 4040, -460, 25, "corona", 3, 255, 0, 0, 255 )
function onHit(hitElement)
if (source == blueMarker) then
setPedGravity(hitElement,0.008)
end
if (source == redMarker) then
setPedGravity(hitElement,0.004)
end
end
addEventHandler("onMarkerHit",getRootElement(),onHit)

Retired

Posted

The best way (less cpu consume):

bluemarker = createMarker ( 4000, -460, 25, "corona", 3, 0, 0, 255, 255 ) -- blue
redmarker = createMarker ( 4040, -460, 25, "corona", 3, 255, 0, 0, 255 ) -- red
 
function MarkerHit(theElement)
if (getElementType(theElement)=='ped') then
if (source==bluemarker) then
setPedGravity ( theElement, 0.008 )
elseif (source==redmarker) then
setPedGravity ( theElement, 0.004 )
end
end
end
addEventHandler( "onMarkerHit", bluemarker, MarkerHit )
addEventHandler( "onMarkerHit", redmarker, MarkerHit )

this will add handler only for that two markers, will help with errors/warnings in console when car or any other element than ped hit the marker..

you can also check if the element type is vehicle, and then get vehicle driver and others occupants,and set gravity for each of them

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

I'd make redmarker and bluemarker have their own functions - it's simpler.

bluemarker = createMarker ( 4000, -460, 25, "corona", 3, 0, 0, 255, 255 ) -- blue
redmarker = createMarker ( 4040, -460, 25, "corona", 3, 255, 0, 0, 255 ) -- red
 
function setElementGravity(theElement, gravity)
if (getElementType(theElement)=='ped') then
setPedGravity ( theElement, gravity )
end
end
 
function BlueMarkerHit(theElement)
   setElementGravity ( theElement, 0.008 )
end
 
function RedMarkerHit(theElement)
   setElementGravity ( theElement, 0.004 )
end
 
addEventHandler( "onMarkerHit", bluemarker, BlueMarkerHit )
addEventHandler( "onMarkerHit", redmarker, RedMarkerHit )

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...