Raised This Month: $ Target: $400
 0% 

Weapon firing when MOTD appears | CVAR not updating |


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-10-2018 , 09:01   Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #1

Hi,

1. So when I kill someone a MOTD is supposed to appear to me, but after I kill him and the MOTD appears I'm unable to stop the gun firing, so it automatically keeps shooting until I'm out of ammo. Why does this loop happen?

2. My CVARs don't update when I first get in the game, I have to use 'restart' command so it can be fully updated. Basically this is my code that sets the CVARs.
PHP Code:
public plugin_init( )
{        
    
g_iCvars] = register_cvar"cs_battleroyale_team_num""6" ); // number of teams
    
g_iCvars] = register_cvar"cs_battleroyale_player_per_team""4" ); // number of players in one team
    
    
g_iMaxTeams get_pcvar_numg_iCvars] );
    
g_iPlayerPerTeam get_pcvar_numg_iCvars] );

while in my amxx.cfg it's
Quote:
cs_battleroyale_team_num 4
cs_battleroyale_player_per_team 2
When I join game for the first time I get 'Number of teams: 6 | Number of players per team: 4' same as inside the .sma , but when I restart it is same as amxx.cfg
Why is this?
__________________

Last edited by edon1337; 08-02-2018 at 14:00.
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-10-2018 , 09:49   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #2

That's considered a bug, the same happens if you hold IN_ATTACK and open the console. I believe you can fix that "holstering" and "deploying" the active item of the player when motd be shown. Or you can "supercede" the primary attack if the motd is current opened.

I'm not sure, but you need to set these variables in plugin_cfg, not in plugin_init.

Code:
g_iMaxTeams = get_pcvar_num( g_iCvars[ 0 ] ); g_iPlayerPerTeam = get_pcvar_num( g_iCvars[ 1 ] );
__________________









Last edited by CrazY.; 07-10-2018 at 10:01.
CrazY. is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-10-2018 , 09:55   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #3

You need to force the player stop shooting before call show_motd

Also here

g_iMaxTeams = get_pcvar_num( g_iCvars[ 0 ] );
g_iPlayerPerTeam = get_pcvar_num( g_iCvars[ 1 ] );

Is fine, is not needed to move into plugin_cfg.
but why not use get_pcvar_num( g_iCvars[ 0 ] ) on plugin, instead of g_iMaxTeams, is needed to fix this variable to initial value? same to other g_iPlayerPerTeam??
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-10-2018 at 09:58.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-10-2018 , 12:35   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #4

Quote:
Originally Posted by ^SmileY View Post
You need to force the player stop shooting before call show_motd

Also here

g_iMaxTeams = get_pcvar_num( g_iCvars[ 0 ] );
g_iPlayerPerTeam = get_pcvar_num( g_iCvars[ 1 ] );

Is fine, is not needed to move into plugin_cfg.
but why not use get_pcvar_num( g_iCvars[ 0 ] ) on plugin, instead of g_iMaxTeams, is needed to fix this variable to initial value? same to other g_iPlayerPerTeam??
g_iMaxTeams is just a variable that holds the cached value of cs_battleroyale_team_num CVAR, is that what you asked?

Full code here, if you want to check:
PHP Code:
#include < amxmodx >
#include < hamsandwich >
#include < fakemeta >
#include < fun >
#include < cstrike >

#define MAX_PLAYERS 32
#define NO_TEAM 0

new g_iPlayerPerTeam;
new 
g_iMaxTeams;

new 
g_iCvars];

new 
g_iTeammatesMAX_PLAYERS ];
new 
g_iPlayerTeamMAX_PLAYERS ];

new 
HamHook:g_iHamTakeDamageFw;
new 
HamHook:g_iHamTraceAttackFw;
new 
HamHook:g_iHamKilledFw;

public 
plugin_init( )
{
    
register_plugin"CS Battle Royale Fake Teams""1.0""DoNii" );
        
    
g_iCvars] = register_cvar"cs_battleroyale_team_num""6" ); // number of teams
    
g_iCvars] = register_cvar"cs_battleroyale_player_per_team""4" ); // number of players in one team
    
    
g_iMaxTeams get_pcvar_numg_iCvars] );
    
g_iPlayerPerTeam get_pcvar_numg_iCvars] );
    
    
register_event"HLTV""OnNewRound""a""1=0""2=0" );
    
    
g_iHamTakeDamageFw RegisterHamHam_TakeDamage"player""fw_HamTakeDamagePre");
    
DisableHamForwardg_iHamTakeDamageFw );
    
    
g_iHamTraceAttackFw RegisterHamHam_TraceAttack"player""fw_HamTraceAttackPre");
    
