1. How am I able to
    1. Test for Sleeper Names? //For example to try if "Username9273" is a sleeper
    2. to track the position of a specific sleeper (for example by username)
    Thanks!
     
  2. You've used the activePlayerList before, there is an equivalent for sleeping players: sleepingPlayerList. You can just use the same approach as you would do it for online players only difference would be the list you're getting the data from.
     
  3. Thanks
     
  4. Well I got an error over here. Im trying to use "find" on the sleepingPlayerList, but it just seems to recieve a null object. Propably im doing many failures on here. Please don't kill me ^^

    I used the command
    /testsleeper name
    just used a name of a guy sleeping in front of me.

    Code:
    Code:
    PLUGIN.Title        = "Sleeper Test"
    PLUGIN.Description  = "Sleeperslist tested"
    PLUGIN.Author       = "LaserHydra"
    PLUGIN.Version      = V(1,0,0)
    PLUGIN.ResourceId     = "?"function PLUGIN:Init()
        command.AddChatCommand("testsleeper", self.Object, "cmdSleeperTest")
    endfunction PLUGIN:cmdSleeperTest( player, cmd, args )
        local sleepers = global.BasePlayer.sleepingPlayerList:GetEnumerator() -- Also does that work like that? ^^ Im just trying to use it as I've seen it in other plugins.. Never used :v
        local target = global.BasePlayer.sleepingPlayerList.Find(args[0])
         while sleeper:MoveNext() do -- As I said. using this first time just from using what I've seen. Please tell me if im doing the whole thing wrong and where I can find more infos about this.
            if sleeper.Current == target then
                rust.SendChatMessage(player, "" .. sleeper)
            end
        end
    end
    Error:
    Code:
    [Oxide] 5:35 PM [Error] Failed to call hook 'cmdSleeperTest' on plugin 'Sleeper Test'
    File: sleepertp.lua Line: 13 instance method 'Find' requires a non null target object:
      at NLua.Lua.ThrowExceptionFromError (Int32 oldTop) [0x00000] in <filename unknown>:0
      at NLua.Lua.CallFunction (System.Object function, System.Object[] args, System.Type[] returnTypes) [0x00000] in <filename unknown>:0
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
     
    Last edited by a moderator: Apr 30, 2015
  5. You're close.
    The line with the local target ... is complete nonsense. You are already looping through the sleepingPlayerList why do you want to also use Find() on it?
    What you want to do is find the baseplayer of the target you used on the chat command not the sleeping player.
    You are also missing an "s" on "sleeper" in your while loop.
    The rest is fine, all you need to do is rethink the line with local target = ... and fix the typo.
     
  6. Wow actually the first time I just hear that im close ^^
    So I just need to call for
    global.BasePlayer.Find(args[0])
    right? I mean I could also use tostring but I would like that you can just type a part of the name and it would work.

    Tell me im not ruining my run with this ^^
     
  7. Oh wait, after reading your post again forget what i posted before.

    You dont need the Find() part at all.
    You only need to check if the current sleeper in your while loop matches with your user input. So in your while loop you check if the name of the current sleeper or the steamid of the current slepper in the loop matches the user input. Not sure if I explained that understandable :p

    Your snippet should look something like that:
    Code:
    function PLUGIN:cmdSleeperTest( player, cmd, args )
        local sleepers = global.BasePlayer.sleepingPlayerList:GetEnumerator() -- Also does that work like that? ^^ Im just trying to use it as I've seen it in other plugins.. Never used :v
         local target = args[0]
         while sleepers:MoveNext() do -- As I said. using this first time just from using what I've seen. Please tell me if im doing the whole thing wrong and where I can find more infos about this.
            if sleepers.Current.displayName == target or rust.UserIDFromPlayer(sleepers.Current) == target then
                rust.SendChatMessage(player, sleepers.Current.displayName)
            end
        end
    end
     
  8. Yeah thats understandable I guess... and Wow by using this while loop with MoveNext and stuff, it opens most of the possibilities I searched for ^^
    [DOUBLEPOST=1430412856][/DOUBLEPOST]One more thing. I know that the displayname is "displayName" but whats the position? just replacing displayName with "position" doesn't work tho ^^ so its propably not "position"
     
  9. That was just a test. Wasnt going to release it like that. But imma use this to see how to do it. Thanks
     
  10. its an old plugin, it might need to be updated if it doesn't work, but if no one said it bugs i guess it still works ^^
     
  11. Well actually I planned to do this. But well didnt know that your Finder plugin already does that :(

    Code:
    PLUGIN.Title        = "Sleeper Teleport"
    PLUGIN.Description  = "Teleport to sleepers"
    PLUGIN.Author       = "LaserHydra"
    PLUGIN.Version      = V(1,0,0)
    PLUGIN.ResourceId     = "?"function PLUGIN:Init()
        command.AddChatCommand("tps", self.Object, "cmdSleeperTP")
    endfunction PLUGIN:cmdSleeperTP( player, cmd, args )
        if player.net.connection.authLevel == 2 then
            if args.Length == 1 then
                local sleepers = global.BasePlayer.sleepingPlayerList:GetEnumerator()
                local target = args[0]
                while sleepers:MoveNext() do
                    if sleepers.Current.displayName == target or rust.UserIDFromPlayer(sleepers.Current) == target then
                        local pos = sleepers.Current.transform.position
                        player:StartSleeping()
                        rust.ForcePlayerPosition( player, pos.x, pos.y, pos.z )
                        rust.SendChatMessage(player, "SLEEPER-TP", "Teleported to: <color=orange>" .. sleepers.Current.displayName .. "</color>")
                    end
                end
            else
                rust.SendChatMessage(player, "SLEEPER-TP", "Syntax: /tps \"Player\"")
            end
        else
            rust.SendChatMessage(player, "SLEEPER-TP", "You have no permission to use this command!")
        end
    end
     
    Last edited by a moderator: Apr 30, 2015
  12. yeah you can teleport to anything you search with the finder XD
    yeah would be nice if you all look through the plugins before making the same plugin XD (like Pain did with his kill plugin that was already made XD)
     
  13. ^^
    Well sad. My first plugin using the new loop I just kinda learned a bit already exists :c ^^
     
  14. you'll have other occasions ^^
     
  15. Wops xD didnt know
     
  16. maybe he wants more control over the code ;) i'm using couple of your plugins Reneb (namely ZoneManager and Build) and they work wonderfully, but i'm still trying to rewrite all of the functions to our own toolkit, just so we can have controls over compatibility with other plugins and update pacing.
     
  17. build wasnt made for other plugin controls true
    but zone manager shouldnt need any edition to be controlled from outer plugins, i made everything editable and special functions for external plugins.
    [DOUBLEPOST=1430417655][/DOUBLEPOST]best example i can give you for the zone manager is the Jail plugin.
     
  18. yeah, sure, but a) i would like to understand the code i'm using :) and b) with alpha and oxide both being in active dev, there are no guarantees something won't brake along the way. seeing how you do this free of charge, i couldn't demand from you to update them (or even hurry you up). since i plan to implement few concepts that would rely heavily on the zones i'd rather be able to fix and customize things myself.

    that said, i've been glancing over the code and it is true, everything is readable (that's why my "implementation" shouldn't take all that long i think;p) and configurable easily, so if anyone needs a functionality like this and is not a masochist, they should really try it out.