Simple Killstreaks -
sciman001 - 13.11.2011
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.
![Smiley](images/smilies/smile.png)
Now to the tutorial.
STEP 1:
First of all, we will make the variable for the player's killstreak.
Code:
new killstreak[MAX_PLAYERS];
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.
![Smiley](images/smilies/smile.png)
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;
}
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:
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;
}
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
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
HandleKS(playerid, killerid);
return 1;
}
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.
Re: Simple Killstreaks -
[HiC]TheKiller - 13.11.2011
Here are some errors with the script
1. MAX_PLAYERS is case sensitive so max_players will return a unknown error.
2. max_playerp_name isn't a defined variable and max_player_name needs to be capitalized to be a defined variable.
3. There is no value assigned to name1 or name2
4.
pawn Code:
format(msg1, strlen(msg1), "%s has ended his killstreak", name1);
Who has ended who's killstreak? If the person wasn't on a killstreak, it would still show.
5. OnPlayerDisConnect should be OnPlayerDisconnect, remember the case.
You should explain the tutorial better, what does each function do?
Re: Simple Killstreaks -
Xx_OutLawZ_xX - 13.11.2011
And what, have you tested this?
Re: Simple Killstreaks -
sciman001 - 13.11.2011
Well, that just shows how tired I am. :P I appologize for the errors. I will fix them right now. Thanks for the responses though.
Re: Simple Killstreaks -
Hansrutger - 16.11.2011
Where do I put Step 3? Under which "public"? :S
Re: Simple Killstreaks - Astralis - 17.11.2011
Quote:
Originally Posted by Hansrutger
Where do I put Step 3? Under which "public"? :S
|
Ye , where?
Re: Simple Killstreaks -
TheLazySloth - 17.11.2011
Sooo everytime a player dies... messages will be spammed continuously? That's what it looks like from my observation.
Re: Simple Killstreaks -
Niko_boy - 19.11.2011
Quote:
Originally Posted by Hansrutger
Where do I put Step 3? Under which "public"? :S
|
Well
The Step 3 contains a Stock Script part Place it in lowest part of script
Its best place to place stocks
Re: Simple Killstreaks -
Hansrutger - 19.11.2011
Quote:
Originally Posted by Jagat
Well
The Step 3 contains a Stock Script part Place it in lowest part of script
Its best place to place stocks
|
Thank you!
Re: Simple Killstreaks -
krystiang1 - 25.11.2011
Quote:
Originally Posted by Jagat
Well
The Step 3 contains a Stock Script part Place it in lowest part of script
Its best place to place stocks
|
So your saying to just scroll down to the bottom of my script and CTRL+V it there?