Solved House locations

Discussion in 'Plugin Requests' started by kiko, Jan 7, 2016.

  1. hello
    Someone would he be able to make this plugin compatible with oxide 2 on rust legacy ???
    thanks for your answer

    I was talking about this plugin: house-loc.lua

    i post here this plugin :
    Code:
    PLUGIN.Title = "House List"
    PLUGIN.Description = "Get all the locations of houses"
    PLUGIN.Author = "Reneb"
    PLUGIN.Version = "1.1.1"local AllStructures = util.GetStaticPropertyGetter( Rust.StructureMaster, "AllStructures")
    local getStructureMasterOwnerId = util.GetFieldGetter(Rust.StructureMaster, "ownerID", true)
    function PLUGIN:Init()
      -- Bind a slash command
       self.oxminPlugin = cs.findplugin("oxmin")
       if (not self.oxminPlugin) then
         error("Oxmin plugin was not found!")
         return
       end
       self.oxminPlugin:AddExternalOxminChatCommand(self, "house", { 3 }, self.cmdHouse)
       self.oxminPlugin:AddExternalOxminChatCommand(self, "housetp", { 3 }, self.cmdHousetp)
    end
    local GetComponents, SetComponents = typesystem.GetField( Rust.StructureMaster, "_structureComponents", bf.private_instance )
    local function GetOneConnectedComponents( master )
      local hashset = GetComponents( master )
      local tbl = {}
      local it = hashset:GetEnumerator()
      while (it:MoveNext()) do
      return it.Current
      end
    endfunction PLUGIN:cmdHouse(netUser, args)
      -- Get the array that holds all StructureMaster objects in the world.
       if(not(args[1])) then
         rust.SendChatToUser(netUser,"Usage: /house PLAYER")
         return
       end
       local possible = {}
       local structures = {}
       local userdata
       local userid
       local structure
       local id = 0
      -- Loop all the strucutres
      for i=0, AllStructures().Count-1 do
      -- Print the ID attached to this structure
         id = id + 1
         userid = self:GetStructureOwnerID(AllStructures())
         userdata = self.oxminPlugin:GetUserDataFromID(tostring(userid))
         if(userdata) then
           if(string.find(tostring(userdata.Name), args[1])) then
             structure = GetOneConnectedComponents( AllStructures() )
             if(structure) then
               rust.SendChatToUser(netUser,id .. " - " .. userdata.Name .. " house location: " .. math.ceil(structure.transform.position.x) .. " " .. math.ceil(structure.transform.position.y + 4) .. " " .. math.ceil(structure.transform.position.z) .. "")
             end
           end
         end
      end
    end
    function PLUGIN:cmdHousetp(netuser, args)
      -- Get the array that holds all StructureMaster objects in the world.
       if(not(args[1])) then
         rust.SendChatToUser(netuser,"Usage: /housetp HOUSEID")
         return
       end
       local jumpid = tonumber(args[1])
       local possible = {}
       local structures = {}
       local id = 0
      -- Loop all the strucutres
      for i=0, AllStructures().Count-1 do
      -- Print the ID attached to this structure
         id = id + 1
         if(id == jumpid) then
           local structure = GetOneConnectedComponents( AllStructures() )
           if(not structure) then
             rust.SendChatToUser(netuser,"This house decayed or was removed")
             return
           end
           local pos = netuser.playerClient.lastKnownPosition
           pos.x = structure.transform.position.x
           pos.y = math.ceil(structure.transform.position.y + 4)
           pos.z = structure.transform.position.z
           rust.ServerManagement():TeleportPlayer( netuser.playerClient.netPlayer, pos )
           local userid = self:GetStructureOwnerID( AllStructures() )
           local userdata = self.oxminPlugin:GetUserDataFromID(tostring(userid))
           if(userdata) then
             rust.SendChatToUser(netuser,userdata.Name .. "'s house")
           end       timer.Once( 2, function() rust.ServerManagement():TeleportPlayer( netuser.playerClient.netPlayer, pos ) end )
         end
      end
    end
    -- Get the ID for this structure
    function PLUGIN:GetStructureOwnerID(structure)
      return getStructureMasterOwnerId(structure)
    end
     
    Last edited by a moderator: Jan 12, 2016
  2. Wulf

    Wulf Community Admin

  3. I made a big mistake, I confused two plugins, sorry sorry sorry, i open another thread
    thanks for your answerd