KAKAN

For @Ron

May 6th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.04 KB | None | 0 0
  1. function CPlayer::Stats()
  2. {
  3.   local stats = null, c = ::stats[ this.ID ];
  4.   local kills = c.Kills, deaths = c.Deaths;
  5.   if( c.IsReg == true )
  6.   {
  7.     if( kills > 0 && deaths > 0 )
  8.     {
  9.       local ratio = format(@"%.2f", kills.tofloat() / deaths.tofloat() );
  10.       stats = format(@"Kills: %i , Deaths: %i , K/D Ratio: %f", kills, deaths, ratio );
  11.     }
  12.     else stats = format(@"Kills: %i , Deaths: %i , Ratio: 0.00", kills, deaths );
  13.   }
  14.   else stats = "Not registered yet.";
  15.   return stats;
  16. }
  17.  
  18. //edit, adding onPlayerCommand.
  19. function onPlayerCommand( player, command, text )
  20. {
  21.     if( cmd == "stats" )
  22.     {
  23.         if( stats[ player.ID ].Logged != true ) return ePrivMessage( "[Error] - You're not registered.", player );
  24.         else if( !text ) return EMessage( ">> " + player.Name + "'s stats: " + player.Stats() );
  25.         local plr = ( IsNum( text ) ? FindPlayer( text.tointeger() ) : FindPlayer( text ) );
  26.         if( !plr ) return ePrivMessage( "Invalid player nick/ID!", player );
  27.         else return EMessage( plr.Name + "'s stats: " + plr.Stats() );
  28.     }
  29. }
Add Comment
Please, Sign In to add comment