Raised This Month: $ Target: $400
 0% 

Weapon firing when MOTD appears | CVAR not updating |


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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