KAKAN

Heal via key

Jan 14th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.89 KB | None | 0 0
  1. rightclick <- BindKey(true, 0x02, 0, 0);
  2.  
  3. function onKeyDown( player, key ){
  4.     if( key == rightclick ){
  5.         if( player.Skin != 5 ) return player.Msg("Not the right skin you know?")
  6.         local has_healed = false;
  7.         for( local plr, i = 0; i < 50; i++ ){
  8.             plr = FindPlayer(i);
  9.             if( !plr ) continue;
  10.             local required_distance = 5.0,
  11.                 dist_from_player = DistanceFromPoint( player.Pos.x, player.Pos.y, plr.Pos.x, plr.Pos.y );
  12.             if( dist_from_player < required_distance && plr.Health != 100 ){
  13.                 player.IncCash(1);
  14.                 plr.Health = 100;
  15.                 player.Msg("you cured %s, reward: 1$",plr.Name);
  16.                 has_healed = true;
  17.             }
  18.         }
  19.         if( !has_healed )player.Msg("No one is near you");
  20.     }
  21. }
  22.  
  23. function CPlayer::IncCash( amount ){
  24.     ::stats[ this.ID ].Cash += amount;
  25.     this.Cash += amount;
  26. }
  27. function CPlayer::Msg( text, ... ){
  28.     vargv.insert( 0, this );
  29.     ::MessagePlayer( format.acall(vargv), this );
  30. }
Add Comment
Please, Sign In to add comment