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

A way to reference two variables to get one result?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SNCurti
Member
Join Date: Feb 2016
Old 05-26-2016 , 22:40   A way to reference two variables to get one result?
Reply With Quote #1

Hi, I'm looking for a way to get some kind of way to plug in two client indexes and spit out a single stored result. How would I make this array (if an array is the solution) and how would it work.
Basically, lets say a player is hurt.
You have the victim and the attacker.
You plug the attacker in and the victim in and you get a variable stored by inputting two variables, similar to an array but you're using 1 variable in an array, 2 variables in this. If you change the attacker, the data stored for that specific victim is changed because the attacker is different and the victim is the same, so whatever is stored there is unique to both of them and can only be accessed by having both indexes correct, in a sense. It's like you have a grid, and you do (2,2). You get what is in that point. Now you do (3,2) and it's a different variable, and you do (2,3) and (2,2) and that's another variable that differs. That's what I mean.
Anyone know how?
I'd appreciate it a bunch.
SNCurti is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 05-26-2016 , 22:58   Re: A way to reference two variables to get one result?
Reply With Quote #2

Perhaps what you're looking for is a multi-dimensional array?

Code:
float g_Damage[MAXPLAYERS+1][MAXPLAYERS+1];

// in some function body
float a, b, c;
a = g_Damage[2][2];
b = g_Damage[3][2];
c = g_Damage[2][3];
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
SNCurti
Member
Join Date: Feb 2016
Old 05-27-2016 , 15:46   Re: A way to reference two variables to get one result?
Reply With Quote #3

Quote:
Originally Posted by nosoop View Post
Perhaps what you're looking for is a multi-dimensional array?

Code:
float g_Damage[MAXPLAYERS+1][MAXPLAYERS+1];

