[Tutorial] Killstreaks for players!
#6

A bit of redundant code, but otherwise nice. You must also assume that programmers are lazy. They don't like to type the same piece of code more than once.

pawn Code:
if(IsPlayerConnected(killerid) &&  killerid != INVALID_PLAYER_ID )
Is redundant. If the killerid is connected, then it is obviously not invalid and vice versa.

Second, the switch statement can be simplified:
pawn Code:
switch(Streaks[killerid]) //IMPORTANT: with the function "switch", you're switching / toggling through the killstreaks of a player (Streals). you need the killerid here, because the playerid is the one which is GETTING killed
{
    case 2: format(str, sizeof(str), "[KILLINGSPREE] ~g~%s has performed a ~y~double kill!", KillerName);
    case 3: format(str, sizeof(str), "[KILLINGSPREE] ~y~Triple Kill for ~b~%s!", KillerName);
    case 4: format(str, sizeof(str), "[KILLINGSPREE] ~p~Quadro Kill for ~r~%s!", KillerName);
    // etc ..
}
GameTextForAll(str,4000,4); //this is a function, which will show a short, colored big text for all the players (str, 4000ms, stylenumber 4)
Reply


Messages In This Thread
Killstreaks for players! - by Twisted_Insane - 24.03.2012, 16:58
Re: Killstreaks for players! - by emokidx - 25.03.2012, 05:27
Re: Killstreaks for players! - by Wickeed - 25.03.2012, 09:06
Re: Killstreaks for players! - by Twisted_Insane - 25.03.2012, 10:37
Re: Killstreaks for players! - by iGetty - 25.03.2012, 13:13
Re: Killstreaks for players! - by Vince - 25.03.2012, 13:22
Re: Killstreaks for players! - by Twisted_Insane - 25.03.2012, 13:23
Re: Killstreaks for players! - by iGetty - 25.03.2012, 13:23
Re: Killstreaks for players! - by Twisted_Insane - 25.03.2012, 13:36
Re: Killstreaks for players! - by 2KY - 25.03.2012, 18:50

Forum Jump:


Users browsing this thread: 1 Guest(s)