DisableHamForwardg_iHamTraceAttackFw );
    
    
g_iHamKilledFw RegisterHamHam_Killed"player""fw_HamKilledPre");
    
DisableHamForwardg_iHamKilledFw );
}

public 
plugin_cfg( )
{
    
EnableHamForwardg_iHamTakeDamageFw );
    
EnableHamForwardg_iHamTraceAttackFw );
    
EnableHamForwardg_iHamKilledFw );
}

public 
plugin_natives( )
{
    
register_library"cs_battleroyale_faketeams" );

    
register_native"GetPlayerTeam""OnNativeGetPlayerTeam");
    
register_native"SetPlayerTeam""OnNativeSetPlayerTeam");
    
    
register_native"GetMaxTeams""OnNativeGetMaxTeams");
    
register_native"SetMaxTeams""OnNativeSetMaxTeams");
    
register_native"GetPlayerPerTeam""OnNativeGetPlayerPerTeam");
    
register_native"SetPlayerPerTeam""OnNativeSetPlayerPerTeam");
}

public 
OnNativeGetPlayerTeamid )
{
    if( ! 
is_user_connectedid ) )
    return -
1;

    return 
g_iPlayerTeamid ];
}

public 
OnNativeSetPlayerTeamidiTeam )
{
    if( ! 
is_user_connectedid ) )
    return -
1;

    
g_iPlayerTeamid ] = iTeam;
    return 
1;
}

public 
OnNativeGetMaxTeams( )
{
    return 
g_iMaxTeams;
}

public 
OnNativeSetMaxTeamsiValue )
{
    if( !( 
<= iValue <= MAX_PLAYERS ) )
    return -
1;

    
g_iMaxTeams iValue;
    return 
1;
}

public 
OnNativeGetPlayerPerTeam( )
{
    return 
g_iPlayerPerTeam;
}

public 
OnNativeSetPlayerPerTeamiValue )
{
    if( !( 
<= iValue <= MAX_PLAYERS ) )
    return -
1;

    
g_iPlayerPerTeam iValue;
    return 
1;
}

public 
client_disconnectid )
{
    if( 
g_iPlayerTeamid ] != NO_TEAM )
    {
        
g_iTeammatesg_iPlayerTeamid ] ]--;
        
g_iPlayerTeamid ] = NO_TEAM;
    }
    
g_iPlayerTeamid ] = NO_TEAM;
}

public 
client_connectid )
{
    
g_iPlayerTeamid ] = NO_TEAM;
    
FindAvailableTeamid );
}

public 
fw_HamKilledPreiVictimiAttackeriShouldGib )
{
    if( 
iVictim == iAttacker )
    return 
HAM_IGNORED;

    new 
iVictimTeam get_user_teamiVictim );
    
    if( 
g_iPlayerTeamiVictim ] != g_iPlayerTeamiAttacker ] )
    {
        if( 
iVictimTeam == get_user_teamiAttacker ) )
        {
            
cs_set_user_teamiVictimiVictimTeam == );
        }
        return 
HAM_IGNORED;
    }
    return 
HAM_SUPERCEDE;
}

public 
fw_HamTraceAttackPreiVictimiAttackerFloat:fDamageFloat:fDir], iPtriDamageType )
{
    if( 
iVictim == iAttacker )
    return 
HAM_IGNORED;

    new 
iVictimTeam get_user_teamiVictim );
    
    if( 
g_iPlayerTeamiVictim ] != g_iPlayerTeamiAttacker ] )
    {
        if( 
iVictimTeam == get_user_teamiAttacker ) )
        {
            
cs_set_user_teamiVictimiVictimTeam == );
            
ExecuteHamBHam_TraceAttackiVictimiAttackerfDamagefDiriPtriDamageType);
            
cs_set_user_teamiVictimiVictimTeam );
        }
        return 
HAM_IGNORED;
    }
    
SetHamParamFloat30.0 );
    return 
HAM_SUPERCEDE;
}

public 
fw_HamTakeDamagePreiVictimiInflictoriAttackerFloat:fDamageiDamageBits )
{    
    if( 
iVictim == iAttacker )
    return 
HAM_IGNORED;
    
    new 
iVictimTeam get_user_teamiVictim );
    
    if( 
g_iPlayerTeamiVictim ] != g_iPlayerTeamiAttacker ] )
    {
        if( 
iVictimTeam == get_user_teamiAttacker ) )
        {
            
cs_set_user_teamiVictimiVictimTeam == );
            
ExecuteHamBHam_TakeDamageiVictimiInflictoriAttackerfDamageiDamageBits );
            
cs_set_user_teamiVictimiVictimTeam );
        }
        return 
HAM_IGNORED;
    }
    
SetHamParamFloat40.0 );
    return 
