SA-MP Forums Archive
Most kills for a round? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Most kills for a round? (/showthread.php?tid=131859)



Most kills for a round? - bajskorv123 - 05.03.2010

Hey, I'm looking for a function where you can get like who had the most stats for the round etc.
Example:
When the round ends, say:
"The round has ended! Most kills for this round was: [NWA]Hannes with 1337 kills! Most deaths for this round was: [NoOb]HackZoreR with 1337 deaths!"

I'm no newb in scripting so i will understand the most, dont make any big tutorials ok?


Re: Most kills for a round? - bajskorv123 - 06.03.2010

Bump


Re: Most kills for a round? - bajskorv123 - 07.03.2010

Bump


Re: Most kills for a round? - bajskorv123 - 09.03.2010

Bump


Re: Most kills for a round? - bajskorv123 - 10.03.2010

Bump


Re: Most kills for a round? - bajskorv123 - 11.03.2010

Bump

I mean like a global variable storing deaths and kills (I can make that by my self)
Then something finding wich player who had the biggest value in deaths or kills.

pawn Код:
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;
}



Re: Most kills for a round? - Jeffry - 11.03.2010

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.


Re: Most kills for a round? - bajskorv123 - 11.03.2010

Quote:
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.
Im desperate
Do what you can


Re: Most kills for a round? - Jeffry - 11.03.2010

Quote:
Originally Posted by [NWA
Hannes ]
Quote:
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.
Im desperate
Do what you can
Oke, Im PMing you from now on.


Re: Most kills for a round? - iLinx - 11.03.2010

This is what i wrote up in notepad, i havent tested it - i cba to really right now.
Give it a try and tell me if it works.
pawn Код:
/*
* 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);
}
forums destroyed indentation, sorry.