// in some function body
float a, b, c;
a = g_Damage[2][2];
b = g_Damage[3][2];
c = g_Damage[2][3];
I tried this but it didn't seem to work, can I show you the code?
Code:
#include <sourcemod>
#include <sdktools_functions>
#include <entity>
#pragma semicolon 1
int finalDamage[MAXPLAYERS+1] = 0;
int AttackerVictimInfo[MAXPLAYERS+1][MAXPLAYERS+1][3];
public Plugin sm_reap =
{
	name = "sm_reap",
	author = "SNC",
	description = "Reap plugin, health to victims from attackers.",
	version = "1.0",
	url = "http://sg-gaming.net/"
};
public OnPluginStart()
{
    // Create reap command
	LoadTranslations("common.phrases.txt");
	RegAdminCmd("sm_reap", cmd_Reap, ADMFLAG_UNBAN);
	HookEvent("player_hurt", OnPlayerHurt);
	HookEvent("teamplay_round_start", OnRoundStart);
	HookEvent("teamplay_game_over", OnRoundEnd);
	HookEvent("player_death", OnPlayerDeath);
}
public Action cmd_Reap(int client, int args)
{
	int arguments = GetCmdArgs();
	int reapedHealth;
	if (arguments == 1 || arguments == 2)
	{
		int timeNow = GetTime();
		PrintToChatAll("%i", timeNow);
		char arg1[64]; // Get argument (player who will be reaped(who's health will be taken from))
		GetCmdArg(1, arg1, sizeof(arg1));
		int clienttaken = FindTarget(client, arg1, false, false);
		if (clienttaken != -1 || clienttaken != 0 || IsPlayerAlive(clienttaken) || IsClientInGame(clienttaken)) // Ruling out invalid clients
		{
			reapedHealth = GetClientHealth(clienttaken);
			if (args == 1)
			{
				for (int i = 1; i <= MaxClients; i++) // For loop giving each player hurt by the person being reaped health back
				{
					PrintToChatAll("%i", AttackerVictimInfo[clienttaken][i][1]);
					if (IsClientInGame(i) && IsPlayerAlive(i))
					{
						if ((timeNow - AttackerVictimInfo[clienttaken][i][1]) >= 60)
						{
							AttackerVictimInfo[clienttaken][i][2] = 0;
						}
						else if ((timeNow - AttackerVictimInfo[clienttaken][i][1]) < 60)
						{
							finalDamage[clienttaken] = AttackerVictimInfo[clienttaken][i][2] + finalDamage[clienttaken];
							int clientHealth = GetClientHealth(i);
							int clientMaxHealth = GetEntProp(i, Prop_Send, "m_iMaxHealth");
							if (AttackerVictimInfo[clienttaken][i][2] + clientHealth > clientMaxHealth)
							{
								if (clientMaxHealth < 400 || clientMaxHealth > 0) // Just a check on health boundaries
								{
									SetEntityHealth(i, clientMaxHealth); // Setting health to full
								}
							}
							else
							{
								SetEntityHealth(i, AttackerVictimInfo[clienttaken][i][2] + clientHealth); //Setting player health
							}
						}
					}
				}
				ShowActivity2(client, "[SM] ", "Player %N has been reaped. All players that have taken damage from %N have been restored.", clienttaken, clienttaken);
				if (reapedHealth > finalDamage[clienttaken])
				{
					SetEntityHealth(clienttaken, reapedHealth - finalDamage[clienttaken]);
				}
				else if (reapedHealth <= finalDamage[clienttaken])
				{
					ForcePlayerSuicide(clienttaken);
				}
			}	
			else if (args == 2)
			{
				char arg2[64]; // Get argument (player who will be given health from reaped player), if none give back to all
				GetCmdArg(2, arg2, sizeof(arg2));
				int clientgiven = FindTarget(client, arg2, false, false);
				if (clientgiven != -1 || clientgiven != 0 || IsPlayerAlive(clientgiven) || IsClientInGame(clientgiven))
				{
					PrintToChatAll("%i", AttackerVictimInfo[clienttaken][clientgiven][1]);
					if ((timeNow - AttackerVictimInfo[clienttaken][clientgiven][1]) >= 60)
					{
						AttackerVictimInfo[clienttaken][clientgiven][2] = 0;
						ShowActivity2(client, "[SM] ", "Invalid target(s). Time hurt out of bounds.");
						return Plugin_Handled;
					}
					else if ((timeNow - AttackerVictimInfo[clienttaken][clientgiven][1]) < 60)
					{
						if (reapedHealth > AttackerVictimInfo[clienttaken][clientgiven][2])
						{
							SetEntityHealth(clienttaken, reapedHealth - AttackerVictimInfo[clienttaken][clientgiven][2]);
						}
						else if (reapedHealth <= AttackerVictimInfo[clienttaken][clientgiven][2])
						{
							ForcePlayerSuicide(clienttaken);
						}
						SlapPlayer(clienttaken, AttackerVictimInfo[clienttaken][clientgiven][2]); // Hurting reaped player
						int clientHealth = GetClientHealth(clientgiven); //Getting health of player being given health
						int clientMaxHealth = GetEntProp(clientgiven, Prop_Send, "m_iMaxHealth");
						if ((AttackerVictimInfo[clienttaken][clientgiven][2] + clientHealth) > clientMaxHealth)
						{
							if (clientMaxHealth < 400 || clientMaxHealth > 0) // Just a check on health boundaries
							{
								SetEntityHealth(clientgiven, clientMaxHealth); // Setting health to full
							}
						}
						else
						{
							SetEntityHealth(clientgiven, AttackerVictimInfo[clienttaken][clientgiven][2] + clientHealth);
						}
						ShowActivity2(client, "[SM] ", "Admin %N used reap on %N. %N has been reaped. The health has been given to %N.", client, clienttaken, clienttaken, clientgiven); // For logging
					}
				}
				else 
				{
					return Plugin_Handled;
				}
			}
		}
		else
		{
			return Plugin_Handled;
		}
	}
	else if (args <= 0 || args > 2)
	{
		ShowActivity2(client, "[SM] ", "Proper usage: sm_reap <name> <name> or sm_reap <name>"); // For logging
	}
	return Plugin_Handled;
}
public Action OnPlayerHurt(Event event, const char[] name, bool dontBroadcast)
{
	int attackerIndex = GetClientOfUserId(GetEventInt(event, "attacker", 0));
	int victimIndex = GetClientOfUserId(GetEventInt(event, "userid", 0));
	if (attackerIndex != 1 && attackerIndex != 0 && victimIndex != 1 && victimIndex != 0 && IsClientInGame(attackerIndex) && IsClientInGame(victimIndex))
	{
		AttackerVictimInfo[attackerIndex][victimIndex][1] = GetTime();
		AttackerVictimInfo[attackerIndex][victimIndex][2] = AttackerVictimInfo[attackerIndex][victimIndex][2] + GetEventInt(event, "damageamount", 0);
	}
}
public Action OnRoundStart(Event event, const char[] name, bool dontBroadcast)
{
    for (int i = 1; i <= MaxClients; i++)
    {
        // Just resetting some stuff
        finalDamage[i] = 0;
        for (int j = 1; j <= MaxClients; j++)
        {
            AttackerVictimInfo[i][j][2] = 0;
        }
    }
}
public Action OnRoundEnd(Event event, const char[] name, bool dontBroadcast)
{
	for (int i = 1; i <= MaxClients; i++)
    {
        // Just resetting some stuff
        finalDamage[i] = 0;
        for (int j = 1; j <= MaxClients; j++)
        {
            AttackerVictimInfo[i][j][2] = 0; AttackerVictimInfo[i][j][1] = 0;	
        }
    }
}
public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int deadPlayer = GetClientOfUserId(GetEventInt(event, "userid", 0));
	for (int i = 1; i <= MaxClients; i++)
	{
		AttackerVictimInfo[deadPlayer][i][2] = 0; AttackerVictimInfo[deadPlayer][i][1] = 0;	
	}
}

