/// <summary> /// If our player spawned and loaded everything. /// </summary> /// <param name="player"></param> /// <param name="se"></param> public void OnPlayerSpawned(Fougerite.Player player, SpawnEvent se) { if (RBConnectionList.ContainsKey(player.UID)) { var data = RBConnectionList[player.UID]; CurrentOnlinePlayers[player.UID] = data; // Lets store the player for later use. Dictionary <ulong, string> IDandHWID = new Dictionary <ulong, string>(); // Create a dictionary to send to the client side. Dictionary <ulong, API.RustBusterUserAPI> CopiedDictionary = new Dictionary <ulong, API.RustBusterUserAPI>(CurrentOnlinePlayers); // Start looping through the dictionary by copying It, so we wont interfere with other for cycles. (Copying is the new Dictionary() above^) foreach (var x in CopiedDictionary.Keys) { IDandHWID[x] = CopiedDictionary[x].HardwareID; } // UDP, using uLink's RPC API. Server -> Client. (Only possible by uLink's API, because RB doesn't support Server to Client connections.) networkView.RPC("ReceiveHardwareIDData", UnityEngine.RPCMode.Others, CopiedDictionary); //You can send RPC to a specific player too using this code: uLink.NetworkView.Get(player.PlayerClient.networkView).RPC("YourOwnRandomString", player.NetworkPlayer, RandomString(8)); RBConnectionList.Remove(player.UID); // Remove player from the temp list. } }
public static void BlueprintUse(IBlueprintItem item, BlueprintDataBlock bdb) { //Fougerite.Player player = Fougerite.Player.FindByPlayerClient(item.controllable.playerClient); Fougerite.Player player = Fougerite.Server.Cache[item.controllable.playerClient.userID]; if (player != null) { BPUseEvent ae = new BPUseEvent(bdb, item); if (OnBlueprintUse != null) { OnBlueprintUse(player, ae); } if (!ae.Cancel) { PlayerInventory internalInventory = player.Inventory.InternalInventory as PlayerInventory; if (internalInventory.BindBlueprint(bdb)) { int count = 1; if (item.Consume(ref count)) { internalInventory.RemoveItem(item.slot); } player.Notice("", "You can now craft: " + bdb.resultItem.name, 4f); } else { player.Notice("", "You already have this blueprint", 4f); } } } }
public void BanPlayer(Fougerite.Player player, string Banner = "Console", string reason = "You were banned.") { string red = "[color #FF0000]"; string green = "[color #009900]"; string white = "[color #FFFFFF]"; foreach (Fougerite.Player pl in Server.GetServer().Players) { if (pl.Admin || pl.Moderator) { pl.Message(red + player.Name + white + " was banned by: " + green + Banner); pl.Message(red + " Reason: " + reason); } } IniParser ini = GlobalBanList; ini.AddSetting("Ips", player.IP, player.Name); ini.AddSetting("Ids", player.SteamID, player.Name); ini.AddSetting("NameIps", player.Name, player.IP); ini.AddSetting("NameIds", player.Name, player.SteamID); ini.AddSetting("AdminWhoBanned", player.Name, Banner); ini.Save(); player.Message(red + " " + reason); player.Message(red + " Banned by: " + Banner); player.Disconnect(); }
public void SendMessageToPlayer(Fougerite.Player player, string function, string data, string data0) { if (player.NetworkPlayer != null && player.PlayerClient?.networkView != null) { uLink.NetworkView.Get(player.PlayerClient.networkView).RPC(function, player.NetworkPlayer, data, data0); } }
private IEnumerator CheckCoroutine() { while (true) { yield return(new WaitForSeconds(1)); foreach (var collider in Physics.OverlapSphere(transform.position, 5)) { if (collider.gameObject.name.Contains("Player")) { var character = collider.GetComponent <Character>(); if (character != null) { var player = new Fougerite.Player(character.playerClient); if (_spawnableObjectBehaviour.SpawnableObject.SteamID == player.SteamID) { var compHealth = player.Health + 1f; if (compHealth > 200) { compHealth = 200; } player.Health = compHealth; collider.GetComponent <HumanBodyTakeDamage>().Bandage(1000); collider.GetComponent <ClientVitalsSync>().SendClientItsHealth(); break; } } } } } }
public void ChangeOwner(Fougerite.Player p) { if (this.IsDeployableObject()) { this.GetObject <DeployableObject>().SetupCreator(p.PlayerClient.controllable); } }
public void SendMessageToPlayer(Fougerite.Player player, string function, int uniqueid, int stacksize) { if (player.NetworkPlayer != null && player.PlayerClient?.networkView != null) { uLink.NetworkView.Get(player.PlayerClient.networkView).RPC(function, player.NetworkPlayer, uniqueid, stacksize); } }
public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments) { Fougerite.Player pl = Fougerite.Server.Cache[Arguments.argUser.userID]; string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(pl); if (!RustPP.Data.Globals.UserIsLogged(pl)) { char ch = '☢'; pl.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f); return; } RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(pl); if (user.ClanID == -1) { if (user.InvitedClan != -1) { user.ClanID = user.InvitedClan; Data.Entities.Clan clan = Data.Globals.Clans.Find(x => x.ID == user.ClanID); user.Clan = clan; user.ClanRank = 1; user.Save(); Data.Globals.SendMessageForClan(user.ClanID, $"[color purple]<!>[/color] El usuario {user.Name} aceptó unirse al clan."); } else { pl.SendClientMessage($"[color red]<!>[/color] ¡No tienes una invitación de clan!"); return; } } else { pl.SendClientMessage($"[color red]<!>[/color] ¡Ya estas en un clan! Usa /clan salir primero"); return; } }
public bool TeleportTo(Fougerite.Player p, float distance = 1.5f, bool callhook = true) { if (this.IsOnline) { if (this == p) // lol { return(false); } try { Transform transform = p.PlayerClient.controllable.transform; // get the target player's transform Vector3 target = transform.TransformPoint(new Vector3(0f, 0f, (this.Admin ? -distance : distance))); // rcon admin teleports behind target player return(this.SafeTeleportTo(target, callhook)); } catch { if (p.Location == Vector3.zero) { return(false); } return(TeleportTo(p.Location, callhook)); } } return(false); }
public bool UnbanByName(string name, string UnBanner = "Consola", Fougerite.Player Sender = null) { var ids = FindIDsOfName(name); var ips = FindIPsOfName(name); string red = "[color #FF0000]"; string green = "[color #009900]"; string white = "[color #FFFFFF]"; if (ids.Count == 0 && ips.Count == 0) { if (Sender != null) { Sender.Message(red + "Couldn't find any names matching with " + name); } return(false); } foreach (Fougerite.Player pl in Players.Where(pl => pl.Admin || pl.Moderator)) { pl.Message(red + name + white + " fue desbaneado por: " + green + UnBanner + white + " Busquedas similares: " + ids.Count); } if (ips.Count > 0) { var iptub = ips.Last(); DataStore.GetInstance().Remove("Ips", iptub); } if (ids.Count > 0) { var idtub = ids.Last(); DataStore.GetInstance().Remove("Ids", idtub); } return(true); }
public StructureMaster CreateSM(Fougerite.Player p, float x, float y, float z, Quaternion rot) { StructureMaster master = NetCull.InstantiateClassic <StructureMaster>(Bundling.Load <StructureMaster>("content/structures/StructureMasterPrefab"), new Vector3(x, y, z), rot, 0); master.SetupCreator(p.PlayerClient.controllable); return(master); }
public ItemMoveEvent(Inventory inst, int fromSlot, Inventory toInventory, int toSlot, Inventory.SlotOperationsInfo info) { _from = inst; _to = toInventory; _fslot = fromSlot; _tslot = toSlot; _iinfo = info; if (toInventory._netListeners != null) // This is null when Rust is placing items. { foreach (uLink.NetworkPlayer netplayer in toInventory._netListeners) { try { NetUser user = netplayer.GetLocalData() as NetUser; if (user != null) { _pl = Fougerite.Server.GetServer().FindPlayer(user.userID); break; } } catch { //ignore } } } }
public object SpawnAtPlayer(string prefab, Fougerite.Player p) { Contract.Requires(!string.IsNullOrEmpty(prefab)); Contract.Requires(p != null); return(this.Spawn(prefab, p.Location, p.PlayerClient.transform.rotation, 1)); }
public static void PlayerHurt(ref DamageEvent e) { try { HurtEvent he = new HurtEvent(ref e); if (!(he.Attacker is NPC) && !(he.Victim is NPC)) { Fougerite.Player attacker = he.Attacker as Fougerite.Player; Fougerite.Player victim = he.Victim as Fougerite.Player; Zone3D zoned = Zone3D.GlobalContains(attacker); if ((zoned != null) && !zoned.PVP) { attacker.Message("You are in a PVP restricted area."); he.DamageAmount = 0f; e = he.DamageEvent; return; } zoned = Zone3D.GlobalContains(victim); if ((zoned != null) && !zoned.PVP) { attacker.Message(victim.Name + " is in a PVP restricted area."); he.DamageAmount = 0f; e = he.DamageEvent; return; } } if (OnPlayerHurt != null) { OnPlayerHurt(he); } e = he.DamageEvent; } catch { } }
public ItemPickupEvent(Controllable controllable, IInventoryItem item, Inventory local, Inventory.AddExistingItemResult result) { _player = Fougerite.Server.Cache[controllable.netUser.userID]; _item = item; _inv = local; _result = result; switch (result) { case Inventory.AddExistingItemResult.CompletlyStacked: _pickedup = true; break; case Inventory.AddExistingItemResult.Moved: _pickedup = true; break; case Inventory.AddExistingItemResult.PartiallyStacked: _pickedup = true; break; case Inventory.AddExistingItemResult.Failed: _pickedup = false; break; case Inventory.AddExistingItemResult.BadItemArgument: _pickedup = false; break; default: _pickedup = false; break; } }
public InventoryModEvent(Inventory inventory, int slot, IInventoryItem item, string type) { this._inventory = inventory; this._slot = slot; this._item = item; this._etype = type; if (inventory._netListeners != null) // This is null when Rust is filling up the boxes with loot. { foreach (uLink.NetworkPlayer netplayer in inventory._netListeners) { try { NetUser user = netplayer.GetLocalData() as NetUser; if (user != null) { _netuser = user; _player = Fougerite.Server.GetServer().FindPlayer(_netuser.userID); _netplayer = netplayer; break; } } catch { //ignore } } } this._finventory = new FInventory(_inventory); }
public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments) { Fougerite.Player pl = Fougerite.Server.Cache[Arguments.argUser.userID]; string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(pl); if (!RustPP.Data.Globals.UserIsLogged(pl)) { char ch = '☢'; pl.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f); return; } using (MySqlConnection connection = new MySqlConnection(Data.Database.Connection.GetConnectionString())) { pl.SendClientMessage($"--------- [color blue]Clanes - TOP 10[/color] ---------"); connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM clans ORDER BY level DESC LIMIT 10"; MySqlDataReader reader = command.ExecuteReader(); DataTable schemaTable = reader.GetSchemaTable(); int puesto = 1; while (reader.HasRows) { while (reader.Read()) { int nivel = reader.GetInt32("level"); string owner = reader.GetString("owner"); string name = reader.GetString("name"); pl.SendClientMessage($"#{puesto} [color blue]{name}[/color] | Nivel [color blue]{nivel.ToString()}[/color] - Lider: [color blue]{owner}[/color]"); puesto++; } reader.NextResult(); } } }
public PlayerInv(Fougerite.Player player) { Contract.Requires(player != null); this.player = player; this._inv = player.PlayerClient.controllable.GetComponent <Inventory>(); if (_inv == null) { throw new InvalidOperationException("Player's inventory component is null."); } Contract.Assert(_inv != null); this._items = new PlayerItem[30]; this._armorItems = new PlayerItem[4]; this._barItems = new PlayerItem[6]; for (int i = 0; i < this._inv.slotCount; i++) { if (i < 30) { this.Items[i] = new PlayerItem(this._inv, i); } else if (i < 0x24) { this.BarItems[i - 30] = new PlayerItem(this._inv, i); } else if (i < 40) { this.ArmorItems[i - 0x24] = new PlayerItem(this._inv, i); } } }
public static bool PlayerConnect(NetUser user) { bool connected = false; try { if (user.playerClient == null) { Logger.LogDebug("PlayerConnect user.playerClient is null"); return(false); } Fougerite.Player item = new Fougerite.Player(user.playerClient); Fougerite.Server.GetServer().Players.Add(item); Logger.LogDebug("User Connected: " + item.Name + " (" + item.SteamID.ToString() + " | " + item.PlayerClient.netPlayer.ipAddress + ")"); if (OnPlayerConnected != null) { OnPlayerConnected(item); } connected = user.connected; if (Fougerite.Config.GetValue("Fougerite", "tellversion") != "false") { item.Message("This server is powered by Fougerite v." + Bootstrap.Version + "!"); } return(connected); } catch (Exception ex) { Logger.LogException(ex); } return(connected); }
public static void FPS(Fougerite.Player player, bool active) { RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(player); if (active) { player.SendCommand("render.fov 60"); player.SendCommand("grass.on True"); player.SendCommand("grass.forceredraw True"); player.SendCommand("grass.displacement True"); player.SendCommand("grass.disp_trail_seconds 1"); player.SendCommand("grass.shadowcast True"); player.SendCommand("grass.shadowreceive True"); player.SendCommand("render.level 1"); player.SendCommand("render.frames 1"); player.SendCommand("render.vsync True"); player.SendCommand("footsteps.quality 2"); player.SendCommand("gfx.ssaa True"); player.SendCommand("gfx.bloom True"); player.SendCommand("gfx.grain True"); player.SendCommand("gfx.ssao True"); player.SendCommand("gfx.tonemap True"); player.SendCommand("gfx.shafts True"); player.SendCommand("water.level 1"); player.SendCommand("render.distance 1"); player.SendCommand("terrain.idleinterval 4"); player.SendCommand("water.reflection True"); player.SendCommand("config.save"); player.SendClientMessage("[color cyan]<!>[/color] FPS Desactivado."); user.FPS = false; } else { player.SendCommand("grass.on false"); player.SendCommand("grass.forceredraw false"); player.SendCommand("grass.displacement false"); player.SendCommand("grass.disp_trail_seconds 99999"); player.SendCommand("grass.shadowcast false"); player.SendCommand("grass.shadowreceive false"); player.SendCommand("render.level 0"); player.SendCommand("render.frames 0"); player.SendCommand("render.vsync false"); player.SendCommand("footsteps.quality 0"); player.SendCommand("gfx.ssaa false"); player.SendCommand("gfx.bloom false"); player.SendCommand("gfx.grain false"); player.SendCommand("gfx.ssao false"); player.SendCommand("gfx.damage false"); player.SendCommand("gfx.tonemap false"); player.SendCommand("gfx.shafts false"); player.SendCommand("render.distance 0"); player.SendCommand("render.fov 60"); player.SendCommand("water.level -1"); player.SendCommand("terrain.idleinterval 0"); player.SendCommand("water.reflection false"); player.SendCommand("config.save"); player.SendClientMessage("[color cyan]<!>[/color] FPS Activado."); user.FPS = false; } }
public ItemPickupEvent(Controllable controllable, IInventoryItem item, Inventory local, Inventory.AddExistingItemResult result, PickupEventType type) { _player = Fougerite.Server.Cache[controllable.netUser.userID]; _item = item; _inv = local; _result = result; _type = type; }
public bool Contains(Fougerite.Player p) { if (p == null) { return(false); } return(this.Contains(p.Location)); }
public static string GetPlayerLangOrDefault(Fougerite.Player pl) { if (!Core.userLang.ContainsKey(pl.UID)) { return("ES"); } return(Core.userLang[pl.UID]); }
public Vector3 Infront(Fougerite.Player p, float length) { Contract.Requires(p != null); Contract.Requires(!float.IsInfinity(length)); Contract.Requires(!float.IsNaN(length)); return(p.PlayerClient.controllable.transform.position + ((Vector3)(p.PlayerClient.controllable.transform.forward * length))); }
public FallDamageEvent(FallDamage fd, float speed, float num, bool flag, bool flag2) { _fd = fd; _player = Fougerite.Server.Cache[fd.idMain.netUser.userID]; _fallspeed = speed; _num = num; _flag = flag; _flag2 = flag2; }
public BeltUseEvent(InventoryHolder holder, int belt) { _holder = holder; _belt = belt; if (holder.netUser != null) { _player = Fougerite.Server.GetServer().FindPlayer(holder.netUser.userID); } }
public bool TeleportTo(Fougerite.Player p) { if (this.IsOnline) { return(this.TeleportTo(p, 1.5f)); } return(false); }
public void OnCommand(Fougerite.Player player, string command, string[] args) { if (CommandList.Count != 0 && !CommandList.Contains(command) && !Fougerite.Server.ForceCallForCommands.Contains(command)) { return; } this.Invoke("On_Command", new object[] { player, command, args }); }
public void AirdropAtPlayer(Fougerite.Player p, int rep) { Contract.Requires(p != null); Contract.Requires(rep >= 0); for (int i = 0; i < rep; i++) { SupplyDropZone.CallAirDropAt(p.Location); } }
public BowShootEvent(BowWeaponDataBlock bw, ItemRepresentation ir, uLink.NetworkMessageInfo ui, IBowWeaponItem ibw) { TakeDamage local = ibw.inventory.GetLocal <TakeDamage>(); _player = Fougerite.Server.Cache[local.GetComponent <Character>().netUser.userID]; _bw = bw; _ibw = ibw; _ir = ir; _unmi = ui; }
public PlayerInv(Fougerite.Player player) { Contract.Requires(player != null); this.player = player; this._inv = player.PlayerClient.controllable.GetComponent<Inventory>(); if (_inv == null) throw new InvalidOperationException("Player's inventory component is null."); Contract.Assert(_inv != null); this._items = new PlayerItem[30]; this._armorItems = new PlayerItem[4]; this._barItems = new PlayerItem[6]; for (int i = 0; i < this._inv.slotCount; i++) { if (i < 30) this.Items[i] = new PlayerItem(this._inv, i); else if (i < 0x24) this.BarItems[i - 30] = new PlayerItem(this._inv, i); else if (i < 40) this.ArmorItems[i - 0x24] = new PlayerItem(this._inv, i); } }
public static bool PlayerConnect(NetUser user) { bool connected = false; try { if (user.playerClient == null) { Logger.LogDebug("PlayerConnect user.playerClient is null"); return false; } Fougerite.Player item = new Fougerite.Player(user.playerClient); Fougerite.Server.GetServer().Players.Add(item); Logger.LogDebug("User Connected: " + item.Name + " (" + item.SteamID.ToString() + " | " + item.PlayerClient.netPlayer.ipAddress + ")"); if (OnPlayerConnected != null) OnPlayerConnected(item); connected = user.connected; if (Fougerite.Config.GetValue("Fougerite", "tellversion") != "false") item.Message("This server is powered by Fougerite v." + Bootstrap.Version + "!"); return connected; } catch (Exception ex) { Logger.LogException(ex); } return connected; }