ramrod Posted June 11, 2008 Posted June 11, 2008 Hey, for my TDMA map, i need to set default gravity. how do i do this? where do i put it? thanks
Willy Posted June 12, 2008 Posted June 12, 2008 http://development.mtasa.com/index.php?title=SetGravity The level of gravity ( default is 0.008 )
ramrod Posted June 12, 2008 Author Posted June 12, 2008 AHHH so its not in the meta like i thought, will try tht ow 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 )
tma Posted June 12, 2008 Posted June 12, 2008 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))
ramrod Posted June 12, 2008 Author Posted June 12, 2008 itll be for the server / everyone. but thats exactly what i have put down and doesnt work.
tma Posted June 12, 2008 Posted June 12, 2008 You have: setGravity ( 0.0035(level) ) I wrote: setGravity(tonumber(level))
ramrod Posted June 12, 2008 Author Posted June 12, 2008 ohhh i edited that cos thats what i thought u had t odo LOL. my bad, thanks, ill figure something out 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
tma Posted June 12, 2008 Posted June 12, 2008 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.
ramrod Posted June 12, 2008 Author Posted June 12, 2008 thanks for the help, do appreciate it. i'm almost there so i now have this function grav ( sourcePlayer, command ) setGravity ( 0.0035 ) end addCommandHandler ( "setgravity" , grav ) and ...it still doesnt work LOL.
tma Posted June 12, 2008 Posted June 12, 2008 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now