AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   CS Gravity (https://forums.alliedmods.net/showthread.php?t=134723)

hornet 08-08-2010 02:02

CS Gravity
 
I'm making a level up system which involves my player's gravity going up by 10 (CS gravity) each time the player levels up, in order to allow them to jump higher. My problem is when I use the Fun Module function get_user_gravity(id) it gives me the number 1065353216.

So I looked at it this way - in CS the default gravity is 800. I want it to go up by 10. So 800 divided by 10 is 80, meaning that my gravity goes up by one 80th of the default gravity each level up. So I thought if I get one 80th of 1065353216, which is 13316915, I can increase 1065353216 (the default) by 13316915 (the 80th of the default) each time the player levels up. Now when using set_user_gravity(id) it seems to push you in the opposite way to CS gravity, (at the moment I've only tested this part at level 20) so whether I add or subtract the 80th it will either shoot me up into the sky or glue me to the ground.

Can someone please help me?

wrecked_ 08-08-2010 02:09

Re: CS Gravity
 
Code:
// Level[id] will represent the player's level #include <amxmodx> #include <engine> new PointerGravity public plugin_init()     PointerGravity = get_cvar_pointer( "sv_gravity" ) SetGravity( id )     entity_set_float( id, EV_FL_gravity, ( ( PointerGravity - ( Level[id] * 10 ) ) / PointerGravity ) )

GXLZPGX 08-08-2010 02:16

Re: CS Gravity
 
Quote:

Originally Posted by hornet (Post 1265031)
I'm making a level up system which involves my player's gravity going up by 10 (CS gravity) each time the player levels up, in order to allow them to jump higher. My problem is when I use the Fun Module function get_user_gravity(id) it gives me the number 1065353216.

So I looked at it this way - in CS the default gravity is 800. I want it to go up by 10. So 800 divided by 10 is 80, meaning that my gravity goes up by one 80th of the default gravity each level up. So I thought if I get one 80th of 1065353216, which is 13316915, I can increase 1065353216 (the default) by 13316915 (the 80th of the default) each time the player levels up. Now when using set_user_gravity(id) it seems to push you in the opposite way to CS gravity, (at the moment I've only tested this part at level 20) so whether I add or subtract the 80th it will either shoot me up into the sky or glue me to the ground.

Can someone please help me?

The way set_user_gravity works is:

set_user_gravity( id, 1.0 ) <-- Normal Gravity
set_user_gravity( id, 1.5 ) <-- Higher Gravity
set_user_gravity( id, 0.5 ) <-- Lower Gravity

Now, I'm not sure, but you can probably use..

set_user_gravity( id, 0.99 )
set_user_gravity( id, 0.98 )

etc.. but I haven't tested it.

hornet 08-08-2010 03:23

Re: CS Gravity
 
Nah both of those didnt work :(

ot_207 08-08-2010 04:35

Re: CS Gravity
 
Quote:

Originally Posted by hornet (Post 1265136)
Nah both of those didnt work :(

It returns those huge values because you are using integers instead of floats.
Try this:
PHP Code:

new Float:xy;
get_user_gravity(id);
get_user_gravity(id);
client_print(idprint_chat"CORRECT %f FALSE %d"xy); 

You will see that CORRECT gravity will return 1.0 or 1.5 or 0.5 depending on the settings that have been made by you or other plugins.
Also you need to set the gravity using float values not integers.
PHP Code:

new Float:1.01;
set_user_gravity(idx);
set_user_gravity(idy); // Here you will get an error ;) 


hornet 08-08-2010 05:24

Re: CS Gravity
 
omg thanks mate you are a champion!!!


All times are GMT -4. The time now is 00:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.