enum Data
{
Deaths,
Kills,
};
new Info[MAX_PLAYERS][Data];
public OnPlayerDeath(playerid, killerid, reason)
{
Info[playerid][Deaths]++;
Info[killerid][Kills]++;
return 1;
}
public OnRoundEnd()//Yes this is my own callback...
{
new mKills;
new mDeaths;
for(new i=0; MAX_PLAYERS; i++)
{
GetMostKills(i, mKills, pName);//Getting the player who had the most kills by all players then storing most kills into mKills and the player with the most kills name in pName
GetMostDeaths(i, mDeaths, pName);
format(str, sizeof(str), "%s had most kills for this round! (Kills: 1337)", pName, mKills);
SendClientMessageToAll(red, str);
format(str, sizeof(str), "%s had most deaths for this round! (Deaths: 1337)", pName, mDeaths);
SendClientMessageToAll(red, str);
}
return 1;
}
Originally Posted by Jeffry
Hmm, yeah this is possible.
Well, Iґd try that on saturday if noone cames before me, is that okay? Not sure if I can do it, but im optimistic. |
Originally Posted by [NWA
Hannes ]
Quote:
Do what you can |
/*
* Gets the most kills and deaths in the Info array.
* Accepts 4 variables by reference, k (variable to store most Kills), kID (variable to store the playerid of the player * with most kills)
* d (variable to store most deaths), dID (variable to store the playerid of the player with most deaths)
* Not tested, should work though */
stock GetHighestKD(&k, &kID, &d, &dID)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Info[playerid][Deaths] > d)
{
d = Info[i][Deaths];
dID = i;
}
if(Info[playerid][Kills] > k)
{
k = Info[i][Kills];
kID = i;
}
}
return 1;
}
/*
* Just a little function to get players name
*/
stock getName(playerid)
{
new str[MAX_PLAYER_NAME];
GetPlayerName(playerid, str, sizeof(str));
return str;
}
Public OnRoundEnd()
{
new mKills, mKillsPlayerID, mDeaths, mDeathsPlayerID;
GetHighestKD(mKills, mKillsPlayerID, mDeaths, mDeathsPlayerID);
format(str, sizeof(str), "%s had most kills for this round! (Kills: %d)", getName(mKillsPlayerID), mKills);
SendClientMessageToAll(red, str);
format(str, sizeof(str), "%s had most deaths for this round! (Deaths: %d)", getName(mDeathsPlayerID), mDeaths);
SendClientMessageToAll(red, str);
}