Jump to content

Need help about gravity


RaceXtreme

Recommended Posts

Posted

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 :)

RaceXtreme

Posted

setVehicleGravity dosn't exist, check wiki again for gravity functions.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Can you help mee plzzz. :)

Hmmm, i think this function its only client side and that would mean that won't work at server side script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

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

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

RaceXtreme

Posted
734.1802, -3325.3698, 339.8891
--- wtf is this? these values probably will crash clients. check wiki page for more info

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)!

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