Raised This Month: $ Target: $400
 0% 

[SOLVED] 1 vs Enemies situations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-09-2013 , 08:51   [SOLVED] 1 vs Enemies situations
Reply With Quote #1

Hi all, i tried to hook when player is alone vs some enemies to count 1v1, 1v2 1v3.

Bassically based on this example.

- Count when a TR is alone vs other players (vs 1, vs 2 etc..)
- When round end and TR alone and alive & is terrorist win, increase in an variable (Indifferent if has other CTs alive or not, because its based on Round end event.

--> The same case applied when alone player is a CT.

EDIT: I tried this code (And worked! Topic Solved)

PHP Code:
#include <amxmodx>
#include <cstrike>

#include <csx>

new p_iStats;

new 
g_iAlive[CsTeams];

new 
g_iAlone[33];

enum Versus
{
    
V1 1,
    
V2,
    
V3,
    
V4,
    
V5
};

new 
g_iVersus[33][Versus];

public 
plugin_init()
{
    
register_plugin("SmileY",AMXX_VERSION_STR,"SmileY");
    
    
p_iStats register_cvar("amx_stats","0");
    
    
register_event("SendAudio","ev_SendAudio","a","2=%!MRAD_terwin","2=%!MRAD_ctwin");
    
    
register_logevent("ev_RoundStart",2,"1=Round_Start");
    
    
register_clcmd(".stats","cmdStats");
}

public 
cmdStats(id)
{
    
client_print
    
(
        
id,
        
print_chat,
        
"[Wins] 1V1 %d 1V2 %d 1V3 %d 1V4 %d 1V5 %d",
        
g_iVersus[id][V1],
        
g_iVersus[id][V2],
        
g_iVersus[id][V3],
        
g_iVersus[id][V4],
        
g_iVersus[id][V5]
    );
    
    return 
PLUGIN_HANDLED;
}

public 
client_death(iKiller,iVictim,iWP,iPlace,iTK)
{
    if(
get_pcvar_num(p_iStats))
    {
        new 
iPlayers[32],iNum,iPlayer;
        
get_players(iPlayers,iNum,"h");
        
        for(new 
i;iNum;i++)
        {
            
iPlayer iPlayers[i];
            
            if(
IsAlone(iPlayer) && !g_iAlone[iPlayer])
            {
                
g_iAlone[iPlayer] = g_iAlive[(cs_get_user_team(iPlayer) == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T];
            }
        }
        
        
g_iAlive[cs_get_user_team(iVictim)]--;
    }
}

public 
ev_SendAudio()
{
    if(
get_pcvar_num(p_iStats))
    {
        new 
szTeam[22];
        
read_data(2,szTeam,charsmax(szTeam));
        
        if(
containi(szTeam,"terwin") != -1)
        {
            new 
iPlayers[32],iNum,iPlayer;
            
get_players(iPlayers,iNum,"aeh","TERRORIST");
            
            for(new 
i;iNum;i++)
            {
                
iPlayer iPlayers[i];

                switch(
g_iAlone[iPlayer])
                {
                    case 
1g_iVersus[iPlayer][V1]++;
                    
                    case 
2g_iVersus[iPlayer][V2]++;
                    
                    case 
3g_iVersus[iPlayer][V3]++;
                    
                    case 
4g_iVersus[iPlayer][V4]++;
                    
                    case 
5g_iVersus[iPlayer][V5]++;
                }
            }
        }
        else
        {
            new 
iPlayers[32],iNum,iPlayer;
            
get_players(iPlayers,iNum,"aeh","CT");
            
            for(new 
i;iNum;i++)
            {
                
iPlayer iPlayers[i];
                
                switch(
g_iAlone[iPlayer])
                {
                    case 
1g_iVersus[iPlayer][V1]++;
                    
                    case 
2g_iVersus[iPlayer][V2]++;
                    
                    case 
3g_iVersus[iPlayer][V3]++;
                    
                    case 
4g_iVersus[iPlayer][V4]++;
                    
                    case 
5g_iVersus[iPlayer][V5]++;
                }
            }
        }
    }
}

public 
ev_RoundStart()
{
    if(
get_pcvar_num(p_iStats))
    {
        new 
iPlayers[32];
        
get_players(iPlayers,g_iAlive[CS_TEAM_T],"aeh","TERRORIST");
        
get_players(iPlayers,g_iAlive[CS_TEAM_CT],"aeh","CT");
        
        
arrayset (g_iAlone,0,sizeof(g_iAlone));
    }
}

stock IsAlone(id// thanks to guipatinador
{
    if(!
is_user_alive(id)) return 0;
    
    new 
szTeam[12];
    
    if(
<= get_user_team(id,szTeam,charsmax(szTeam)) <= 2)
    {
        new 
Players[32],iNum;
        
get_players(Players,iNum,"ae",szTeam);
        
        return (
iNum == 1) ? 0;
    }

    return 
0;

Thanks.


Ps. Solved.
Attached Files
File Type: sma Get Plugin or Get Source (stats2.sma - 495 views - 2.8 KB)
__________________
Projects:

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

Last edited by ^SmileY; 08-09-2013 at 22:51.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 15:56.


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