Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spree <- array( 100, null );
- class SpreeSys
- {
- player = null;
- spree = 0;
- constructor( player )
- {
- if( typeof player != "instance" ) return;
- this.player = player;
- this.spree = 0;
- }
- function Get()
- {
- return [ this.spree, this.player ];
- }
- function Inc( amount = 1 )
- {
- this.spree += amount;
- local s = this.spree;
- if( s >= 5 && s%5 == 0 ) Start();
- }
- function Dec( amount )
- {
- this.spree -= amount;
- }
- function Start()
- {
- local s = this.spree, reward = s*100;
- ::Message( format( "%s is on a killing spree of %i kills in a row. Reward: %i.", this.player.Name, s, reward ) );
- this.player.Cash += reward;
- }
- function End( victim = null )
- {
- local spree = this.spree;
- if( spree >= 5 )
- {
- if( victim != null ) ::Message( format("%s has ended %s killing spree of %i kills in a row.", victim.Name, this.player.Name, spree ) );
- else ::Message( format("%s has ended their own killing spree of %i kills in a row.", this.player.Name, spree ) );
- this.spree = 0;
- }
- else this.spree = 0;
- }
- }
- function onPlayerJoin( player )
- {
- spree[ player.ID ] = SpreeSys( player );
- }
- function onPlayerKill( killer, player, reason, bodypart )
- {
- spree[ killer.ID ].Inc();
- spree[ player.ID ].End( killer );
- }
- function onPlayerTeamKill( killer, player, reason, bodypart )
- {
- onPlayerKill( killer, player, reason, bodypart );
- }
- function onPlayerDeath( player )
- {
- spree[ player.ID ].End();
- }
- function onPlayerPart( player, reason )
- {
- spree[ player.ID ].End();
- spree[ player.ID ] = null;
- }
- function onPlayerCommand( player, cmd, text )
- {
- if( cmd == "spree" )
- {
- local spree = ::spree, Buffer = "", hue;
- foreach( value in spree )
- {
- if( value == null ) continue;
- hue = value.Get();
- if( hue[0] >= 5 )
- {
- if( Buffer == "" ) Buffer = hue[1].Name + "(" + hue[0] + ")";
- else Buffer += " , " + hue[1].Name + "(" + hue[0] + ")";
- }
- }
- if( Buffer != "" ) MessagePlayer( "Players on spree: " + Buffer, player );
- else MessagePlayer("No players are currently on spree.", player );
- }
- }
Add Comment
Please, Sign In to add comment