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

[CSGO]Help with plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sajmooooon
Senior Member
Join Date: Nov 2018
Location: Slovakia
Old 03-24-2020 , 17:11   [CSGO]Help with plugin
Reply With Quote #1

Hi, I was trying to make plugin to hintprint message if CT< T, but somehow it doesn't work, can someone help me with that ?
Code:
public OnPluginStart()
{
    HookEvent("round_start",Event_RoundStart, EventHookMode_PostNoCopy);
}

stock int GetTeamPlayers(int team)
{
    int number = 0;
    for (new i=1; i<=MaxClients; i++)
    {
        if (IsPlayerAlive(i) && GetClientTeam(i) == team) 
            number++;
    }
    return number;
} 

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	int TCount = GetTeamPlayers(2);
        int CTCount = GetTeamPlayers(3);
	if (CTCount < TCount)
	{
		PrintHintTextToAll("Only <font color='#ff0000'>A plant</font>");
	} 
}

Last edited by Sajmooooon; 03-24-2020 at 17:12.
Sajmooooon is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-24-2020 , 20:59   Re: [CSGO]Help with plugin
Reply With Quote #2

Quote:
Originally Posted by Sajmooooon View Post
Hi, I was trying to make plugin to hintprint message if CT< T, but somehow it doesn't work, can someone help me with that ?
Code:
public OnPluginStart()
{
    HookEvent("round_start",Event_RoundStart, EventHookMode_PostNoCopy);
}

stock int GetTeamPlayers(int team)
{
    int number = 0;
    for (new i=1; i<=MaxClients; i++)
    {
        if (IsPlayerAlive(i) && GetClientTeam(i) == team) 
            number++;
    }
    return number;
} 

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	int TCount = GetTeamPlayers(2);
        int CTCount = GetTeamPlayers(3);
	if (CTCount < TCount)
	{
		PrintHintTextToAll("Only <font color='#ff0000'>A plant</font>");
	} 
}
check your error logs and you'll know why
__________________
8guawong is offline
Sajmooooon
Senior Member
Join Date: Nov 2018
Location: Slovakia
Old 03-25-2020 , 03:52   Re: [CSGO]Help with plugin
Reply With Quote #3

Exception reported: Client 12 is not in game
[SM] Exception reported: Client 2 is not in game
Sajmooooon is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-25-2020 , 04:21   Re: [CSGO]Help with plugin
Reply With Quote #4

Quote:
Originally Posted by Sajmooooon View Post
Exception reported: Client 12 is not in game
[SM] Exception reported: Client 2 is not in game
exactly so you have to check if client is in game before checking if the client is alive
__________________
8guawong is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 03-25-2020 , 05:16   Re: [CSGO]Help with plugin
Reply With Quote #5

updated to new syntax and added IsClientInGame as 8guawong said.
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("round_start",Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void Event_RoundStart(Handle  event, const char[]  namebool  dontBroadcast)
{
    
int TCount GetTeamPlayers(2);
    
int CTCount GetTeamPlayers(3);
    if (
CTCount TCount)
    {
        
PrintHintTextToAll("Only <font color='#ff0000'>A plant</font>");
    }
}

stock int GetTeamPlayers(int team)
{
    
int number 0;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == team)
            
number++;
    }
    return 
number;


Last edited by iskenderkebab33; 03-26-2020 at 16:52.
iskenderkebab33 is offline
Sajmooooon
Senior Member
Join Date: Nov 2018
Location: Slovakia
Old 03-25-2020 , 08:23   Re: [CSGO]Help with plugin
Reply With Quote #6

Oh my bad, thanks for help
Sajmooooon is offline
Sajmooooon
Senior Member
Join Date: Nov 2018
Location: Slovakia
Old 03-25-2020 , 10:02   Re: [CSGO]Help with plugin
Reply With Quote #7

Quote:
Originally Posted by iskenderkebab33 View Post
updated to new syntax and added IsClientInGame as 8guawong said.
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("round_start",Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void Event_RoundStart(Handle  event, const char[]  namebool  dontBroadcast)
{
    
int TCount GetTeamPlayers(2);
    
int CTCount GetTeamPlayers(3);
    if (
CTCount TCount)
    {
        
PrintHintTextToAll("Only <font color='#ff0000'>A plant</font>");
    }
}

stock int GetTeamPlayers(int team)
{
    
int number 0;
    for (
int i 0MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == team)
            
number++;
    }
    return 
number;

L 03/25/2020 - 14:11:45: [SM] Call stack trace:
L 03/25/2020 - 14:11:45: [SM] [0] IsClientInGame
L 03/25/2020 - 14:11:45: [SM] [1] Line 26, plugin.sp::GetTeamPlayers
L 03/25/2020 - 14:11:45: [SM] [2] Line 13, plugin.sp::Event_RoundStart
L 03/25/2020 - 14:12:55: [SM] Exception reported: Client index 0 is invalid
Sajmooooon is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-25-2020 , 10:23   Re: [CSGO]Help with plugin
Reply With Quote #8

Quote:
Originally Posted by Sajmooooon View Post
L 03/25/2020 - 14:11:45: [SM] Call stack trace:
L 03/25/2020 - 14:11:45: [SM] [0] IsClientInGame
L 03/25/2020 - 14:11:45: [SM] [1] Line 26, plugin.sp::GetTeamPlayers
L 03/25/2020 - 14:11:45: [SM] [2] Line 13, plugin.sp::Event_RoundStart
L 03/25/2020 - 14:12:55: [SM] Exception reported: Client index 0 is invalid
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("round_start",Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void Event_RoundStart(Handle  event, const char[]  namebool  dontBroadcast)
{
    
int TCount GetTeamPlayers(2);
    
int CTCount GetTeamPlayers(3);
    if (
CTCount TCount)
    {
        
PrintHintTextToAll("Only <font color='#ff0000'>A plant</font>");
    }
}

stock int GetTeamPlayers(int team)
{
    
int number 0;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == team)
            
number++;
    }
    return 
number;

__________________
8guawong is offline
Sajmooooon
Senior Member
Join Date: Nov 2018
Location: Slovakia
Old 03-25-2020 , 14:22   Re: [CSGO]Help with plugin
Reply With Quote #9

Quote:
Originally Posted by 8guawong View Post
PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("round_start",Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void Event_RoundStart(Handle  event, const char[]  namebool  dontBroadcast)
{
    
int TCount GetTeamPlayers(2);
    
int CTCount GetTeamPlayers(3);
    if (
CTCount TCount)
    {
        
PrintHintTextToAll("Only <font color='#ff0000'>A plant</font>");
    }
}

stock int GetTeamPlayers(int team)
{
    
int number 0;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == team)
            
number++;
    }
    return 
number;

Thanks
Sajmooooon 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 12:03.


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