public static void CopyPersistantMessages(ref RustProto.Avatar.Builder builder, ref RustProto.Avatar avatar) { builder.ClearBlueprints(); for (int i = 0; i < avatar.BlueprintsCount; i++) { builder.AddBlueprints(avatar.GetBlueprints(i)); } }
void OnPlayerSpawn(PlayerClient player, bool useCamp, RustProto.Avatar avatar) { if (KitsConfig["autokit"] == null) return; if (avatar != null && avatar.HasPos && avatar.HasAng) return; object thereturn = Interface.GetMod().CallHook("canRedeemKit", new object[] { player.netUser }); if (thereturn == null) { timer.Once(0.01f, () => StripAndGiveKit(player.netUser, "autokit")); } }
private void OnPlayerSpawn(PlayerClient client, bool useCamp, RustProto.Avatar avatar) { HookCalled("OnPlayerSpawn"); // Print spawn location in console Puts("Player " + client.netUser.displayName + " spawned at " + client.lastKnownPosition + "."); Puts("Player did " + (useCamp ? "" : "not ") + "select a sleepingbag to spawn at."); // Doing stuff with the player needs to wait until the next frame NextTick(() => { // Print start metabolism values in console var player = client.controllable; var character = player.character; var metabolism = character.GetComponent<Metabolism>(); Puts(client.netUser.displayName + " currently has the following Metabolism values:"); Puts(" Health: " + character.health.ToString()); Puts(" Calories: " + metabolism.GetCalorieLevel().ToString()); Puts(" Radiation: " + metabolism.GetRadLevel().ToString()); // Give admin items for testing if (client.netUser.CanAdmin()) { var inventory = player.GetComponent<Inventory>(); var pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Belt, false, Inventory.Slot.KindFlags.Belt); var item = DatablockDictionary.GetByName("Uber Hatchet"); inventory.AddItemAmount(item, 1, pref); } }); }
public static RustProto.User.Builder SetNameOnJoin(string value, RustProto.User.Builder builder) { Google.ProtocolBuffers.ThrowHelper.ThrowIfNull(value, "value"); builder.PrepareBuilder(); builder.result.hasDisplayname = true; string userName = value; try { foreach (KeyValuePair<string, string> kv in rankPrefixes) { userName = userName.Replace("[" + kv.Key + "]", ""); userName = userName.Replace(kv.Value, ""); } foreach (KeyValuePair<string, string> kv in playerPrefixes) { userName = userName.Replace("[" + kv.Value + "]", ""); } userName = userName.Replace("<G> ", ""); userName = userName.Replace("* <G> ", ""); userName = userName.Replace("<D> ", ""); userName = userName.Replace("* <D> ", ""); userName = userName.Replace("<F> ", ""); userName = userName.Replace("* <F> ", ""); bool nameOccupied = Array.FindAll(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName == userName).Count() > 0; int instanceNum = 0; if (nameOccupied && !kickDuplicate) { instanceNum = Array.FindAll(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName == userName).Count(); nameOccupied = Array.FindAll(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName == userName + " (" + instanceNum + ")").Count() > 0; while (nameOccupied) { instanceNum++; nameOccupied = Array.FindAll(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.userName == userName + " (" + instanceNum + ")").Count() > 0; } string newName = userName + " (" + instanceNum + ")"; } } catch (Exception ex) { Vars.conLog.Error(ex.ToString()); } builder.result.displayname_ = userName; return builder; }
private void OnPlayerSpawn(PlayerClient client, bool useCamp, RustProto.Avatar avater) { HookCalled("OnPlayerSpawn"); // TODO: Print spawn location // TODO: Print start metabolism values // TODO: Give admin items for testing }