Raised This Month: $51 Target: $400
 12% 

Solved CS:S Ace - ANNOUNCEMENT - PROBLEM


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kshishu
Junior Member
Join Date: Mar 2016
Location: Opole
Old 03-09-2017 , 10:17   CS:S Ace - ANNOUNCEMENT - PROBLEM
Reply With Quote #1

Hello,

I have a problem with my script which is almost working...

The question is: is this plugin correctly counting kills? why is not printing to chat the player who got 5kills or 6kills.

My server is WAR - mixes/cw - this server is for people and I want to give them some surprise.
This server is for 6on6 or 5on5 and I want to have some announcement about ACE.

Code:
#pragma semicolon 1

#include <cstrike>
#include <morecolors>
#include <sourcemod>
#include <sdktools>

new Handle:sm_war_live;
new kills[MAXPLAYERS+1];

public Plugin myinfo = 
{
    name = "MD TEST",
    author = "Leon Le Professionnel",
    description = "Testing scripts .",
    version = "1.0",
    url = "http://www.martwy-dystrykt.pl"
};

public OnPluginStart()
{
    HookEvent("player_disconnect", Event_PlayerDisconnect);
    HookEvent("player_death", Event_PlayerDeath);
    HookEvent("round_end",Event_RoundEndEvent);
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (GetConVarInt(sm_war_live) == 1)
    {
        new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));

        if(attacker == 0)
        {
            return;
        }

        new victim = GetClientOfUserId(GetEventInt(event, "userid"));

        if(GetClientTeam(attacker) != GetClientTeam(victim)
        {
            kills[attacker]++;
        }
    }
}

public Event_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (GetConVarInt(sm_war_live) == 1)
    {
        new attacker = GetClientOfUserId(GetEventInt(event, "userid"));

        kills[attacker] = 0;
    }
}


public RoundStartEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    if (GetConVarInt(sm_war_live) == 1)
    {
        for(new i = 1; i < MAXPLAYERS; i++)
        {
            kills[i] = 0;
        }
    }
}

public Event_RoundEndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    if (GetConVarInt(sm_war_live) == 1)
    {
        new acer6 = 0;
        new acer5 = 0;
        
        for(new i = 1; i < MaxClients; i++)
        if(kills[i] == 6)
        {
            acer6 = i;
        }
        
        for(new i = 1; i < MaxClients; i++)
        if(kills[i] == 5)
        {
            acer5 = i;
        }
        
        decl String:iname6[MAX_NAME_LENGTH];
        GetClientName(acer6, iname6, sizeof(iname6));
        
        for(new i = 1; i < MaxClients; i++)
        if (IsClientInGame(i) && kills[i] == 6)
        {
            CPrintToChatAll("{green}[MD INFO] {default}Player {frozen}%N {default} Did an 6 ACE!", iname6);
        }
        
        decl String:iname5[MAX_NAME_LENGTH];
        GetClientName(acer5, iname5, sizeof(iname5));
        
        for(new i = 1; i < MaxClients; i++)
        if (IsClientInGame(i) && kills[i] == 5)
        {
            CPrintToChatAll("{green}[MD INFO] {default}Player {frozen}%N {default} Did an 5 ACE!", iname5);
        }
    }
}
__________________




Last edited by kshishu; 03-09-2017 at 11:21.
kshishu is offline
Send a message via Skype™ to kshishu
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-09-2017 , 11:01   Re: CS:S Ace - ANNOUNCEMENT - PROBLEM
Reply With Quote #2

I'll write it out for you.

EDIT: Try this:

PHP Code:
#include <cstrike>
#include <morecolors>
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

//Handles
Handle sm_war_live;

//Integers
int g_iRoundKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
sm_war_live CreateConVar("sm_war_live""1""War");

    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("round_start"RoundStartEvent);
    
HookEvent("round_end",Event_RoundEndEvent);
}

public 
void OnClientDisconnect(int iClient)
{
    
g_iRoundKills[iClient] = 0;
}

public 
Action Event_PlayerDeath(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iAttacker GetClientOfUserId(GetEventInt(hEvent"attacker"));
    
int iVictim GetClientOfUserId(GetEventInt(hEvent"userid"));

    if(!
IsValidClient(iAttacker) || !IsValidClient(iVictim))
    {
        return 
Plugin_Continue;
    }
    
    if(
GetClientTeam(iAttacker) != GetClientTeam(iVictim))
    {
        
g_iRoundKills[iAttacker]++;
    }
}

public 
Action RoundStartEvent(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    for(
int i 1<= MAXPLAYERSi++)
    {
        
g_iRoundKills[i] = 0;
    }
}

public 
Action Event_RoundEndEvent(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (
GetConVarBool(sm_war_live))
    {
        
int Acer;
    
        for(
int i 1<= MaxClientsi++)
        {
            if(
g_iRoundKills[i] >= 5)
            {
                
Acer i;
                
                break;
            }
        }
        
        if(!
IsValidClient(Acer))
        {
            return 
Plugin_Continue;
        }

        
CPrintToChatAll("{green}[MD INFO] {default}Player {frozen}%N {default} aced the round!"Acer);
    }
    
    return 
Plugin_Continue;


Last edited by Weetabix; 03-09-2017 at 11:13.
Weetabix is offline
kshishu
Junior Member
Join Date: Mar 2016
Location: Opole
Old 03-09-2017 , 11:21   Re: CS:S Ace - ANNOUNCEMENT - PROBLEM
Reply With Quote #3

+ FOR YOU

Thank you

@Solved
__________________



kshishu is offline
Send a message via Skype™ to kshishu
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 17:33.


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