Jump to content

Need help about gravity


RaceXtreme

Recommended Posts

Hey gice, im new here in the forum. Who dont know me im RaceXtreme and i play MTA about 3.5 years.

So...

Im trying to do a server-side script that change the gravity of the car when the player hits the marker.

When this happend the player will run on the wall of the build.

I did a code here and i want to know if it is correct:

  
local Marker = createMarker ( 724.4444, -3318.2453, 322.6392, "cylinder", 5, 255, 140, 0, 255 ) 
  
function MarkerHit ( player ) 
         local veh = getPedOccupiedVehicle(player) 
         if (veh) then 
         setVehicleGravity ( veh, 734.1802, -3325.3698, 339.8891 )    
         end 
end 
  
addEventHandler( "onMarkerHit", Marker, MarkerHit ) 
  

Thx gice :)

Link to comment

even heard about Debugging ?

This throws error for sure, and you just can't miss it!

setVehicleGravity is client-side

server side setVehicleGravity:

  
-- server side code 
function setVehicleGravity(veh, x,y,z) 
  if (isElement(veh) and getElementType(veh)=='vehicle' and x~=nil and y~=nil and z~=nil) then 
    triggerClientEvent(getRootElement(), "setVehGrav", veh, x, y, z) 
    return true 
  else 
    return false 
  end 
end 
  
-- client side code: 
addEvent("setVehGrav", true) 
addEventHandler("setVehGrav", getRootElement(), function(x,y,z) 
  setVehicleGravity(source,x,y,z) 
end 
) 
  

after you put this code, you can use setVehicleGravity server side

Link to comment

Thats anything wrong on my code? ( Only to be sure :D )

And thx :)

Another thing...

I tryied to run this code on race resource but it didnt work, bacause when i hit the marker dont happend nothing.

On the server side works but on client i tryied the same code but with some changes.

The marker creats but when i hit it dont happend anything.

  
function markerHit ( thePlayer ) 
  if (thePlayer==getLocalPlayer()) then 
   outputChatBox ( "Hello?" ) -- This happend 
   local veh = getPedOccupiedVehicle( player ) 
   setVehicleGravity ( veh, 734.1802, -3325.3698, 339.8891 ) -- But this no. And it is on client-side. 
  end 
end 
addEventHandler( "onClientResourceStart", resourceRoot, startclient ) 
  

I want that the car runs on the wall but it dosent works. :/

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