// Killing spree system by Mean
#include < a_samp >
new gPlayerKills[ MAX_PLAYERS ];
public OnPlayerConnect( playerid ) return gPlayerKills[ playerid ] = 0;
public OnPlayerDeath( playerid, killerid, reason )
{
new string[ 70 ], name[ 24 ];
GetPlayerName( killerid, name, 24 );
gPlayerKills[ killerid ]++;
gPlayerKills[ playerid ] = 0;
if( gPlayerKills[ killerid ] == 2 ) format( string, sizeof string, "%s made a double kill! ", name );
if( gPlayerKills[ killerid ] == 3 ) format( string, sizeof string, "%s made a triple kill! ", name );
if( gPlayerKills[ killerid ] == 4 ) format( string, sizeof string, "%s is on a killing spree! ", name );
if( gPlayerKills[ killerid ] == 5 ) format( string, sizeof string, "%s is a kill frenzy! ", name );
if( gPlayerKills[ killerid ] == 6 ) format( string, sizeof string, "%s is a kill atrocity!", name );
if( gPlayerKills[ killerid ] == 7 ) format( string, sizeof string, "%s is a kill manjarow!", name );
if( gPlayerKills[ killerid ] == 8 ) format( string, sizeof string, "%s is a killtastrophe!", name );
if( gPlayerKills[ killerid ] == 9 ) format( string, sizeof string, "%s is untouchable!", name );
if( gPlayerKills[ killerid ] == 10 ) format( string, sizeof string, "%s is a killionaire!", name );
if( gPlayerKills[ killerid ] > 10 ) format( string, sizeof string, "%s is still a killionaire! ( %d kills )", name, gPlayerKills[ killerid ] );
// You can add more :D.
return SendClientMessageToAll( 0xAAAAAA, string );
}
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if( !strcmp( cmdtext, "/spree", true, 6 ) || !strcmp( cmdtext, "/streak", true, 7 ) )
{
new str[ 55 ];
format( str, sizeof str, "You are currently on a killing spree of %d kills.", gPlayerKills[ playerid ] );
return SendClientMessage( playerid, 0xAAAAAA, str );
}
return 0;
}
public OnPlayerSpawn(playerid) { SetPVarInt(playerid, "kills", 0); } public OnPlayerDeath(playerid, killerid, reason) { if(team[playerid] == 2) { SetPVarInt(killerid, "kills", GetPVarInt(killerid, "kills")+1); if (GetPVarInt(killerid, "kills") == 2) Audio_Play(killerid, 1, false, false, false); if (GetPVarInt(killerid, "kills") == 3) Audio_Play(killerid, 4, false, false, false); if (GetPVarInt(killerid, "kills") == 4) Audio_Play(killerid, 2, false, false, false); if (GetPVarInt(killerid, "kills") == 5) Audio_Play(killerid, 6, false, false, false); if (GetPVarInt(killerid, "kills") >= 6) Audio_Play(killerid, 7, false, false, false); } }
Make use of the switch function, damn. I find it so ugly when people have scripts that are filled with useless if statements.
|
switch( GetPVarInt( killerid, "kills" ) )
{
case 2: // 2 kills
{
// Stuff here
}
case 3: // 3 kills
{
// stuff here
}
// ETC
}
if( GetPVarInt( killerid, "kills" ) == 2 )
{
// Stuff here
}
if( GetPVarInt( killerid, "kills" ) == 3 )
{
// Stuff here
}
// ETC
SetPVarInt( playerid, "kills", 0 );