Raised This Month: $ Target: $400
 0% 

Gravity Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dudeman1090
Junior Member
Join Date: Dec 2005
Location: SomeWhere
Old 03-02-2006 , 19:06   Gravity Help
Reply With Quote #1

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
__________________
Hey
Dudeman1090 is offline
Send a message via MSN to Dudeman1090 Send a message via Yahoo to Dudeman1090
Kraugh
Senior Member
Join Date: Jan 2006
Location: barrington, ri
Old 03-02-2006 , 20:06  
Reply With Quote #2

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.
__________________
"You can not restrain a fool from speaking, but nothing obliges you to listen."
Kraugh is offline
Send a message via AIM to Kraugh
c0rdawg
Senior Member
Join Date: Jan 2006
Old 03-02-2006 , 21:33  
Reply With Quote #3

a plugin could change the cvar too, then you wouldn't have to do all that. not that its that much, but yeah...
c0rdawg is offline
Send a message via AIM to c0rdawg Send a message via MSN to c0rdawg
pixel3
Senior Member
Join Date: Dec 2005
Old 03-03-2006 , 11:34  
Reply With Quote #4

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)     } }
__________________
pixel3 is offline
violentcrimes
Senior Member
Join Date: Nov 2006
Old 12-23-2006 , 01:36   Re: Gravity Help
Reply With Quote #5

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
__________________
violentcrimes is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-23-2006 , 01:42   Re: Gravity Help
Reply With Quote #6

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.
The Specialist is offline
Send a message via AIM to The Specialist
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-23-2006 , 01:44   Re: Gravity Help
Reply With Quote #7

violentcrimes: http://forums.alliedmods.net/showthread.php?t=6516
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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