Reign of Kings Turn off ropes

Discussion in 'Plugin Requests' started by Upperking, May 30, 2015.

  1. Can we turn ropes off somehow?
     
  2. Rather than posting my own thread its the same idea.

    Any way to make a "Only rope at Night" plugin? to work with KoS Night?
    I have looked into it myself and had nothing but failures.
    Thanks.
     
  3. I will try to do this rly fast before i go to sleep ;x
     
  4. You are a legend
     
  5. Check your private messages .. I sent u the plugin because i couldnt test it.
     
  6. ok i will test it now.
     
  7. Could you please share this plugin even if it doesn't work? Sharing is caring, thank you ^^
     
  8. Nah it wont work anyway.. i will try to find anothet way to do this
     
  9. Any way to remove an item from someone when its day? aka ropes? or even stop them equipping a rope? Just throwing out ideas other than what you've already tried.

    Thanks for your interest though much appreciated.
     
  10. Hello,

    I've been following this thread for a while now and since nobody has any improvement over this, I decided to completely remove ropes and iron shackles to avoid player capturing for now -- I also tried to make OnPlayerCapture work without success.

    I simply set up a timer which remove ropes every X seconds when it finds one in someones inventory. Point me in the right direction if anything is wrong here
    Code:
            timer.Repeat(5,0,DeleteCaptureDevices);
            public void DeleteCaptureDevices()
            {
                foreach(Player player in Server.AllPlayers)
                {
                    if (
                        player != null
                        && player.DisplayName != null
                        && player.DisplayName != "Server"
                        && player.GetInventory() != null
                        && player.GetInventory().Contents != null
                    )
                    {
                        if (Server.PlayerIsOnline(player.DisplayName))
                        {
                            var inventory = player.GetInventory().Contents;
                            foreach (var item in inventory.Where(item => item != null)) // InvGameItemStack
                            {
                                if (item.Name == "Rope" || item.Name == "Iron Shackles")
                                {
                                    inventory.SplitItem(item, 1, true);
                                }
                            }
                        }
                    }
                }
            }
    
    This code (with appropriate libraries ofc) does all the work, does not impact server performance. However, it seems like some of the players are excluded from this removal and be able to craft and equip ropes. I tried different ways to execute this code but still problems with that. Maybe bad coding?
     
    Last edited by a moderator: Oct 30, 2015
  11. Looks pretty good to me, Maybe that could even be hooked into the time of day, So it only removes the ropes when it hits a certain time of day, Thanks for your input i will try it out and see how it goes.

    Much appreciated.
    [DOUBLEPOST=1446231652][/DOUBLEPOST]For some reason this part isn't working.

    Code:
    foreach (var item in inventory.Where(item => item != null)) // InvGameItemStack
                            {
                                if (item.Name == "Rope" || item.Name == "Iron Shackles")
                                {
                                    inventory.SplitItem(item, 1, true);
                                }
                            }
     
  12. Hello again,

    I did some debugging and found out that "if (Server.PlayerIsOnline(player.DisplayName))" is excluding some of the players from Server.AllPlayers

    I removed this if check and it seems to work without problems now. I will check this thoroughly when lots of players fill the server in afternoon.
     
  13. Cheers for the reply, What i meant to say was it executes fine when i debugged your script, Its just no one's rope were removed? I may be missing something.