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

Solved [CSGO REQ] Remaining Players Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
sHoC
Senior Member
Join Date: Nov 2015
Location: Italy
Old 06-23-2018 , 12:00   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #11

Quote:
Originally Posted by mug1wara View Post
You could just remove the index of the global variable if you want all players kills to be shown.

For hud:
PHP Code:
#include <sourcemod>

int g_iKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_Death);
    
    
HookEvent("round_end"Event_End);
}

public 
void OnGameFrame()
{
    
SetHudTextParams(0.50.51.01125510);
    
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
int iCount GetAlivePlayersCount();
            
            
ShowHudText(i1"Remaining players: %s Kills: %s"iCountg_iKills[i]);
        }
    }
}

public 
Action Event_Death(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iAttacker hEvent.GetInt("attacker");
    
    
g_iKills[iAttacker]++;
}

public 
Action Event_End(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iClient GetClientOfUserId(hEvent.GetInt("userid"));
    
    
g_iKills[iClient] = 0;
}

stock int GetAlivePlayersCount()
{
    
int iCount;
    
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
            
iCount++;
    }
    
    return 
iCount;

this version dosent work, remaining players and kills dosent show nothing. if I switch %s with %d for both, there will be showing the number of players alive but when I make a kill still 0 kills
__________________
sHoC is offline
KlausLaw
AlliedModders Donor
Join Date: Feb 2018
Location: Israel
Old 06-23-2018 , 12:49   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #12

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


int g_Kills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("player_death"Event_PlayerDeath);
    
CreateTimer(1.0Timer_HudMsg_TIMER_REPEAT);
}


public 
Action Event_PlayerDeath(Handle event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
g_Kills[attacker]++;
    return 
Plugin_Continue;
}

public 
Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
g_Kills[i] = 0;
    }
    return 
Plugin_Continue;
}

public 
Action Timer_HudMsg(Handle timer)
{
    static 
int iAlivePlayers;
    
iAlivePlayers 0;
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i) || !IsPlayerAlive(i))continue;
        
iAlivePlayers++;
    }
    
SetHudTextParams(0.40.21.02225210);
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i))continue;
        
ShowHudText(i1"Remaining players: %d\nKills: %d"iAlivePlayersg_Kills[i]);
    }

Enjoy
__________________
Taking private requests


Last edited by KlausLaw; 06-23-2018 at 12:49.
KlausLaw is offline
KlausLaw
AlliedModders Donor
Join Date: Feb 2018
Location: Israel
Old 06-23-2018 , 12:55   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #13

And @mug1wara
1.You can't get a client from round end.
2.You are wasting so many resources, you are doing a loop inside a loop on every frame.
You don't have to get the amount of alive players on every client in the loop, you can just get it outside the loop, and you don't have to do it on every frame, it's just a waste.
__________________
Taking private requests


Last edited by KlausLaw; 06-23-2018 at 12:57.
KlausLaw is offline
sHoC
Senior Member
Join Date: Nov 2015
Location: Italy
Old 06-23-2018 , 13:08   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #14

Quote:
Originally Posted by KlausLaw View Post
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>


int g_Kills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("player_death"Event_PlayerDeath);
    
CreateTimer(1.0Timer_HudMsg_TIMER_REPEAT);
}


public 
Action Event_PlayerDeath(Handle event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
g_Kills[attacker]++;
    return 
Plugin_Continue;
}

public 
Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
g_Kills[i] = 0;
    }
    return 
Plugin_Continue;
}

public 
Action Timer_HudMsg(Handle timer)
{
    static 
int iAlivePlayers;
    
iAlivePlayers 0;
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i) || !IsPlayerAlive(i))continue;
        
iAlivePlayers++;
    }
    
SetHudTextParams(0.40.21.02225210);
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i))continue;
        
ShowHudText(i1"Remaining players: %d\nKills: %d"iAlivePlayersg_Kills[i]);
    }

Enjoy
I tested it, when I make a kill its still 0 the number of kills
__________________

Last edited by sHoC; 06-23-2018 at 13:13.
sHoC is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 06-23-2018 , 13:12   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #15

Me doing a loop inside a loop, so do you. ^^ I'd still use OnGameFrame, works fine for me. Also didn't know you couldn't get client index from round_end? Better check on wiki again thanks.
@shoc

Use this, tested and working.
PHP Code:
#include <sourcemod>

int g_iKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_Death);
    
    
HookEvent("round_end"Event_End);
}

public 
void OnGameFrame()
{
    
SetHudTextParams(-1.00.40.1125510);
    
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
int iCount GetAlivePlayersCount();
            
            
ShowHudText(i1"Remaining players: %i | Kills: %i"iCountg_iKills[i]);
        }
    }
}

public 
Action Event_Death(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iAttacker GetClientOfUserId(hEvent.GetInt("attacker"));
    
    
g_iKills[iAttacker]++;
}

public 
Action Event_End(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
        
g_iKills[i] = 0;
}

stock int GetAlivePlayersCount()
{
    
int iCount
    
    for (
int i 1<= MaxClientsi++) 
    { 
        if (
IsClientInGame(i) && IsPlayerAlive(i)) 
            
iCount++; 
    } 
    
    return 
iCount


Last edited by mug1wara; 06-23-2018 at 13:24.
mug1wara is offline
KlausLaw
AlliedModders Donor
Join Date: Feb 2018
Location: Israel
Old 06-23-2018 , 13:39   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #16

Maybe you did something wrong, just download the plugin.
Maybe you tested it with 1 player? because if you kill him, it will trigger round end, and then the kills will get reset.
I can make it to reset on round start if you'd like.

and mug1wara, i'm not doing an inside loop.
You are doing a loop to get the alive players amount inside the loop to show the hud.
What i'm doing, is to get the alive players amount, and then i'm doing a loop to show the hud, HUGE DIFFERENCE.
Attached Files
File Type: sp Get Plugin or Get Source (alivePlayers.sp - 125 views - 1.4 KB)
__________________
Taking private requests


Last edited by KlausLaw; 06-23-2018 at 13:43.
KlausLaw is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 06-23-2018 , 13:53   Re: [CSGO REQ] Remaining Players Plugin
Reply With Quote #17

ok fine ):<

Last edited by mug1wara; 06-23-2018 at 13:53.
mug1wara is offline
Reply


Thread Tools
Display Modes

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 20:47.


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