No. Just make a two-dimensional array. An ArrayList is only useful if you don't know how many values you are going to need. Here, you need MAXPLAYERS+1 * MAXPLAYERS+1. There is no use for an ArrayList here, nor would an ArrayList be easy to use, as the client indexes wouldn't necessarily correspond to the ArrayList indexes.
An ArrayList is only useful over a standard array if you require a array that can change size. That's it.
PHP Code:
#pragma semicolon 1
#include <sdkhooks>
#pragma newdecls required
float gDamageTaken[MAXPLAYERS+1][MAXPLAYERS+1]; //first dimension is the attacker, second is victim
public void OnPluginStart() {
HookEvent("round_end", Event_RoundEnd);
}
public void OnClientPutInServer(int client) {
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3]) {
if(victim && attacker && victim <= MaxClients && attacker <= MaxClients) {
if(IsClientInGame(victim) && IsClientInGame(attacker)) {
gDamageTaken[attacker][victim] += damage;
}
}
return Plugin_Continue;
}
//remove damage info relating to a user who is disconnecting
public void OnClientDisconnect(int client) {
for (int i = 1; i <= MaxClients; i++) {
gDamageTaken[client][i] = 0.0;
gDamageTaken[i][client] = 0.0;
}
}
public Action Event_RoundEnd(Event event, char[] name, bool dontBroadcast) {
for(int i = 1; i <= MaxClients; i++) {
if(IsClientInGame(i)) {
for (int x = i; x <= MaxClients; x++) {
if (i != x && gDamageTaken[i][x] > 0.0) {
PrintToChat(client, "You dealt %f damage to %N!", gDamageTaken[i][x], x);
}
}
}
}
}
__________________