Raised This Month: $32 Target: $400
 8% 

[CS:GO] Hns EasyBlock Team Swap After 5


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Audite
AlliedModders Donor
Join Date: Sep 2021
Location: Sweden
Old 08-06-2022 , 16:40   [CS:GO] Hns EasyBlock Team Swap After 5
Reply With Quote #1

Simple plugin.

Let's start with that I would pay some amount for this.

Plugin should track if T side havent changed in 5 rounds, then swap the teams. But if the CT won and got swapped, reset the counter.

My Discord: Audite#0769

Audite is offline
Cruze
Veteran Member
Join Date: May 2017
Old 08-07-2022 , 16:48   Re: [CS:GO] Hns EasyBlock Team Swap After 5
Reply With Quote #2

Try this
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

int g_iWins 0;
const 
int g_iRound 5;

public 
Plugin myinfo =

    
name "Swap Teams"
    
author "Cruze",  
    
description "Swap Teams if T wins X number of rounds consecutively.",  
    
version "1.0",  
    
url "www.github.com/cruze03" 


public 
void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEnd);
    
    
HookUserMessage(GetUserMessageId("TextMsg"), Hook_TextMsg);
}

public 
void OnMapStart()
{
    
g_iWins 0;
}


public 
Action Hook_TextMsg(UserMsg umIdHandle hMsg, const int[] iPlayersint iPlayersNumbool bReliablebool bInit)
{
    
char name[40], szValue[40]; 
    
PbReadString(hMsg"params"szValuesizeof(szValue), 1);
    
PbReadString(hMsg"params"namesizeof(name), 0);   
    if(
strcmp(name"#SFUI_Notice_Game_will_restart_in"false) == 0)
    {
        
CreateTimer(StringToFloat(szValue), Timer_GameRestarted);
    }
    return 
Plugin_Continue;
}

public 
Action Timer_GameRestarted(Handle timer)
{
    
g_iWins 0;
}

public 
void Event_RoundEnd(Event ev, const char[] namebool dbc)
{
    
int winner ev.GetInt("winner");
    if(
winner == 2)
    {
        
g_iWins++;
    }
    else if(
winner == 3)
    {
        
g_iWins 0;
    }
    if(
g_iWins >= g_iRound)
    {
        
SwapTeams();
        
g_iWins 0;
    }
}

void SwapTeams()
{
    
int clientteam;
    
    for(
client 1client <= MaxClientsclient++)
    {
        if(!
IsClientInGame(client))
        {
            continue;
        }
        
team GetClientTeam(client);
        if(
team == 2)
        {
            
CS_SwitchTeam(client3);
        }
        else if(
team == 3)
        {
            
CS_SwitchTeam(client2);
        }
    }
    
PrintToChatAll("[SM] Terrorists have won %i rounds consecutively. Swapping teams."g_iRound);

__________________
Taking paid private requests! Contact me
Cruze 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 21:58.


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