Raised This Month: $ Target: $400
 0% 

fm_set_user_gravity Help!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cikjam
Senior Member
Join Date: Feb 2009
Location: Australia
Old 06-13-2009 , 03:31   fm_set_user_gravity Help!
Reply With Quote #1

Hey,

I been tryna make a plugin for admins to type /grav or /gravity and they will have gravity and type it again and it will be normal but everything i tried failed, im tryna learn to script, so would someone be able to show me the real thing and ill learn from it, thanx.
cikjam is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 06-13-2009 , 03:48   Re: fm_set_user_gravity Help!
Reply With Quote #2

Try this.
Code:
#define USE_FAKEMETA // Comment this if you want to use Fun instead   #include <amxmodx> #include <amxmisc>   #if defined USE_FAKEMETA         #include <fakemeta> #else         #include <fun> #endif   #define MAX_PLAYERS 32   #define ADMIN_LEVEL ADMIN_SLAY #define ADMIN_GRAV 400   new g_bHasGrav[MAX_PLAYERS + 1]; new g_pGrav;   public plugin_init() {         g_pGrav = get_cvar_pointer("sv_gravity");           register_clcmd("say /grav", "cmdGrav", ADMIN_LEVEL);         register_clcmd("say /gravity", "cmdGrav", ADMIN_LEVEL); } public client_disconnect(iCl)         g_bHasGrav[iCl] = false;   public cmdGrav(iCl, iLvl, iCmd) {         if (!cmd_access(iCl, iLvl, iCmd, 2))                 return;           switch (g_bHasGrav[iCl])         {                 case 1:                 {                         g_bHasGrav[iCl] = false;   #if defined USE_FAKEMETA                         set_pev(iCl, pev_gravity, ADMIN_GRAV / get_pcvar_num(g_pGrav)); #else                         set_user_gravity(iCl, ADMIN_GRAV / get_pcvar_num(g_pGrav)); #endif                 }                 case 0:                 {                         g_bHasGrav[iCl] = true;   #if defined USE_FAKEMETA                         set_pev(iCl, pev_gravity, get_pcvar_num(g_pGrav)); #else                         set_user_gravity(iCl, get_pcvar_num(g_pGrav)); #endif                 }         } }
__________________
hleV is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-13-2009 , 04:14   Re: fm_set_user_gravity Help!
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <amxmisc>

//#define USE_FAKEMETA

#if defined USE_FAKEMETA
    #include <fakemeta>
    #define my_set_user_gravity(%1,%2)    set_pev(%1, pev_gravity, %2)
#else
    #include <fun>
    #define my_set_user_gravity(%1,%2)    set_user_gravity(%1, %2)
#endif

#define MAX_PLAYERS 32

#define ADMIN_LEVEL ADMIN_SLAY
#define ADMIN_GRAV 250.0

new g_bHasGrav[MAX_PLAYERS+1]
new 
sv_gravity

public plugin_init()
{
    
sv_gravity get_cvar_pointer("sv_gravity")

    
register_clcmd("say /grav""cmdGrav"ADMIN_LEVEL)
    
register_clcmd("say /gravity""cmdGrav"ADMIN_LEVEL)
}

public 
client_putinserver(id)
{
    
g_bHasGrav[id] = false
}

public 
cmdGrav(idlevelcid)
{
    if(
cmd_access(idlevelcid2))
    {
        
my_set_user_gravity(id, (g_bHasGrav[id] = !g_bHasGrav[id]) ? (ADMIN_GRAV get_pcvar_float(sv_gravity)) : 1.0)
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
cikjam
Senior Member
Join Date: Feb 2009
Location: Australia
Old 06-13-2009 , 04:48   Re: fm_set_user_gravity Help!
Reply With Quote #4

thx both work
Hlev ones i fly to roof though

Where would i add messages in these? saying.
You Have Enabled Gravity
You Have Disabled Gravity

Thanx

EDIT: BTW, there are glitches, when you use parachute the gravity goes off, and when you press alt tab and go to windows and come bak the grav is also off
cikjam is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-13-2009 , 04:53   Re: fm_set_user_gravity Help!
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <fun>

#define MAX_PLAYERS 32

#define ADMIN_LEVEL ADMIN_SLAY
#define ADMIN_GRAV 250.0

new g_bHasGrav[MAX_PLAYERS+1]
new 
sv_gravity

public plugin_init()
{
    
sv_gravity get_cvar_pointer("sv_gravity")

    
register_clcmd("say /grav""cmdGrav"ADMIN_LEVEL)
    
register_clcmd("say /gravity""cmdGrav"ADMIN_LEVEL)
}

public 
client_putinserver(id)
{
    
g_bHasGrav[id] = false
}

public 
cmdGrav(id)
{
    if( 
get_user_flags(id) & ADMIN_LEVEL )
    {
        if( (
g_bHasGrav[id] = !g_bHasGrav[id]) )
        {
            
set_user_gravity(idADMIN_GRAV get_pcvar_float(sv_gravity))
            
client_print(idprint_chat" * You Have Enabled Low Gravity")
        }
        else
        {
            
set_user_gravity(id)
            
client_print(idprint_chat" * You Have Disabled Low Gravity")
        }
    }
    return 
PLUGIN_HANDLED

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 06-13-2009 at 10:31.
ConnorMcLeod is offline
cikjam
Senior Member
Join Date: Feb 2009
Location: Australia
Old 06-13-2009 , 05:05   Re: fm_set_user_gravity Help!
Reply With Quote #6

Thanx it works, the only thing is i just noticed, Non-admins can use this.
cikjam is offline
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 06-13-2009 , 07:26   Re: fm_set_user_gravity Help!
Reply With Quote #7

I dont know if its the best way but you can add is_user_admin in the if function
micke1101 is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 06-13-2009 , 10:29   Re: fm_set_user_gravity Help!
Reply With Quote #8

Quote:
Originally Posted by cikjam View Post
Thanx it works, the only thing is i just noticed, Non-admins can use this.
PHP Code:
#define ADMIN_LEVEL ADMIN_SLAY 
--> 
#define ADMIN_LEVEL ADMIN_ALL 
or change

PHP Code:
register_clcmd("say /grav""cmdGrav"ADMIN_LEVEL
register_clcmd("say /gravity""cmdGrav"ADMIN_LEVEL)
-->
register_clcmd("say /grav""cmdGrav"
register_clcmd("say /gravity""cmdGrav"
EDIT: Wow. I'm dumb! :p
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 06-13-2009 at 10:32.
Xellath is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-13-2009 , 10:30   Re: fm_set_user_gravity Help!
Reply With Quote #9

I'm not sur if the 2 should be a 1 :
if(cmd_access(id, level, cid, 2))

Anyway, edited.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 13:52.


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