13.11.2011, 02:03
(
Last edited by sciman001; 13/11/2011 at 05:31 AM.
)
Hello all! How are you? First of all, I would like to thank you for reading this, and appologize if I make any errors in the code.
Now to the tutorial.
STEP 1:
First of all, we will make the variable for the player's killstreak.
We made it an array so that it can save the killstreak of many players.
STEP 2:
Next, we will make sure that the killstreak of the player is set to 0 when he joins and leavs the server. That way, it will be fair.
Heres the code:
Again, this is so that the player's killstreak is 0 on connect/disconnect. You could remove ont of them and it would work still but... just for safety, I use both. 
STEP 3:
Next, we will make the function to handle the killstreaks. Just to make the script cleaner. Heres the function:
Basically what this code does, is it changes the killstreaks of the players, sends a message to everyone about the players's killtreaks, and if the killer got a killstreak, does it.
STEP 4:
now, we just add the function that handles the killstreaks to the onplsyerdeath callback. That way, the player doesnt just have 0 killstreak the whole time. :P
Now, the whole system is done. :P
So now, you should have a working killstreak system. Thank you for reading and thank you for your time.
p.s. Comment any errors I made and I'll fix them.
Now to the tutorial.STEP 1:
First of all, we will make the variable for the player's killstreak.
Code:
new killstreak[MAX_PLAYERS];
STEP 2:
Next, we will make sure that the killstreak of the player is set to 0 when he joins and leavs the server. That way, it will be fair.
Heres the code:Code:
public OnPlayerConnect(playerid)
{
killstreak[playerid] = 0; //sets the player's killstreak to 0
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
killstreak[playerid] = 0;
return 1;
}

STEP 3:
Next, we will make the function to handle the killstreaks. Just to make the script cleaner. Heres the function:
Code:
stock HandleKS(playerid, killerid) //put this function outside of any callbacks or functions
{
killstreak[playerid] = 0;
killstreak[killerid] ++;
new msg1[64], msg2[64], name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name1, strlen(name1));
GetPlayerName(playerid, name2, strlen(name2));
format(msg1, strlen(msg1), "%s has ended %s's killstreak", name2, name1);
format(msg2, strlen(msg2), "%s is now on a killsreak of %i", name2, killstreak[killerid]);
SendClientMessageToAll(-1, msg1);
SendClientMessageToAll(-1, msg2);
switch(killstreak[killerid])
{
case 3:
{
//killstreak code - make ur killstreak here
}
case 6:
{
//killstreak code - make ur killstreak here
}
case 9: //change the numbers as desired and add/remove as many as you want
{
//killstreak code - make ur killstreak here
}
}
return 1;
}
STEP 4:
now, we just add the function that handles the killstreaks to the onplsyerdeath callback. That way, the player doesnt just have 0 killstreak the whole time. :P
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
HandleKS(playerid, killerid);
return 1;
}
So now, you should have a working killstreak system. Thank you for reading and thank you for your time.

p.s. Comment any errors I made and I'll fix them.


