I have a problem when I try to give items to sleepers.
The sleepers do receive the items, but after that all sleepers appear as online players suddenly.
Players who want to connect get a message that they are already connected.
Even if I give items to only one sleeper, they all appear as online.
Does anyone have an idea what is going wrong?
Giving items to sleepers?
Discussion in 'Rust Development' started by GonzoTheThird, Feb 16, 2017.
-
Show your code.
-
I think:
Code:foreach (var pl in BasePlayer.activePlayerList) { //activePlayerList - its only for online sleepers if(pl.isSleeping()) { player.inventory.GiveItem(ItemManager.CreateByItemID(-____ID_ITEM___, ___HOWMUCH_)); } }
-
I tried various code.
The Sample from zhulenejsnek also causes the Problem. -
Code:
void Giveitem(string id, int itemid, int amount){ foreach(BasePlayer player in BasePlayer.sleepingPlayerList) if(player.isSleeping() && player.UserIDString == id) player.inventory.GiveItem(ItemManager.CreateByID(itemid, amount)); }