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

Solved CS:GO end round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 09-22-2018 , 17:07   CS:GO end round
Reply With Quote #1

Hey, as the titel says, if someone gets X Kills (example, 3 Kills) the plugin will end the round.

Thanks!

Last edited by iskenderkebab33; 11-03-2018 at 17:27.
iskenderkebab33 is offline
Vaggelis
Senior Member
Join Date: May 2017
Old 09-22-2018 , 17:38   Re: CS:GO x Kills = end round
Reply With Quote #2

Untested, at CS_TerminateRound the 5.0 is the delay before new round starts and the CSRoundEnd_Draw is the reason (you can change it of course). Here all all the reasons: https://sm.alliedmods.net/new-api/cs...RoundEndReason
PHP Code:
#include <sourcemod>
#include <cstrike>

#define KILLS 3

new g_Kills[MAXPLAYERS 1]

public 
OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart)
    
HookEvent("player_death"Event_PlayerDeath)
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for(new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
        {
            
g_Kills[i] = 0
        
}
    }
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"))
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"))
    
    if(
attacker && IsClientInGame(attacker) && attacker != victim)
    {
        
g_Kills[attacker]++
        
        if(
g_Kills[attacker] >= KILLS)
        {
            
CS_TerminateRound(5.0CSRoundEnd_Draw)
        }
    }

Vaggelis is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 09-22-2018 , 17:45   Re: CS:GO x Kills = end round
Reply With Quote #3

Quote:
Originally Posted by Vaggelis View Post
Untested, at CS_TerminateRound the 5.0 is the delay before new round starts and the CSRoundEnd_Draw is the reason (you can change it of course). Here all all the reasons: https://sm.alliedmods.net/new-api/cs...RoundEndReason
PHP Code:
#include <sourcemod>
#include <cstrike>

#define KILLS 3

new g_Kills[MAXPLAYERS 1]

public 
OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart)
    
HookEvent("player_death"Event_PlayerDeath)
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for(new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
        {
            
g_Kills[i] = 0
        
}
    }
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"))
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"))
    
    if(
attacker && IsClientInGame(attacker) && attacker != victim)
    {
        
g_Kills[attacker]++
        
        if(
g_Kills[attacker] >= KILLS)
        {
            
CS_TerminateRound(5.0CSRoundEnd_Draw)
        }
    }

working, many thanks.
iskenderkebab33 is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 09-23-2018 , 15:55   Re: CS:GO x Kills = end round
Reply With Quote #4

Quote:
Originally Posted by Vaggelis View Post
Untested, at CS_TerminateRound the 5.0 is the delay before new round starts and the CSRoundEnd_Draw is the reason (you can change it of course). Here all all the reasons: https://sm.alliedmods.net/new-api/cs...RoundEndReason
PHP Code:
#include <sourcemod>
#include <cstrike>

#define KILLS 3

new g_Kills[MAXPLAYERS 1]

public 
OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart)
    
HookEvent("player_death"Event_PlayerDeath)
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for(new 
1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
        {
            
g_Kills[i] = 0
        
}
    }
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"))
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"))
    
    if(
attacker && IsClientInGame(attacker) && attacker != victim)
    {
        
g_Kills[attacker]++
        
        if(
g_Kills[attacker] >= KILLS)
        {
            
CS_TerminateRound(5.0CSRoundEnd_Draw)
        }
    }

@Vaggelis can you add also a PrintToChat with the message, Player <NAME> reached 3 Kills and ended the round
iskenderkebab33 is offline
Vaggelis
Senior Member
Join Date: May 2017
Old 09-23-2018 , 16:20   Re: CS:GO x Kills = end round
Reply With Quote #5

After CS_TerminateRound(5.0, CSRoundEnd_Draw) add this: PrintToChatAll("%N reached %d kills and ended the round", attacker)
Vaggelis is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 09-23-2018 , 16:29   Re: CS:GO x Kills = end round
Reply With Quote #6

Quote:
Originally Posted by Vaggelis View Post
After CS_TerminateRound(5.0, CSRoundEnd_Draw) add this: PrintToChatAll("%N reached %d kills and ended the round", attacker)
not working :/
iskenderkebab33 is offline
Vaggelis
Senior Member
Join Date: May 2017
Old 09-23-2018 , 16:32   Re: CS:GO x Kills = end round
Reply With Quote #7

Quote:
Originally Posted by iskenderkebab33 View Post
not working :/
Whats the error?
Vaggelis is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 09-23-2018 , 16:52   Re: CS:GO x Kills = end round
Reply With Quote #8

Quote:
Originally Posted by Vaggelis View Post
Whats the error?
no error, just not showing
iskenderkebab33 is offline
Vaggelis
Senior Member
Join Date: May 2017
Old 09-23-2018 , 16:53   Re: CS:GO x Kills = end round
Reply With Quote #9

Quote:
Originally Posted by iskenderkebab33 View Post
no error, just not showing
Sorry i forgot something, do it like this: PrintToChatAll("%N reached %d kills and ended the round", attacker, KILLS)
Vaggelis 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 11:38.


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