Jump to content

[Help] SetElementVelocity (onClientRender)


2kristof2

Recommended Posts

Hi,

Here is my script:

NumToCount = 0.05 
CountSpeed = 100 
local b = 0.001 
  
marker = createMarker(5497.0727539063, -2612.5356445313, 7.6, "corona",6, 0, 0, 0, 0) 
function flying (player) 
   if source == marker then 
      if isPedInVehicle(player) then 
       vehicle=getPedOccupiedVehicle(player) 
       x,y,z = getElementVelocity(vehicle) 
       addEventHandler ( "onClientRender", getRootElement(), MyB) 
       setTimer (function() removeEventHandler ( "onClientRender", getRootElement(), MyB) end, 1100 , 1 ) 
      end 
   end 
end 
addEventHandler("onClientMarkerHit", getRootElement(), flying) 
  
function MyB ( ) 
setTimer (function() b = b + 0.0015 end, CountSpeed , NumToCount ) 
setElementVelocity(vehicle, x,y,b)  
end 
  

My question is how to change local b to the primary value (0.001), because when I hit the marker and hit it again after X seconds I'll get different velocity..

Thanks for help :)

regards,

2kristof2

Edited by Guest
Link to comment
  
CountSpeed = 100 
local b = 0.001 
local tick 
  
marker = createMarker(5497.0727539063, -2612.5356445313, 7.6, "corona",6, 0, 0, 0, 0) 
function flying (player) 
   if source == marker then 
      if isPedInVehicle(player) then 
       vehicle=getPedOccupiedVehicle(player) 
       b = 0.001 
       tick = getTickCount() 
       x,y,z = getElementVelocity(vehicle) 
       addEventHandler ( "onClientRender", getRootElement(), MyB) 
       setTimer (function() removeEventHandler ( "onClientRender", getRootElement(), MyB) end, 1100 , 1 ) 
      end 
   end 
end 
addEventHandler("onClientMarkerHit", getRootElement(), flying) 
  
function MyB ( ) 
if (getTickCount() - tick) >= CountSpeed then 
       b = b + 0.0015 
       tick = getTickCount() 
end 
setElementVelocity(vehicle, x,y,b)  
end 
  

Link to comment

I'm back, try this:

  
local CountSpeed = 100 
local b = 0.001 
local tick 
  
local marker = createMarker(5497.0727539063, -2612.5356445313, 7.6, "corona",6, 0, 0, 0, 0) 
  
function flying (player) 
   if source == marker then 
      if isPedInVehicle(player) then 
           vehicle=getPedOccupiedVehicle(player) 
           b = 0.001 
           tick = getTickCount() 
           x,y,z = getElementVelocity(vehicle) 
           addEventHandler ( "onClientRender", getRootElement(), MyB) 
           setTimer (function() removeEventHandler ( "onClientRender", getRootElement(), MyB) end, 1100 , 1 ) 
      end 
   end 
end 
addEventHandler("onClientMarkerHit", getRootElement(), flying) 
  
function MyB ( ) 
    if (getTickCount() - tick) >= CountSpeed then 
       b = b + 0.024 
       tick = getTickCount() 
    end 
    setElementVelocity(vehicle, x,y,b) 
end 

Link to comment

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...