Jump to content

setting gravity


ramrod

Recommended Posts

Posted

AHHH so its not in the meta like i thought, will try tht ow :D

thnx

ahh ok, so i did that...but it doesnt work.

what is the problem here

function grav ( sourcePlayer, command, level )

setGravity ( 0.0035(level) )

end

addCommandHandler ( "setgravity", grav )

Posted

If your code is server side change the one line to:

  
setPlayerGravity(sourcePlayer,tonumber(level)) 
  

That's per-player. For the server (i.e. everyone):

  
setGravity(tonumber(level)) 
  

Posted

ohhh i edited that cos thats what i thought u had t odo LOL. my bad, thanks, ill figure something out :D

ok, so i tried to fiddle around, and it still doesnt work, where abouts do i put the gravity number i want it to be? where would i bet the 0.0035

Posted

Just do this if you only want a specific level:

  
setGravity(0.0035) 
  

The "level" parameter into your function is then redundant and can be removed.

Posted

thanks for the help, do appreciate it.

i'm almost there :D

so i now have this

function grav ( sourcePlayer, command )

setGravity ( 0.0035 )

end

addCommandHandler ( "setgravity" , grav )

and ...it still doesnt work LOL. :(

Posted

Sorry I mis-read the doc for setGravity() - it doesn't affect players/vehicles. You'd need to do something like:

  
function setGravityForPlayer(player) 
    setPlayerGravity(player,0.0035) 
end 
  
addCommandHandler("setgravity", 
    function(player,cmd) 
        for _,player in pairs(getElementsByType("player")) do 
            setGravityForPlayer(player) 
        end 
    end 
) 
  
addEventHandler('onPlayerSpawn',getRootElement(), 
    function() 
        setTimer(setGravityForPlayer,1000,1,source) 
    end 
) 
  

The command now loops though the players and sets their gravity. Then each time a player spawns the same setting is made - this allows people who join after the command has been issued, to have their gravity set the same.

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