Rust Legacy Sleeper locations

Discussion in 'Plugin Requests' started by MrPrzyr, May 12, 2015.

  1. I agree, I was going to suggest this too.
     
  2. Hey, I have a shitty solution for you:

    Code:
    PLUGIN.Title = "Sleepers"
    PLUGIN.Description = "Saves sleeper locations"
    PLUGIN.Author = "mvrb"
    PLUGIN.Version      = V(1, 0, 0)
    PLUGIN.ResourceId   = _function PLUGIN:Init()
        -----------------------------
        -- Chat Commands
        -----------------------------
       
        command.AddChatCommand("sleeper", self.Object, "cmdSleepers")
        command.AddChatCommand("sleepers", self.Object, "cmdSleepers")
        command.AddChatCommand("s", self.Object, "cmdSleepers")
       
        -----------------------------
        -- Variables
        -----------------------------
       
        -- ChatName
        CN = "YourServerName"   
       
        -- Sleepers
        self.sleepers = {}   
    end-----------------------------
    -- Custom Functions
    -----------------------------
    function PLUGIN:cmdSleepers( netuser, cmd )   
        if(netuser:CanAdmin()) then
            if (#self.sleepers > 0) then
                rust.SendChatMessage(netuser, CN, "--- start ---")
                local i = 1
                while (self.sleepers[i]) do
                    rust.SendChatMessage(netuser, self.sleepers[i]["name"], self.sleepers[i]["msg"])
                    i = i + 1
                end
                rust.SendChatMessage(netuser, CN, "--- end ---")
            else -- No players have disconnected
                rust.SendChatMessage(netuser, CN, "[color #FF3D0D]No players have disconnected in the current session.")
            end
        end
    end
    function PLUGIN:AddSleeper( name, msg)
        local insert = {}
        insert["name"] = name
        insert["msg"] = msg
        table.insert(self.sleepers, insert)
    end-----------------------------
    -- AutoFunctions
    -----------------------------
    function PLUGIN:OnPlayerDisconnected(networkplayer)
        local netuser     = networkplayer:GetLocalData()
        local name         = netuser.displayName
        local position     = netuser.playerClient.lastKnownPosition
       
        if (#self.sleepers == 20) then    table.remove(self.sleepers, 1)    end -- Remove last line if 20
        if(position.x ~= 0 and position.y ~= 0 and position.z ~= 0) then
            self:AddSleeper(netuser.displayName, math.ceil(position.x) .. " || " .. math.ceil(position.y) .. " || " .. math.ceil(position.z) .. " ||")   
            print(netuser.displayName .. " disconnected here: teleport.topos mvrb " .. math.ceil(position.x) .. " " .. math.ceil(position.y) .. " " .. math.ceil(position.z))
        end
    end
    Players coordinates are added to /s or /sleepers. It will display the last 20 disconnected users, but it doesn't save it to a file so you can find a sleeper's location by name.

    It will print it to the console though, so you could go through the logs and search for the last disconnect of a player.

    Save the code as 'sleepers.lua'.