Last edited by SNCurti; 05-27-2016 at 15:47.
SNCurti is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-28-2016 , 12:59   Re: A way to reference two variables to get one result?
Reply With Quote #4

In your case you'd want to client variables.

A variable for who the player is "reaping" from,
A variable for the player who is being "reaped"
etc.

I'm pretty tired and can't see too well at the moment, but have you done any looking into
-ADT_Array
-ADT_Trie
-ADT_Stack

It just looks to me like a pretty standard case of making something more complicated than it has to be.

Edit: About your original post, you can use a variable inside of an array index.
PHP Code:
g_clientProp[client] = 50;
g_props[clientProp[client]] = 9
Something like that might be something you're looking for?

Last edited by sdz; 05-28-2016 at 13:06.
sdz is offline
SNCurti
Member
Join Date: Feb 2016
Old 05-28-2016 , 14:31   Re: A way to reference two variables to get one result?
Reply With Quote #5

Quote:
Originally Posted by EasSidezz View Post
In your case you'd want to client variables.

A variable for who the player is "reaping" from,
A variable for the player who is being "reaped"
etc.

I'm pretty tired and can't see too well at the moment, but have you done any looking into
-ADT_Array
-ADT_Trie
-ADT_Stack

It just looks to me like a pretty standard case of making something more complicated than it has to be.

Edit: About your original post, you can use a variable inside of an array index.
PHP Code:
g_clientProp[client] = 50;
g_props[clientProp[client]] = 9
Something like that might be something you're looking for?
Unfortunately I don't know if that helps, since I need to store 1 variable for 32 players who each can damage 32 players. So the issue is, I need to reference one player that hurts another player, and I need to also store the damage he can do to another 31 players at the same time, and there are another 31 players that have potential to damage players, so they each need 32 slots of players they can hurt and store that damage in.
I don't know if those arrays can help me.
SNCurti is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-29-2016 , 10:09   Re: A way to reference two variables to get one result?
Reply With Quote #6

Quote:
Originally Posted by SNCurti View Post
Unfortunately I don't know if that helps, since I need to store 1 variable for 32 players who each can damage 32 players. So the issue is, I need to reference one player that hurts another player, and I need to also store the damage he can do to another 31 players at the same time, and there are another 31 players that have potential to damage players, so they each need 32 slots of players they can hurt and store that damage in.
I don't know if those arrays can help me.
Yeah then a multidimensional array would be the only way.

