AlliedModders

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

Monster Truck 01-01-2014 16:39

Gravity --'
 
Hi all, i've got some problems now with a plugin. I give you here a little description. It shows a menu each round for Terros and Cts wich allows them to choose their races. One of them (in Terro) gives Gravity, and there is my problem.

When it stills 1 Terro, he can open a menu that allows him to 1v1 each ct untill the last one.

The problem is that the last Terro get is gravity to normal, but it wont work. Honnestly, i don't really know the normal gravity value.

Anyway, had the same problem for speed and fixed it.

I show the whole code here :
PHP Code:

#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>

#define VERSION "2.3"

new g_PlayersSpeedg_PlayersSpeedLastg_maxPlayers
new boolg_isAlive33 ], CsTeamsg_playerTeam33 ]

public 
plugin_init()
{
    
register_plugin("Classes"VERSION"Imag!ne")
    
RegisterHam(Ham_Spawn"player""PlayerSpawn"1)
    
    
g_PlayersSpeed register_cvar("terro_menu""700")
    
g_PlayersSpeedLast register_cvar("Gravity_Speed_Last_Handler""320")
    
g_maxPlayers get_maxplayers( );
}

public 
PlayerSpawn(id)
{
    if(
is_user_alive(id))
    {
        
strip_user_weapons(id)
        
set_pdata_int(id1160)
        
give_item(id"weapon_knife")
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_Tterro(id);
            case 
CS_TEAM_CTrace(id);
        }
    }
}

public 
race(id)
{
    new 
menu menu_create("Choisis Ta classe de Garde :""furien_menu")
    
menu_additem(menu"\wMilitaire \y- \w[ \rM4 \w+ \rDeagle \w]""1")
    
menu_additem(menu"\wSniper \y- \w[ \rAwp \w+ \rDeagle \w]""2")
    
menu_additem(menu"\wMarine \y- \w[ \rMitrailleuse \w+ \rUsp \w]""3")
    
menu_additem(menu"\wGarde \y- \w[ \rAk47 \w+ \rDeagle \w+ \rFlash \w]""4")
    
menu_setprop(menuMPROP_EXITNAME"Quitter")
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu)
}

public 
terro(id)
{
    new 
menu menu_create("Choisis Ta classe de Prisonnier :""terro_menu")
    
menu_additem(menu"\wAssasin \y- \w[ \rGravite \w+ \rArmure \w]""1")
    
menu_additem(menu"\wDealer \y- \w[ \r140Hp \w+ \rArmure \w]""2")
    
menu_additem(menu"\wPedophile \y- \w[ \rVitesse \w+ \rArmure \w]""3")
    
menu_additem(menu"\wTerroriste \y- \w[ \rHe \w+ \rArmure \w]""4")
    
menu_setprop(menuMPROP_EXITNAME"Quitter")
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu)
}



