Facebook
From Obese Teal, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 224
  1.  
  2. // By Quarchodron / CC(2018) / Made for RolePlay v.0.4
  3.  
  4. addEvent("onPlayerEnterAreaHouse");
  5. addEvent("onPlayerLeaveAreaHouse");
  6.  
  7. addEvent("onPlayerEnterHouse");
  8. addEvent("onPlayerLeaveHouse");
  9.  
  10. class createHouse
  11. {
  12.     constructor(id, _area, roof, floor)
  13.         {
  14.             area_id = id;
  15.         area = _area;  
  16.  
  17.         roof_y = roof;
  18.         floor_y = floor;               
  19.             inhouse = false;
  20.                
  21.                 owner = null;
  22.                
  23.                 local _this = this;
  24.         addEventHandler("onPlayerEnterAreaHouse", function(areae){ _this.enterHouse(areae) });
  25.             addEventHandler("onPlayerLeaveAreaHouse", function(areae){ _this.leaveHouse(areae) });
  26.                
  27.         area.onEnter = function(){callEvent("onPlayerEnterAreaHouse", this);}  
  28.         area.onExit = function(){callEvent("onPlayerLeaveAreaHouse", this);}   
  29.     }
  30.        
  31.         function enterHouse(areas)
  32.         {
  33.             if(areas == area)
  34.                 {
  35.                     local pos = getPlayerPosition(heroId);
  36.                
  37.                     if(pos.y >= floor_y && pos.y <= roof_y)
  38.                     {
  39.                         inhouse = true;
  40.                                 callEvent("onPlayerEnterHouse", area_id, owner);
  41.                     }                        
  42.                 }
  43.         }
  44.        
  45.         function leaveHouse(areas)
  46.         {
  47.             if(areas == area)
  48.                 {
  49.                     if(inhouse)
  50.                     {
  51.                         inhouse = false;       
  52.                                 callEvent("onPlayerLeaveHouse", area_id, owner);
  53.                     }                        
  54.                 }
  55.         }
  56.        
  57.         function setOwnerHouse(name)
  58.         {
  59.             owner = name;
  60.         }
  61.        
  62.         function getOwnerHouse()
  63.         {
  64.             return owner;
  65.         }
  66.        
  67.         roof_y = 0;
  68.         floor_y = 0;
  69.         area_id = -1;
  70.         area = null;
  71.         inhouse = false;
  72.         owner = null;
  73. }
  74.  
  75.