Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CPlayer::Stats()
- {
- local stats = null, c = ::stats[ this.ID ];
- local kills = c.Kills, deaths = c.Deaths;
- if( c.IsReg == true )
- {
- if( kills > 0 && deaths > 0 )
- {
- local ratio = format(@"%.2f", kills.tofloat() / deaths.tofloat() );
- stats = format(@"Kills: %i , Deaths: %i , K/D Ratio: %f", kills, deaths, ratio );
- }
- else stats = format(@"Kills: %i , Deaths: %i , Ratio: 0.00", kills, deaths );
- }
- else stats = "Not registered yet.";
- return stats;
- }
- //edit, adding onPlayerCommand.
- function onPlayerCommand( player, command, text )
- {
- if( cmd == "stats" )
- {
- if( stats[ player.ID ].Logged != true ) return ePrivMessage( "[Error] - You're not registered.", player );
- else if( !text ) return EMessage( ">> " + player.Name + "'s stats: " + player.Stats() );
- local plr = ( IsNum( text ) ? FindPlayer( text.tointeger() ) : FindPlayer( text ) );
- if( !plr ) return ePrivMessage( "Invalid player nick/ID!", player );
- else return EMessage( plr.Name + "'s stats: " + plr.Stats() );
- }
- }
Add Comment
Please, Sign In to add comment