edit: here I changed some stuff around which might have helped. idk.
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

int finalDamage[MAXPLAYERS 1] = {0, ...};
int AttackerVictimInfo[MAXPLAYERS 1][MAXPLAYERS 1][3];

public 
Plugin sm_reap =
{
    
name "sm_reap",
    
author "SNC",
    
description "Reap plugin, health to victims from attackers.",
    
version "1.0",
    
url "http://sg-gaming.net/"
};

public 
OnPluginStart()
{
    
// Create reap command
    
LoadTranslations("common.phrases.txt");
    
RegAdminCmd("sm_reap"cmd_ReapADMFLAG_UNBAN);
    
HookEvent("player_hurt"OnPlayerHurt);
    
HookEvent("teamplay_round_start"OnRoundStart);
    
HookEvent("teamplay_game_over"OnRoundEnd);
    
HookEvent("player_death"OnPlayerDeath);
}

public 
Action cmd_Reap(int clientint args)
{
    
int arguments GetCmdArgs();
    
int reapedHealth;
    if (
arguments == || arguments == 2)
    {
        
int timeNow GetTime();
        
PrintToChatAll("%i"timeNow);
        
char arg1[64]; // Get argument (player who will be reaped(who's health will be taken from))
        
GetCmdArg(1arg1sizeof(arg1));
        
int clienttaken FindTarget(clientarg1falsefalse);
        if (
clienttaken != -1)
        {
            
IsPlayerAlive(clienttaken) && IsClientInGame(clienttaken)) // Ruling out invalid clients
            
{
                
reapedHealth GetClientHealth(clienttaken);
                if (
args == 1)
                {
                    for (
int i 1<= MaxClientsi++) // For loop giving each player hurt by the person being reaped health back
                    
{
                        if (
IsClientInGame(i) && IsPlayerAlive(i))
                        {
                            
PrintToChatAll("%i"AttackerVictimInfo[clienttaken][i][1]);
                            if ((
timeNow AttackerVictimInfo[clienttaken][i][1]) >= 60)
                            {
                                
AttackerVictimInfo[clienttaken][i][2] = 0;
                            }
                            else if ((
timeNow AttackerVictimInfo[clienttaken][i][1]) < 60)
                            {
                                
finalDamage[clienttaken] = AttackerVictimInfo[clienttaken][i][2] + finalDamage[clienttaken];
                                
int clientHealth GetClientHealth(i);
                                
int clientMaxHealth GetEntProp(iProp_Send"m_iMaxHealth");
                                if (
AttackerVictimInfo[clienttaken][i][2] + clientHealth clientMaxHealth)
                                {
                                    if (
clientMaxHealth 400 || clientMaxHealth 0// Just a check on health boundaries
                                    
{
                                        
SetEntityHealth(iclientMaxHealth); // Setting health to full
                                    
}
                                }
                                else
                                {
                                    
SetEntityHealth(iAttackerVictimInfo[clienttaken][i][2] + clientHealth); //Setting player health
                                
}
                            }
                        }
                    }
                    
ShowActivity2(client"[SM] ""Player %N has been reaped. All players that have taken damage from %N have been restored."clienttakenclienttaken);
                    if (
reapedHealth finalDamage[clienttaken])
                    {
                        
SetEntityHealth(clienttakenreapedHealth finalDamage[clienttaken]);
                    }
                    else if (
reapedHealth <= finalDamage[clienttaken])
                    {
                        
ForcePlayerSuicide(clienttaken);
                    }
                }    
                else if (
args == 2)
                {
                    
char arg2[64]; // Get argument (player who will be given health from reaped player), if none give back to all
                    
GetCmdArg(2arg2sizeof(arg2));
                    
int clientgiven FindTarget(clientarg2falsefalse);
                    if (
clientgiven != -|| clientgiven != || IsPlayerAlive(clientgiven) || IsClientInGame(clientgiven))
                    {
                        
PrintToChatAll("%i"AttackerVictimInfo[clienttaken][clientgiven][1]);
                        if ((
timeNow AttackerVictimInfo[clienttaken][clientgiven][1]) >= 60)
                        {
                            
AttackerVictimInfo[clienttaken][clientgiven][2] = 0;
                            
ShowActivity2(client"[SM] ""Invalid target(s). Time hurt out of bounds.");
                            return 
Plugin_Handled;
                        }
                        else if ((
timeNow AttackerVictimInfo[clienttaken][clientgiven][1]) < 60)
                        {
                            if (
reapedHealth AttackerVictimInfo[clienttaken][clientgiven][2])
                            {
                                
SetEntityHealth(clienttakenreapedHealth AttackerVictimInfo[clienttaken][clientgiven][2]);
                            }
                            else if (
reapedHealth <= AttackerVictimInfo[clienttaken][clientgiven][2])
                            {
                                
ForcePlayerSuicide(clienttaken);
                            }
                            
SlapPlayer(clienttakenAttackerVictimInfo[clienttaken][clientgiven][2]); // Hurting reaped player
                            
int clientHealth GetClientHealth(clientgiven); //Getting health of player being given health
                            
int clientMaxHealth GetEntProp(clientgivenProp_Send"m_iMaxHealth");
                            if ((
AttackerVictimInfo[clienttaken][clientgiven][2] + clientHealth) > clientMaxHealth)
                            {
                                if (
clientMaxHealth 400 || clientMaxHealth 0// Just a check on health boundaries
                                
{
                                    
SetEntityHealth(clientgivenclientMaxHealth); // Setting health to full
                                
}
                            }
                            else
                            {
                                
SetEntityHealth(clientgivenAttackerVictimInfo[clienttaken][clientgiven][2] + clientHealth);
                            }
                            
ShowActivity2(client"[SM] ""Admin %N used reap on %N. %N has been reaped. The health has been given to %N."clientclienttakenclienttakenclientgiven); // For logging
                        
}
                    }
                    else 
                    {
                        return 
Plugin_Handled;
                    }
                }
            }
            else
            {
                return 
Plugin_Handled;
            }
        }
    }
    else if (
args <= || args 2)
    {
        
ShowActivity2(client"[SM] ""Proper usage: sm_reap <from> <to> or sm_reap <from>"); // For logging
    
}
    return 
Plugin_Handled;
}
public 
Action OnPlayerHurt(Event event, const char[] namebool dontBroadcast)
{
    
int attackerIndex GetClientOfUserId(GetEventInt(event"attacker"0));
    
int victimIndex GetClientOfUserId(GetEventInt(event"userid"0));
    if (
attackerIndex != && attackerIndex != && victimIndex != && victimIndex != && IsClientInGame(attackerIndex) && IsClientInGame(victimIndex))
    {
        
AttackerVictimInfo[attackerIndex][victimIndex][1] = GetTime();
        
AttackerVictimInfo[attackerIndex][victimIndex][2] = AttackerVictimInfo[attackerIndex][victimIndex][2] + GetEventInt(event"damageamount"0);
    }
}
public 
Action OnRoundStart(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
// Just resetting some stuff
        
finalDamage[i] = 0;
        for (
int j 1<= MaxClientsj++)
        {
            
AttackerVictimInfo[i][j][2] = 0;
        }
    }
}
public 
Action OnRoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
// Just resetting some stuff
        
