SA-MP Forums Archive
If Killing Spree More then all player's (rep+) - 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)
+--- Thread: If Killing Spree More then all player's (rep+) (/showthread.php?tid=307191)



If Killing Spree More then all player's (rep+) - Ballu Miaa - 29.12.2011

I have a Basic killing spree system with a Textdraw. it shows up name of the Player on killing spree.

pawn Код:
// OnPlayerDeath
Kills[killerid]++;
Kills[playerid] = 0;

if(Kills[killerid] >= 3)
    {
        new string[256];
        format(string,sizeof(string),"%s is a killing spree with &d kills!",PlayerName(killerid), Kills[killerid]);
        TextDrawSetString(KSTD,string); // This textdraw is already created under OnGameModeInit with srting ::
        TextDrawFont( KSTD, 3);
        TextDrawLetterSize( KSTD, 0.35, 1.0);
        TextDrawColor(KSTD , 0x8000FFFF);
        TextDrawSetOutline( KSTD, 1);
        TextDrawSetProportional( KSTD, 1);
        TextDrawSetShadow( KSTD , 1);
    }
    if(Kills[killerid] > PlayerInfo[killerid][pSpree]) PlayerInfo[killerid][pSpree] = Kills[killerid];

What i want is a function which use's a for loop to search MAX_PLAYERS and check the Largest killing spree among all players i.e. MAX_PLAYERS I dont know how can i create this? Can anyone please code me something or suggest please?

Again what i want is a Global variable or something which check all player's for largest killing spree which is Kills[killer]

Thanks
Char.C


Re: If Killing Spree More then all player's (rep+) - Norck - 29.12.2011

Hope I get you right:
pawn Код:
new top_player = -1; // id of the player that has most kills
new top_kills = 0;     // amount of kills that top player has
for(new i=GetMaxPlayers(); i >=0; i--)
{
    if(!IsPlayerConnected(i))    continue;
    if(Kills[i] > top_kills)
    {
        top_player = i;
        top_kills = Kills[i];
    }
}
if(top_player == -1)  // if no-one has at least 1 kill
{
    // you may want to do something here
}
else
{
    // top_player = player that has most kills
}



Re: If Killing Spree More then all player's (rep+) - Cameltoe - 29.12.2011

EDIT: Looks like ^ was a bit faster ^^,

pawn Код:
enum KS
{
     KillerID = INVALID_PLAYER_ID,
     Kills = 0,
}
new KillspreeInfo[KS];

for(new NewKillspreeID; NewKillspreeID < MAX_PLAYERS; NewKillspreeID++)
{
      if(!IsPlayerConnected(NewKillspreeID)) continue;
      if(Kills[NewKillspreeID] > KillSpreeInfo[Kills] && Kills[NewKillspreeID] > 0)
      {
           KillSpreeInfo[KillerID] = NewKillspreeID;
           KillSpreeInfo[Kills] = Kills[KillSpreeInfo[KillerID];
      }  
}
// Check if KillSpreeInfo[KillerID] != INVALID_PLAYER_ID And update the textdraw



Re: If Killing Spree More then all player's (rep+) - Ballu Miaa - 29.12.2011

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
EDIT: Looks like ^ was a bit faster ^^,

pawn Код:
enum KS
{
     KillerID = INVALID_PLAYER_ID,
     Kills = 0,
}
new KillspreeInfo[KS];

for(new NewKillspreeID; NewKillspreeID < MAX_PLAYERS; NewKillspreeID++)
{
      if(!IsPlayerConnected(NewKillspreeID)) continue;
      if(Kills[NewKillspreeID] > KillSpreeInfo[Kills] && Kills[NewKillspreeID] > 0)
      {
           KillSpreeInfo[KillerID] = NewKillspreeID;
           KillSpreeInfo[Kills] = Kills[KillSpreeInfo[KillerID];
      }  
}
// Check if KillSpreeInfo[KillerID] != INVALID_PLAYER_ID And update the textdraw
Can you help me with the Usage?? I mean Update the Textdraw how?? Can you please make Me a full code using my Functions pleasE?

Im just confuse at it!


Re: If Killing Spree More then all player's (rep+) - Ballu Miaa - 30.12.2011

Please reply! I need to update this ASAP?? Please code me a Textdraw to be created when this Happens!!

And i need an Explanation to understand this if i need to create a function myself!


Re: If Killing Spree More then all player's (rep+) - Guest9328472398472 - 30.12.2011

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Please reply! I need to update this ASAP?? Please code me a Textdraw to be created when this Happens!!

And i need an Explanation to understand this if i need to create a function myself!
Patience is the key to everything, they are helping you the best you can. All you need is patience


Re: If Killing Spree More then all player's (rep+) - Ballu Miaa - 30.12.2011

Quote:
Originally Posted by Brandon Javorsky
Посмотреть сообщение
Patience is the key to everything, they are helping you the best you can. All you need is patience
I understand that brother. Thanks for the reply. I woke up after 10 hours or so and there was no Reply so got fucked up a bit. Sorry Mate.

Can you help me explain the upper code's?


Re: If Killing Spree More then all player's (rep+) - §с†¶e®РµРe - 30.12.2011

To change the textdraw text u can use TextDrawSetString and change the string of the textdraw u created earlier i think.....
[OFFTOPIC]RP server is running fine.I am going to get a free VPS like in January so if u want to leave volt-host and host for free give ur server to me i will host it on the same VPS but u can't get port 7777(that's mine).Any other port of u want contact me[/OFFTOPIC]


Re: If Killing Spree More then all player's (rep+) - Ballu Miaa - 30.12.2011

Quote:
Originally Posted by §с†¶e®РµРe
Посмотреть сообщение
To change the textdraw text u can use TextDrawSetString and change the string of the textdraw u created earlier i think.....
[OFFTOPIC]RP server is running fine.I am going to get a free VPS like in January so if u want to leave volt-host and host for free give ur server to me i will host it on the same VPS but u can't get port 7777(that's mine).Any other port of u want contact me[/OFFTOPIC]
I understand that Haardik! But can you code it then?? I'm confused that where exactly i can use this function or so!
Help me with the code please.

[offtopic] Wow Nice! For sure. Will love to. Let me know when its on! Peace Much Love [/offtopic]


Re: If Killing Spree More then all player's (rep+) - Guest9328472398472 - 30.12.2011

My Suggestion : Look up in SAMP Wiki (Tutorials - Scripting) and see if you can find any functions that checks each player and automatically enters in which players from (say) 1-10 have the record killing spree...something like that. I would suggest you wiki.sa-mp.com. You should find something there, like I have before.