View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-22-2020 , 08:35   Re: [CSGO] Get active bonus weapon in deathmatch
Reply With Quote #2

Spoiler


There are two ways... I haven't found bonusweaponloadoutslot to second way.

But here is way to do it with events.
Event's fire always in same order.

This example have also trash code, ignore it.

PHP Code:
/*
Server event "player_death", Tick 28790:
- "userid" = "12"
- "attacker" = "2"
- "assister" = "0"
- "assistedflash" = "0"
- "weapon" = "elite"
- "weapon_itemid" = "7667212035"
- "weapon_fauxitemid" = "17293822569105719298"
- "weapon_originalowner_xuid" = "76561197988592905"
- "headshot" = "1"
- "dominated" = "0"
- "revenge" = "0"
- "wipe" = "0"
- "penetrated" = "0"
- "noreplay" = "1"
Server event "item_pickup_slerp", Tick 28790:
- "userid" = "2"
- "index" = "352"
- "behavior" = "1"
Server event "item_pickup", Tick 28790:
- "userid" = "2"
- "item" = "healthshot"
- "silent" = "1"
- "defindex" = "57"
Server event "gg_leader", Tick 28790:
- "playerid" = "2"
Server event "gg_killed_enemy", Tick 28790:
- "victimid" = "12"
- "attackerid" = "2"
- "dominated" = "0"
- "revenge" = "0"
- "bonus" = "1"
*/




#include <sdktools>

public void OnPluginStart()
{
    
HookEventEx("player_death",     gg_bonus_kill);
    
HookEventEx("gg_killed_enemy",    gg_bonus_kill);

    
RegConsoleCmd("sm_test"test);
}

public 
void gg_bonus_kill(Event event, const char[] namebool dontBroadcast)
{
    static 
int tick[MAXPLAYERS+1];
    static 
char weapon[MAXPLAYERS+1][MAX_NAME_LENGTH];

    if(
StrEqual(name"player_death"false))
    {
        
int attacker GetClientOfUserId(event.GetInt("attacker"));
        
tick[attacker] = GetGameTickCount();
        
event.GetString("weapon"weapon[attacker], sizeof(weapon[]));

        return;
    }

    
// not bonus kill
    
if(event.GetInt("bonus") != 1) return;


    
int attackerid GetClientOfUserId(event.GetInt("attackerid"));
    
    
// some odd reason tick doesn't match.
    
if(tick[attackerid] != GetGameTickCount()) return;
    
    
// success
    
BonusGun(attackeridweapon[attackerid]);
}

void BonusGun(int client, const char[] weapon)
{
    
PrintToServer("%N %s"clientweapon);
}



public 
Action test(int clientint args)
{
    
int m_iBonusProgress GetEntProp(clientProp_Send"m_iBonusProgress");
    
int m_iBonusChallenge GetEntProp(clientProp_Send"m_iBonusChallenge");
    
    
PrintToServer("m_iBonusProgress %i\nm_iBonusChallenge%i"m_iBonusProgressm_iBonusChallenge);



    
float m_flDMBonusStartTime GameRules_GetPropFloat("m_flDMBonusStartTime");
    
float m_flDMBonusTimeLength GameRules_GetPropFloat("m_flDMBonusTimeLength");
    
int m_unDMBonusWeaponLoadoutSlot GameRules_GetProp("m_unDMBonusWeaponLoadoutSlot");
    
int m_bDMBonusActive GameRules_GetProp("m_bDMBonusActive");


    
PrintToServer("m_flDMBonusStartTime %f\nm_flDMBonusTimeLength %f\nm_unDMBonusWeaponLoadoutSlot %i\nm_bDMBonusActive %i\n",
                    
m_flDMBonusStartTime,
                    
m_flDMBonusTimeLength,
                    
m_unDMBonusWeaponLoadoutSlot,
                    
m_bDMBonusActive);



    
PrintToServer("m_GGProgressiveWeaponOrderCT %i"GameRules_GetProp("m_GGProgressiveWeaponOrderCT"_m_unDMBonusWeaponLoadoutSlot));
    
PrintToServer("m_GGProgressiveWeaponKillUpgradeOrderT %i"GameRules_GetProp("m_GGProgressiveWeaponKillUpgradeOrderT"_m_unDMBonusWeaponLoadoutSlot));



    return 
Plugin_Continue;


*edit
I think I figured out how second way is working. It has to do with items_game.txt
I add that code later here.
__________________
Do not Private Message @me

Last edited by Bacardi; 04-22-2020 at 09:36.
Bacardi is offline