HAM_SUPERCEDE;
}

public 
OnNewRound( )
{
    static 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"a" );

    static 
iTempID;
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        if( 
g_iPlayerTeamiTempID ] == NO_TEAM && ( ( <= get_user_teamiTempID ) <= ) ) )
        {
            
FindAvailableTeamiTempID );
        }
    }
}

FindAvailableTeamid )
{
    for( new 
iTeam=1iTeam <= g_iMaxTeamsiTeam++ )
    {
        if( 
IsTeamAvailableiTeam ) )
        {
            
g_iPlayerTeamid ] = iTeam;
            
g_iTeammatesiTeam ]++;
            
            break;
        }
        continue;
    }
}

IsTeamAvailableiTeam )
{
    return 
g_iTeammatesiTeam ] < g_iPlayerPerTeam 0;

Quote:
Originally Posted by CrazY. View Post
That's considered a bug, the same happens if you hold IN_ATTACK and open the console. I believe you can fix that "holstering" and "deploying" the active item of the player when motd be shown. Or you can "supercede" the primary attack if the motd is current opened.

I'm not sure, but you need to set these variables in plugin_cfg, not in plugin_init.

Code:
g_iMaxTeams = get_pcvar_num( g_iCvars[ 0 ] ); g_iPlayerPerTeam = get_pcvar_num( g_iCvars[ 1 ] );
I already tried using plugin_cfg but it didn't change anything.
About the MOTD thanks I'll try it.
__________________

Last edited by edon1337; 07-10-2018 at 12:37.
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-10-2018 , 12:46   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #5

Check cvars.ini too.
__________________








CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-10-2018 , 17:26   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
Check cvars.ini too.
Do I have to put CVARs that I put in amxx.cfg in cvars.ini too?
__________________
edon1337 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-12-2018 , 12:13   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #7

I tried setting 9999.9 delay and returning HAM_SUPERCEDE in Ham_Weapon_PrimaryAttack but it didn't stop player from shooting
__________________

Last edited by edon1337; 07-12-2018 at 12:13.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-12-2018 , 13:42   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #8

Quote:
Originally Posted by edon1337 View Post
I tried setting 9999.9 delay and returning HAM_SUPERCEDE in Ham_Weapon_PrimaryAttack but it didn't stop player from shooting
Can you post code?
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-12-2018 , 16:15   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #9

PHP Code:
new bool:g_bVictoryBlockAttack33 ];

#define g_iBitsum (1<<CSW_P228)|(1<<CSW_GLOCK)|(1<<CSW_C4)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_UMP45)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)

public plugin_init( )
{
    for( new 
CSW_P228<= CSW_P90i++ )
    {
        if( 
g_iBitsum & (1<<i) )
        continue;
        
        
get_weaponnameiszWeaponNamecharsmaxszWeaponName ) );
        
RegisterHamHam_Weapon_PrimaryAttackszWeaponName"@HamPrimaryAttack_Pre" );
    }
}

public @
HamPrimaryAttack_PreiEnt )
{
    new 
id;
    
id peviEntpev_owner );
    
    if( 
g_bVictoryBlockAttackid ] )
    {
        
set_pdata_floatiEntm_flNextPrimaryAttack9999.9);
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}

VictoryiPlayer )
{
    new 
szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"a" );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
g_bVictoryBlockAttackiTempID ] = true;
    }

__________________
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-13-2018 , 04:03   Re: Weapon firing when MOTD appears | CVAR not updating |
Reply With Quote #10

Quote:
Originally Posted by edon1337 View Post
PHP Code:
new bool:g_bVictoryBlockAttack33 ];

#define g_iBitsum (1<<CSW_P228)|(1<<CSW_GLOCK)|(1<<CSW_C4)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_UMP45)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)

public plugin_init( )
{
    for( new 
CSW_P228<= CSW_P90i++ )
    {
        if( 
g_iBitsum & (1<<i) )
        continue;
        
        
get_weaponnameiszWeaponNamecharsmaxszWeaponName ) );
        
RegisterHamHam_Weapon_PrimaryAttackszWeaponName"@HamPrimaryAttack_Pre" );
    }
}

public @
HamPrimaryAttack_PreiEnt )
{
    new 
id;
    
id peviEntpev_owner );
    
    if( 
g_bVictoryBlockAttackid ] )
    {
        
set_pdata_floatiEntm_flNextPrimaryAttack9999.9);
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}

VictoryiPlayer )
{
    new 
szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"a" );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
g_bVictoryBlockAttackiTempID ] = true;
    }

#1 Your code is not compilable cause there is not szWeaponName
#2 You should use new const instead of #define on bitsums, cause it wont work.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted 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 12:37.


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