finalDamage[i] = 0;
        for (
int j 1<= MaxClientsj++)
        {
            
AttackerVictimInfo[i][j][2] = 0AttackerVictimInfo[i][j][1] = 0;    
        }
    }
}
public 
Action OnPlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int deadPlayer GetClientOfUserId(GetEventInt(event"userid"0));
    for (
int i 1<= MaxClientsi++)
    {
        
AttackerVictimInfo[deadPlayer][i][2] = 0AttackerVictimInfo[deadPlayer][i][1] = 0;    
    }


Last edited by sdz; 05-29-2016 at 10:18.
sdz is offline
SNCurti
Member
Join Date: Feb 2016
Old 05-29-2016 , 13:12   Re: A way to reference two variables to get one result?
Reply With Quote #7

Quote:
Originally Posted by EasSidezz View Post
Yeah then a multidimensional array would be the only way.

edit: here I changed some stuff around which might have helped. idk.
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

int finalDamage[MAXPLAYERS 1] = {0, ...};
int AttackerVictimInfo[MAXPLAYERS 1][MAXPLAYERS 1][3];

public 
Plugin sm_reap =
{
    
name "sm_reap",
    
author "SNC",
    
description "Reap plugin, health to victims from attackers.",
    
version "1.0",
    
url "http://sg-gaming.net/"
};