public 
furien_menu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    new 
info[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessinfo6__callback)
    
    if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
    {   
        new 
key str_to_num(info)
    
        switch(
key)
        {
            case 
1:
            {
                
give_item(id"weapon_m4a1")
                
cs_set_user_bpammo(idCSW_M4A19000)
                
give_item(id"weapon_deagle")
                
cs_set_user_bpammo(idCSW_DEAGLE3500)
            }
            case 
2:
            {
                
give_item(id"weapon_awp")
                
cs_set_user_bpammo(idCSW_AWP9000)
                
give_item(id"weapon_deagle")
                
cs_set_user_bpammo(idCSW_DEAGLE3500)
            }
            case 
3:
            {
                
give_item(id,"weapon_m249")
                
cs_set_user_bpammo(idCSW_M2499000)
                
give_item(id"weapon_usp")
                
cs_set_user_bpammo(idCSW_USP3500)
            }
            case 
4:
            {
                
give_item(id"weapon_ak47")
                
cs_set_user_bpammo(idCSW_AK479000)
                
give_item(id"weapon_deagle")
                
cs_set_user_bpammo(idCSW_DEAGLE3500)
                
give_item(id"weapon_flashbang")
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}


public 
terro_menu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    new 
info[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessinfo6__callback)
    
    if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
    {   
        new 
key str_to_num(info)
    
        switch(
key)
        {
            case 
1:
            {
                
set_user_gravity(id,0.400)
                
cs_set_user_armor(id,100CS_ARMOR_VESTHELM)
            }
            case 
2:
            {
                
set_user_healthidget_user_health(id) + 40 )
                
cs_set_user_armor(id,100CS_ARMOR_VESTHELM)
            }
            case 
3:
            {
                
set_user_maxspeed(id,  get_pcvar_float(g_PlayersSpeed))
                
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
            }
            case 
4:
            {
                
give_item(id"weapon_hegrenade")
                
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
Gravity_Speed_Last_Handleridmenuitem )
{
    if( 
item == MENU_EXIT || getOneTerrorist( ) != id || !g_isAliveid ] )
    {
        
set_user_maxspeedidget_pcvar_float(g_PlayersSpeedLast))
        
set_user_gravity(id)
    }
}

stock getOneTerrorist( )
{
    new 
count;
       
    for( new 
id 1id <= g_maxPlayersid ++ )
    {
        if( 
g_isAliveid ] && g_playerTeamid ] == CS_TEAM_T )
        {
            if( 
count )
            {
                
count 0;
                break;
            }
            else
            {
                
count id;
            }
        }
    }
       
    return 
count;
}

public 
client_putinserverid )
{
    
g_playerTeamid ] = CS_TEAM_SPECTATOR;


Can anybody help me with that issue ?

jimaway 01-01-2014 18:37

Re: Gravity --'
 
set_user_gravity to 1 to set it back to sv_gravity

Monster Truck 01-02-2014 04:38

Re: Gravity --'
 
I get "tag mismatch" if i do that, is it okay anyway ?

EDIT : it won't work, the gravity stays at 0,400 and won't back to normal. :/ (Pasted New Code)

EDIT2 : maybe the right question is : What is the normal value of gravity in set_user_gravity ? Thanks for any answer

Monster Truck 01-02-2014 06:40

Re: Gravity --'
 
Code Edited, i found the normal value (1.0) but is still wont work :shock:.

I'm not upping, just telling what's new on my problem :/

Thanks in advance for any answers.

DavidJr 01-02-2014 06:47

Re: Gravity --'
 
PHP Code:

set_user_gravity(id

It makes the gravity normal.

Monster Truck 01-02-2014 06:56

Re: Gravity --'
 
Code Edited to 2.3

Thank u, but ... i added this to the New Code with set_user_gravity (id) and IT STILL wont work :/

Help me i'm going mad :cry:

11922911 01-02-2014 07:03

Re: Gravity --'
 
where is Gravity_Speed_Last_Handler used?

Monster Truck 01-02-2014 07:19

Re: Gravity --'
 
Used in the last public fuction, there is the code

PHP Code:

public Gravity_Speed_Last_Handleridmenuitem )
{
         if( 
item == MENU_EXIT || getOneTerrorist( ) != id || !g_isAliveid ] )
        {
                 
set_user_maxspeedidget_pcvar_float(g_PlayersSpeedLast))
                 
set_user_gravity(id)
        }



11922911 01-02-2014 07:38

Re: Gravity --'
 
Quote:

Originally Posted by Monster Truck (Post 2079883)
Used in the last public fuction, there is the code

PHP Code:

public Gravity_Speed_Last_Handleridmenuitem )
{
         if( 
item == MENU_EXIT || getOneTerrorist( ) != id || !g_isAliveid ] )
        {
                 
set_user_maxspeedidget_pcvar_float(g_PlayersSpeedLast))
                 
set_user_gravity(id)
        }



It won't working because the function has never been used or called by other thing.

DavidJr 01-02-2014 07:40

Re: Gravity --'
 
You didn't call this function.
PHP Code:

Gravity_Speed_Last_Handler 

Damn, you are faster than me.


All times are GMT -4. The time now is 10:09.

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