[Tutorial] How to add a Spree system in your Gamemode.
#1

Hi,
I'm gonna show, how to add a Spree system in your Gamemode.

1.-
Add the new variable, we have to declare it:
pawn Код:
new spree[MAX_PLAYERS];
2.-
pawn Код:
new Text:Spree;
We'll declare the Text for the Spree. We have just to declare it!
3.-
pawn Код:
forward Txtreset();
public Txtreset()
{
    TextDrawHideForAll(Spree);
    return 1;
}
We have to add the function, which will hide the Spree text for the players!
4.-
pawn Код:
public OnGameModeInit()
{
  Spree = TextDrawCreate(9.000000,310.000000,"%s is on a killing spree of i kills.");
    TextDrawAlignment(Spree,0);
    TextDrawBackgroundColor(Spree,0x000000ff);
    TextDrawFont(Spree,3);
    TextDrawLetterSize(Spree,0.299999,0.799999);
    TextDrawColor(Spree,0xffffffff);
    TextDrawSetOutline(Spree,1);
    TextDrawSetProportional(Spree,1);
    TextDrawSetShadow(Spree,1);
    TextDrawHideForAll(Spree);
    return 1;
}
We have to create the TextDraw for the spree, it will be shown for the players!
5.-
pawn Код:
public OnGameModeExit()
{

    TextDrawDestroy(Spree);

    return 1;
}
Add the function to destroy the Spree TextDraw.

6.-
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
spree[killerid]++;

    if(spree[killerid] == 2) {
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(killerid, pName, sizeof(pName));
        format(string, sizeof(string), "%s is on a killing spree, with 5 kills", pName); //It goes for 2 kills
        TextDrawHideForAll(Spree);
        TextDrawSetString(Spree, string);
        TextDrawShowForAll(Spree); SetTimer("TxtReset", 3000, 0);
    }

    if(spree[killerid] == 7) {
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(killerid, pName, sizeof(pName));
        format(string, sizeof(string), "%s is on a killing spree, with 7 kills!", pName);//it goes for 7 kills!
        TextDrawHideForAll(Spree);
        TextDrawSetString(Spree, string);
        TextDrawShowForAll(Spree); SetTimer("TxtReset", 3000, 0);
        //Here you can add a function or a special action with 7 kills
    }

    if(spree[killerid] == 10) {
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(killerid, pName, sizeof(pName));
        format(string, sizeof(string), "%s is on a killing spre with 10 kills~", pName);//It goes for 10 kills
        TextDrawHideForAll(Spree);
        TextDrawSetString(Spree, string);
        TextDrawShowForAll(Spree); SetTimer("TxtReset", 3000, 0);//You can add more if you want!
}
    return 1;
}
We have to create the Messages that will be sent, when the player reaches a spree kill!


Hope it be useful for many people.
Reply
#2

Cool tutorial, well done
Reply
#3

See you wrong here
pawn Код:
Spree = TextDrawCreate(9.000000,310.000000,"s is on a killing spree of i kills.");
It`s
pawn Код:
%s
no s
Reply
#4

Quote:
Originally Posted by SounDD
Посмотреть сообщение
See you wrong here
pawn Код:
Spree = TextDrawCreate(9.000000,310.000000,"s is on a killing spree of i kills.");
It`s
pawn Код:
%s
no s
You are wrong as well.

%s is a place holder for a string when you use the format function. Both of you are wrong!
Reply
#5

It's good tutorial
Reply
#6

good tutorial
Reply
#7

Good Tutorial.
Thx
Reply
#8

Well done
Reply
#9

Please need a photo
Reply
#10

Quote:

if(spree[killerid] == 2) {
new string[128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(killerid, pName, sizeof(pName));
format(string, sizeof(string), "%s is on a killing spree, with 5 kills", pName); //It goes for 2 kills
TextDrawHideForAll(Spree);
TextDrawSetString(Spree, string);
TextDrawShowForAll(Spree); SetTimer("TxtReset", 3000, 0);


Its not big deal but ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)