public 
OnPluginStart()
{
    
// Create reap command
    
LoadTranslations("common.phrases.txt");
    
RegAdminCmd("sm_reap"cmd_ReapADMFLAG_UNBAN);
    
HookEvent("player_hurt"OnPlayerHurt);
    
HookEvent("teamplay_round_start"OnRoundStart);
    
HookEvent("teamplay_game_over"OnRoundEnd);
    
HookEvent("player_death"OnPlayerDeath);
}

public 
Action cmd_Reap(int clientint args)
{
    
int arguments GetCmdArgs();
    
int reapedHealth;
    if (
arguments == || arguments == 2)
    {
        
int timeNow GetTime();
        
PrintToChatAll("%i"timeNow);
        
char arg1[64]; // Get argument (player who will be reaped(who's health will be taken from))
        
GetCmdArg(1arg1sizeof(arg1));
        
int clienttaken FindTarget(clientarg1falsefalse);
        if (
clienttaken != -1)
        {
            
IsPlayerAlive(clienttaken) && IsClientInGame(clienttaken)) // Ruling out invalid clients
            
{
                
reapedHealth GetClientHealth(clienttaken);
                if (
args == 1)
                {
                    for (
int i 1<= MaxClientsi++) // For loop giving each player hurt by the person being reaped health back
                    
{
                        if (
IsClientInGame(i) && IsPlayerAlive(i))
                        {
                            
PrintToChatAll("%i"AttackerVictimInfo[clienttaken][i][1]);
                            if ((
timeNow AttackerVictimInfo[clienttaken][i][1]) >= 60)
                            {
                                
AttackerVictimInfo[clienttaken][i][2] = 0;
                            }
                            else if ((
timeNow AttackerVictimInfo[clienttaken][i][1]) < 60)
                            {
                                
finalDamage[clienttaken] = AttackerVictimInfo[clienttaken][i][2] + finalDamage[clienttaken];
                                
int clientHealth GetClientHealth(i);
                                
int clientMaxHealth GetEntProp(iProp_Send"m_iMaxHealth");
                                if (
AttackerVictimInfo[clienttaken][i][2] + clientHealth clientMaxHealth)
                                {
                                    if (
clientMaxHealth 400 || clientMaxHealth 0// Just a check on health boundaries
                                    
{
                                        
SetEntityHealth(iclientMaxHealth); // Setting health to full
                                    
}
                                }
                                else
                                {
                                    
SetEntityHealth(iAttackerVictimInfo[clienttaken][i][2] + clientHealth); //Setting player health
                                
}
                            }
                        }
                    }
                    
ShowActivity2(client"[SM] ""Player %N has been reaped. All players that have taken damage from %N have been restored."clienttakenclienttaken);
                    if (
reapedHealth finalDamage[clienttaken])
                    {
                        
SetEntityHealth(clienttakenreapedHealth finalDamage[clienttaken]);
                    }
                    else if (
reapedHealth <= finalDamage[clienttaken])
                    {
                        
ForcePlayerSuicide(clienttaken);
                    }
                }    
                else if (
args == 2)
                {
                    
char arg2[64]; // Get argument (player who will be given health from reaped player), if none give back to all
                    
GetCmdArg(2arg2sizeof(arg2));
                    
int clientgiven FindTarget(clientarg2falsefalse);
                    if (
clientgiven != -|| clientgiven != || IsPlayerAlive(clientgiven) || IsClientInGame(clientgiven))
                    {
                        
PrintToChatAll("%i"AttackerVictimInfo[clienttaken][clientgiven][1]);
                        if ((
timeNow AttackerVictimInfo[clienttaken][clientgiven][1]) >= 60)
                        {
                            
AttackerVictimInfo[clienttaken][clientgiven][2] = 0;
                            
ShowActivity2(client"[SM] ""Invalid target(s). Time hurt out of bounds.");
                            return 
Plugin_Handled;
                        }
                        else if ((
timeNow AttackerVictimInfo[clienttaken][clientgiven][1]) < 60)
                        {
                            if (
reapedHealth AttackerVictimInfo[clienttaken][clientgiven][2])
                            {
                                
SetEntityHealth(clienttakenreapedHealth AttackerVictimInfo[clienttaken][clientgiven][2]);
                            }
                            else if (
reapedHealth <= AttackerVictimInfo[clienttaken][clientgiven][2])
                            {
                                
ForcePlayerSuicide(clienttaken);
                            }
                            
SlapPlayer(clienttakenAttackerVictimInfo[clienttaken][clientgiven][2]); // Hurting reaped player
                            
int clientHealth GetClientHealth(clientgiven); //Getting health of player being given health
                            
int clientMaxHealth GetEntProp(clientgivenProp_Send"m_iMaxHealth");
                            if ((
AttackerVictimInfo[clienttaken][clientgiven][2] + clientHealth) > clientMaxHealth)
                            {
                                if (
clientMaxHealth 400 || clientMaxHealth 0// Just a check on health boundaries
                                
{
                                    
SetEntityHealth(clientgivenclientMaxHealth); // Setting health to full
                                
}
                            }
                            else
                            {
                                
SetEntityHealth(clientgivenAttackerVictimInfo[clienttaken][clientgiven][2] + clientHealth);
                            }
                            
ShowActivity2(client"[SM] ""Admin %N used reap on %N. %N has been reaped. The health has been given to %N."clientclienttakenclienttakenclientgiven); // For logging
                        
}
                    }
                    else 
                    {
                        return 
Plugin_Handled;
                    }
                }
            }
            else
            {
                return 
Plugin_Handled;
            }
        }
    }
    else if (
args <= || args 2)
    {
        
ShowActivity2(client"[SM] ""Proper usage: sm_reap <from> <to> or sm_reap <from>"); // For logging
    
}
    return 
Plugin_Handled;
}
public 
Action OnPlayerHurt(Event event, const char[] namebool dontBroadcast)
{
    
int attackerIndex GetClientOfUserId(GetEventInt(event"attacker"0));
    
int victimIndex GetClientOfUserId(GetEventInt(event"userid"0));
    if (
attackerIndex != && attackerIndex != && victimIndex != && victimIndex != && IsClientInGame(attackerIndex) && IsClientInGame(victimIndex))
    {
        
AttackerVictimInfo[attackerIndex][victimIndex][1] = GetTime();
        
AttackerVictimInfo[attackerIndex][victimIndex][2] = AttackerVictimInfo[attackerIndex][victimIndex][2] + GetEventInt(event"damageamount"0);
    }
}
public 
Action OnRoundStart(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
// Just resetting some stuff
        
finalDamage[i] = 0;
        for (
int j 1<= MaxClientsj++)
        {
            
AttackerVictimInfo[i][j][2] = 0;
        }
    }
}
public 
Action OnRoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
// Just resetting some stuff
        
finalDamage[i] = 0;
        for (
int j 1<= MaxClientsj++)
        {
            
AttackerVictimInfo[i][j][2] = 0AttackerVictimInfo[i][j][1] = 0;    
        }
    }
}
public 
Action OnPlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int deadPlayer GetClientOfUserId(GetEventInt(event"userid"0));
    for (
int i 1<= MaxClientsi++)
    {
        
AttackerVictimInfo[deadPlayer][i][2] = 0AttackerVictimInfo[deadPlayer][i][1] = 0;    
    }

I'll test it out and get back to you.
EDIT: Unfortunately it hasn't changed anything in the code.

Last edited by SNCurti; 05-29-2016 at 13:22.
SNCurti 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 16:39.


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