AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HELP - with /gravity for admins (https://forums.alliedmods.net/showthread.php?t=174339)

Pexu 12-19-2011 04:39

HELP - with /gravity for admins
 
Hello guys im new on Allied Modders, Im polish and i need help with /gravity for VIP's.

So I'v searched everywhere and I managed to find it but there are a few things I would like to change.

This is what i found, it works fine but it resets in new round, and you need to type it in two times before enableing it.

I need:
-type /gravity or /grav to enable or disable gravity
-Dont want it to reset untill admin types in /gravity or /grav again

Thank you all for your help and time, im sorry if there are some spelling mistakes as i sed im from poland and english is my second language :)

Here: https://forums.alliedmods.net/showthread.php?p=847780

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(id, ADMIN_GRAV / get_pcvar_float(sv_gravity))
           
client_print(id, print_chat, " * You Have Enabled Low Gravity")
        }
        else
        {
           
set_user_gravity(id)
           
client_print(id, print_chat, " * You Have Disabled Low Gravity")
        }
    }
    return
PLUGIN_HANDLED
}




Erox902 12-19-2011 04:48

Re: HELP - with /gravity for admins
 
Gravity is resetted 'cuz the game does automaticly set it back when you spawn.

What you could do is check at spawn if g_bHasGrav at spawn and if "index" does, set it again.

Pexu 12-19-2011 04:52

Re: HELP - with /gravity for admins
 
Do is there no way i can have gravity at all times untill i type /gravity again ?

Devil259 12-19-2011 05:02

Re: HELP - with /gravity for admins
 
Did you read what Erox902 said ?

Code:
RegisterHam( Ham_Spawn , "player" , "fwPlayerSpawn" , true ) // hook the spawn with ham public fwPlayerSpawn( id ) // spawn function {     if( g_bHasGrav[ id ] ) // if he's gravity     {         set_user_gravity( ... ) // set it     } }

Btw :

Code:
if( (g_bHasGrav[id] = !g_bHasGrav[id]) )

=

Code:
if( !g_bHasGrav[id] )

Pexu 12-19-2011 05:09

Re: HELP - with /gravity for admins
 
This looks like it would work, but i am new to scripting could you show me this added in

Thank your the best karma !!

Pexu 12-19-2011 06:56

Re: HELP - with /gravity for admins
 
why is it when i coppy and paste it all looks like this:

Code:

#include <amxmodx> #include <fun> #include <hamsandwich> #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)    RegisterHam( Ham_Spawn , "player" , "fwPlayerSpawn" , true ) } public fwPlayerSpawn( id ) {    if( is_user_alive( id ) && g_bHasGrav[ id ] )    {        set_user_gravity( id , ADMIN_GRAV / get_pcvar_float(sv_gravity))    } } public client_putinserver(id) {    g_bHasGrav[id] = false } public cmdGrav(id) {    if( get_user_flags(id) & ADMIN_LEVEL )    {        if( !g_bHasGrav[id] )        {            set_user_gravity(id, ADMIN_GRAV / get_pcvar_float(sv_gravity))            client_print(id, print_chat, " * You Have Enabled Low Gravity")        }        else        {            set_user_gravity(id)            client_print(id, print_chat, " * You Have Disabled Low Gravity")        }    }    return PLUGIN_HANDLED }

Pexu 12-19-2011 07:06

Re: HELP - with /gravity for admins
 
I have tried this but gravity still resets in next round ;(

Can some one make a plugin like this when player with flag "t" types in /gravity it sets gravity to lower and when they type /gravityoff it sets it back to normal ?

is it possible so that it does not reset every round ?

Erox902 12-19-2011 07:28

Re: HELP - with /gravity for admins
 
The code that Devil259 should work.
Are you sure that you compiled and replaced the original amxx?

Also don't double post use the edit button

Pexu 12-19-2011 07:43

Re: HELP - with /gravity for admins
 
yes, after i type /gravity it works but restes in the next round an also when i type in /gravity second time in the round it doesent change back to norman this pops up all the time "
You Have Enabled Low Gravity

Erox902 12-19-2011 12:25

Re: HELP - with /gravity for admins
 
Try this simple edit
PHP Code:

RegisterHamHam_Spawn"player""fwPlayerSpawn" 



All times are GMT -4. The time now is 12:06.

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