AlliedModders

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

Dudeman1090 03-02-2006 19:06

Gravity Help
 
im making a plugins but i need help.... i need to know how to make it set every1's gravity.. i know i can just change the server cvar but i want it in the plugin. Thx in advanced

Kraugh 03-02-2006 20:06

well, you could use set_user_gravity from the fun module:

Code:
set_user_gravity(id,Float:amount);

however, it doesn't take an exact number like sv_gravity. instead, it takes a percentage of what the gravity currently is. so, setting amount as 1.0 will give you 100% of current gravity, 0.5 will be 50% of current gravity, and 2.0 will be 200% of current gravity.

it is still possible to set it to an exact number (ie: 800 instead of 1.0), by dividing what you want it to be by sv_gravity. since you want to set everyone's gravity, you'll have to get a list of players and loop through it.

so, here it is.

Code:
public set_all_gravity(Float:gravity) {    new Float:current_gravity = get_cvar_float("sv_gravity");    new Float:new_gravity = gravity / current_gravity;    new players[32], num, i;    get_players(players,num);    for(i=0;i<num;i++)       set_user_gravity(players[i],new_gravity); }

just put this somewhere in your code, and then you can call it like any other function to set the gravity of all players in the server.

c0rdawg 03-02-2006 21:33

a plugin could change the cvar too, then you wouldn't have to do all that. not that its that much, but yeah...

pixel3 03-03-2006 11:34

Quote:

Originally Posted by c0rdawg
a plugin could change the cvar too, then you wouldn't have to do all that. not that its that much, but yeah...

Something like this:

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Chnage Gravity" #define VERSION "1.0" #define AUTHOR "YourName" /* Admin level required to use command */ #define ADMIN_LEVEL ADMIN_KICK public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("amx_gravity", "handle_gravity", ADMIN_LEVEL, "<amount> - Change the gravity") } public handle_gravity(id, level, cid) {     if (!cmd_access(id,level,cid,3)) {         return PLUGIN_HANDLED     }     new gravity[6]     read_argv(1, gravity, 5)     server_cmd("sv_gravity %i",gravity)     new name[32]     get_user_name(id, name, 31)     switch(get_cvar_num("amx_show_activity")){         case 2: client_print(0,print_chat,"[AMXX] ADMIN %s: set gravity to %i", name, gravity)         case 1: client_print(0,print_chat,"[AMXX] ADMIN: set gravity to %i", gravity)     } }

violentcrimes 12-23-2006 01:36

Re: Gravity Help
 
ok im prolly a moron but for some reason i cant set up my server.cfg to make it auto 250 for the gravity its for a scout 24/7 server so i dont want it to change i want it to always have 250 gravity

The Specialist 12-23-2006 01:42

Re: Gravity Help
 
your not supposed to use server_cmd for cvars . Use

Code:
set_cvar_string("sv_gravity","250"); set_cvar_num("sv_gravity","250");

It says right in the doc's , that you shouldnt use server_cmd for cvars.

XxAvalanchexX 12-23-2006 01:44

Re: Gravity Help
 
violentcrimes: http://forums.alliedmods.net/showthread.php?t=6516


All times are GMT -4. The time now is 20:19.

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