AlliedModders

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

cikjam 06-13-2009 03:31

fm_set_user_gravity Help!
 
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.

hleV 06-13-2009 03:48

Re: fm_set_user_gravity Help!
 
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                 }         } }

ConnorMcLeod 06-13-2009 04:14

Re: fm_set_user_gravity Help!
 
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)
    }



cikjam 06-13-2009 04:48

Re: fm_set_user_gravity Help!
 
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

ConnorMcLeod 06-13-2009 04:53

Re: fm_set_user_gravity Help!
 
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



cikjam 06-13-2009 05:05

Re: fm_set_user_gravity Help!
 
Thanx it works, the only thing is i just noticed, Non-admins can use this.

micke1101 06-13-2009 07:26

Re: fm_set_user_gravity Help!
 
I dont know if its the best way but you can add is_user_admin in the if function

Xellath 06-13-2009 10:29

Re: fm_set_user_gravity Help!
 
Quote:

Originally Posted by cikjam (Post 847815)
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

ConnorMcLeod 06-13-2009 10:30

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

Anyway, edited.


All times are GMT -4. The time now is 13:52.

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