Example #1
0
 internal RustLegacyLivePlayer(NetUser netUser)
 {
     this.netUser = netUser;
     steamid = netUser.userID;
     Character = this;
     Object = netUser.playerClient;
 }
Example #2
0
 void cmdChatProd(NetUser netuser, string command, string[] args)
 {
     if (!hasAccess(netuser)) { SendReply(netuser, "You don't have access to this command"); return; }
     cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent<Character>();
     if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { SendReply(netuser, "Are you looking at the sky?"); return; }
     if (cachedhitInstance != null)
     {
         cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
         if (cachedCollider == null) { SendReply(netuser, "Can't prod what you are looking at"); return; }
         cachedStructure = cachedCollider.GetComponent<StructureComponent>();
         if (cachedStructure != null && cachedStructure._master != null)
         {
             cachedMaster = cachedStructure._master;
             var name = PlayerDatabase?.Call("GetPlayerData", cachedMaster.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "UnknownPlayer" : name.ToString()));
             return;
         }
     }
     else
     {
         cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>();
         if (cachedDeployable != null)
         {
             var name = PlayerDatabase?.Call("GetPlayerData", cachedDeployable.ownerID.ToString(), "name");
             SendReply(netuser, string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
             return;
         }
     }
     SendReply(netuser, string.Format("Can't prod what you are looking at: {0}",cachedRaycast.collider.gameObject.name));
 }
Example #3
0
 void cmdSpawnOpen(NetUser player, string command, string[] args)
 {
     if (!hasAccess(player)) return;
     if (SpawnsData.ContainsKey(player))
     {
         SendReply(player, "You must save/close your current spawns first. /spawns_help for more informations");
         return;
     }
     if (args == null || args.Length == 0)
     {
         SendReply(player, "/spawns_remove SPAWN_NUMBER");
         return;
     }
     var NewSpawnFile = Interface.GetMod().DataFileSystem.GetDatafile(args[0].ToString());
     if (NewSpawnFile["1"] == null)
     {
         SendReply(player, "This spawnfile is empty or not valid");
         return;
     }
     SpawnsData.Add(player, new List<Vector3>());
     foreach (KeyValuePair<string, object> pair in NewSpawnFile)
     {
         var currentvalue = pair.Value as Dictionary<string, object>;
         ((List<Vector3>)SpawnsData[player]).Add(new Vector3(Convert.ToInt32(currentvalue["x"]), Convert.ToInt32(currentvalue["y"]), Convert.ToInt32(currentvalue["z"])));
     }
     SendReply(player, string.Format("Opened spawnfile with {0} spawns", ((List<Vector3>)SpawnsData[player]).Count.ToString()));
 }
 void cmdChatClean(NetUser netuser, string command, string[] args)
 {
     if (!hasAccess(netuser)) { SendReply(netuser, "You dont have access to this command."); return; }
     if(args.Length == 0)
     {
         SendReply(netuser, "You must enter deployed item name that you want to clean.");
         SendReply(netuser, "Not using the option: \"all\" will only clean items that are not on a structure.");
         SendReply(netuser, "using the option: \"all\" will only clean all the items.");
         SendReply(netuser, "/clean DEPLOYNAME optional:all");
         return;
     }
     cachedName = args[0].ToLower();
     int totalCleaned = 0;
     bool all = (args.Length > 1 && args[1] == "all") ? true : false;
     switch (args[0].ToLower())
     {
         case "lootsack":
         case "bag":
         case "lootsacks":
         case "bags":
             totalCleaned = CleanAllSacks(all);
         break;
         default:
             var getvalidname = ValidDeploy(cachedName);
             if (getvalidname == null)
             {
                 SendReply(netuser, string.Format("{0} is not a valid deploy name.", args[0]));
                 return;
             }
             cachedName = (string)getvalidname;
             totalCleaned = CleanAllDeployables(cachedName, all);
         break;
     }
     SendReply(netuser, string.Format("You've successfully cleaned {0} {1}.", totalCleaned.ToString(), args[0]));
 }
Example #5
0
        public void uLink_OnPlayerConnected(uLink.NetworkPlayer player)
        {
            connectingPlayer = (NetUser)player.localData;
            String playerSteamURL = "http://steamcommunity.com/profiles/" + connectingPlayer.userID.ToString();

            WebClient wc = new WebClient ();
            wc.DownloadStringCompleted += (sender, e) =>
            {
                userProfilePage = e.Result;

                if (lockGroup != "none")
                {
                    if (userProfilePage.IndexOf("http://steamcommunity.com/groups/" + lockGroup) == -1)
                    {
                        connectingPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
                    }
                }

                Match vacMatch = Regex.Match(userProfilePage, @"^([0-9]{1,5}) day\(s\) since last ban$");
                if (vacMatch.Success)
                {
                    int daysSinceBan = Convert.ToInt32(vacMatch.Groups[1].Value);
                    if (daysSinceBan < minVacDays)
                    {
                        connectingPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
                    }
                }
            };

            wc.DownloadStringAsync(new Uri(playerSteamURL));
        }
 void cmdChatHouse(NetUser player, string command, string[] args)
 {
     if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; }
     if (args.Length == 0) { SendReply(player, "/house STEAMID/name"); return; }
     string[] steamids;
     ulong teststeam;
     if(args.Length == 1 && args[0].Length == 17 && ulong.TryParse(args[0],out teststeam))
     {
         steamids = new string[] { teststeam.ToString() };
     }
     else
     {
         var tempsteamids = PlayerDatabase.Call("FindAllPlayers", args[0]);
         if(tempsteamids == null)
         {
             SendReply(player, "You must have the Player Database plugin to use this plugin.");
             return;
         }
         steamids = (string[])tempsteamids;
         if(steamids.Length == 0)
         {
             SendReply(player, "No Players found.");
             return;
         }
     }
     userIDToStructure.Clear();
     foreach (StructureMaster master in (List<StructureMaster>)StructureMaster.AllStructures)
     {
         if (userIDToStructure[master.ownerID] == null)
             userIDToStructure[master.ownerID] = new List<StructureMaster>();
         userIDToStructure[master.ownerID].Add(master);
     }
     if (userTeleports[player] == null)
         userTeleports[player] = new List<Vector3>();
     userTeleports[player].Clear();
     int currentid = 0;
     for (int i = 0; i < steamids.Length; i++)
     {
         cachedSteamID = steamids[i];
         cachedsteamid = Convert.ToUInt64(cachedSteamID);
         cachedName = "Unknown";
         var tempname = PlayerDatabase?.Call("GetPlayerData", cachedSteamID, "name");
         if (tempname != null)
             cachedName = tempname.ToString();
         if(userIDToStructure[cachedsteamid] == null)
         {
             SendReply(player, string.Format("{0} - {1}: No Structures Found.",cachedSteamID,cachedName));
             continue;
         }
         foreach(StructureMaster master in userIDToStructure[cachedsteamid])
         {
             cachedVector3 = FindFirstComponent(master);
             userTeleports[player].Add(cachedVector3);
             SendReply(player, string.Format("{3} - {0} - {1}: {2}", cachedSteamID, cachedName, cachedVector3.ToString(), currentid.ToString()));
             currentid++;
         }
     }
 }
Example #7
0
 public void SendChatMessage(NetUser netUser, string name, string message = null)
 {
     if (message == null)
     {
         message = name;
         name = "Server";
     }
     ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"chat.add {QuoteSafe(name)} {QuoteSafe(message)}");
 }
Example #8
0
 void cmdSpawnshelp(NetUser player, string command, string[] args)
 {
     if (!hasAccess(player)) return;
     SendReply(player, "Start by making a new data with: /spawns_new");
     SendReply(player, "Add new spawn points where you are standing with /spawns_add");
     SendReply(player, "Remove a spawn point that you didn't like with /spawns_remove NUMBER");
     SendReply(player, "Save the spawn points into a file with: /spawns_save FILENAME");
     SendReply(player, "Use /spawns_open later on to open it back and edit it");
     SendReply(player, "Use /spawns_close to stop setting points without saving");
 }
Example #9
0
 void cmdSpawnAdd(NetUser player, string command, string[] args)
 {
     if (!hasAccess(player)) return;
     if (!(SpawnsData.ContainsKey(player)))
     {
         SendReply(player, "You must create/open a new Spawn file first /spawns_help for more informations");
         return;
     }
     ((List<Vector3>)SpawnsData[player]).Add(player.playerClient.lastKnownPosition);
     SendReply(player, string.Format("Added Spawn n°{0}", ((List<Vector3>)SpawnsData[player]).Count));
 }
Example #10
0
 void cmdSpawnsClose(NetUser player, string command, string[] args)
 {
     if (!hasAccess(player)) return;
     if (!(SpawnsData.ContainsKey(player)))
     {
         SendReply(player, "You must create a new Spawn file first /spawns_help for more informations");
         return;
     }
     SpawnsData.Remove(player);
     SendReply(player, "Spawns file closed without saving");
 }
Example #11
0
 void cmdAddKit(NetUser netuser, string[] args)
 {
     if (args.Length < 3)
     {
         SendReply(netuser, "/kit add \"KITNAME\" \"DESCRIPTION\" -option1 -option2 etc, Everything you have in your inventory will be used in the kit");
         SendReply(netuser, "Options avaible:");
         SendReply(netuser, "-maxXX => max times someone can use this kit. Default is infinite.");
         SendReply(netuser, "-cooldownXX => cooldown of the kit. Default is none.");
         SendReply(netuser, "-vip => Allow to give this kit only to vip & admins");
         SendReply(netuser, "-admin => Allow to give this kit only to admins (set this for the autokit!!!!)");
         return;
     }
     string kitname = args[1].ToString();
     string description = args[2].ToString();
     bool vip = false;
     bool vipp = false;
     bool vippp = false;
     bool admin = false;
     int max = -1;
     double cooldown = 0.0;
     if (KitsConfig[kitname] != null)
     {
         SendReply(netuser, string.Format("The kit {0} already exists. Delete it first or change the name.", kitname));
         return;
     }
     if (args.Length > 3)
     {
         object validoptions = VerifyOptions(args, out admin, out vip, out vipp, out vippp, out max, out cooldown);
         if (validoptions is string)
         {
             SendReply(netuser, (string)validoptions);
             return;
         }
     }
     Dictionary<string, object> kitsitems = GetNewKitFromPlayer(netuser);
     Dictionary<string, object> newkit = new Dictionary<string, object>();
     newkit.Add("items", kitsitems);
     if (admin)
         newkit.Add("admin", true);
     if (vip)
         newkit.Add("vip", true);
     if (vipp)
         newkit.Add("vip+", true);
     if (vippp)
         newkit.Add("vip++", true);
     if (max >= 0)
         newkit.Add("max", max);
     if (cooldown > 0.0)
         newkit.Add("cooldown", cooldown);
     newkit.Add("description", description);
     KitsConfig[kitname] = newkit;
     SaveKits();
 }
Example #12
0
 void cmdChatFly(NetUser netuser, string command, string[] args)
 {
     if(!hasAccess(netuser)) { SendReply(netuser, "You dont have access to this command."); return; }
     if (args.Length == 0 && netuser.playerClient.GetComponent<FlyPlayer>())
     {
         GameObject.Destroy(netuser.playerClient.GetComponent<FlyPlayer>());
         return;
     }
     float speed = 1f;
     if (args.Length > 0) float.TryParse(args[0], out speed);
     FlyPlayer newfly = netuser.playerClient.GetComponent<FlyPlayer>();
     if(newfly == null) newfly = netuser.playerClient.gameObject.AddComponent<FlyPlayer>();
     newfly.Refresh();
     newfly.speed = speed;
 }
Example #13
0
 void OnPlayerConnected(NetUser netuser)
 {
     IsCountryBlocked(netuser.displayName, netuser.userID.ToString(), IpAddress(netuser.networkPlayer.ipAddress));
 }
Example #14
0
 /// <summary>
 /// Print a message to a players chat log
 /// </summary>
 /// <param name="netUser"></param>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToChat(NetUser netUser, string format, params object[] args)
 {
     ConsoleNetworker.SendClientCommand(netUser.networkPlayer, "chat.add \"Server\" " + string.Format(format, args).Quote());
 }
Example #15
0
 private void base_OnPlayerInit(NetUser netUser) => AddOnlinePlayer(netUser);
Example #16
0
        void TryGiveKit(NetUser netuser, string kitname)
        {
            if (KitsConfig[kitname] == null)
            {
                SendReply(netuser, unknownKit);
                return;
            }
            object thereturn = Interface.GetMod().CallHook("canRedeemKit", netuser );
            if (thereturn != null)
            {
                if (thereturn is string)
                {
                    SendReply(netuser, (string)thereturn);
                }
                return;
            }

            Dictionary<string, object> kitdata = (KitsConfig[kitname]) as Dictionary<string, object>;
            double cooldown = 0.0;
            int kitleft = 1;
            if (kitdata.ContainsKey("max"))
                kitleft = GetKitLeft(netuser, kitname, (int)(kitdata["max"]));
            if (kitdata.ContainsKey("admin"))
                if(!hasAccess(netuser))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            if (kitdata.ContainsKey("vip"))
                if (!hasVip(netuser,"vip"))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            if (kitdata.ContainsKey("vip+"))
                if (!hasVip(netuser, "vip+"))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            if (kitdata.ContainsKey("vip++"))
                if (!hasVip(netuser, "vip++"))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            if (kitleft <= 0)
            {
                SendReply(netuser, maxKitReached);
                return;
            }
            if (kitdata.ContainsKey("cooldown"))
                cooldown = GetKitTimeleft(netuser, kitname, (double)(kitdata["cooldown"]));
            if (cooldown > 0.0)
            {
                SendReply(netuser, string.Format("You must wait {0}s before using this kit again", cooldown.ToString()));
                return;
            }
            object wasGiven = GiveKit(netuser, kitname);
            if ((wasGiven is bool) && !((bool)wasGiven))
            {
                Puts(string.Format("An error occurred while giving the kit {0} to {1}", kitname, netuser.playerClient.userName.ToString()));
                return;
            }
            proccessKitGiven(netuser, kitname, kitdata, kitleft);
        }
Example #17
0
 bool hasVip(NetUser netuser, string vipname)
 {
     if (netuser.CanAdmin()) return true;
     return permission.UserHasPermission(netuser.playerClient.userID.ToString(), vipname);
 }
Example #18
0
 double GetKitTimeleft(NetUser netuser, string kitname, double max)
 {
     if (KitsData[netuser.playerClient.userID.ToString()] == null) return 0.0;
     var data = KitsData[netuser.playerClient.userID.ToString()] as Dictionary<string, object>;
     if (!(data.ContainsKey(kitname))) return 0.0;
     var currentkit = data[kitname] as Dictionary<string, object>;
     if (!(currentkit.ContainsKey("cooldown"))) return 0.0;
     return ((double)currentkit["cooldown"] - CurrentTime());
 }
Example #19
0
 void cmdChatKits(NetUser player, string command, string[] args)
 {
     if (args.Length > 0 && (args[0].ToString() == "add" || args[0].ToString() == "reset" || args[0].ToString() == "remove"))
     {
         if (!hasAccess(player))
         {
             SendReply(player, noAccess);
             return;
         }
         if (args[0].ToString() == "add")
             cmdAddKit(player, args);
         else if (args[0].ToString() == "reset")
             cmdResetKits(player, args);
         else if (args[0].ToString() == "remove")
             cmdRemoveKit(player, args);
         return;
     }
     if (args.Length == 0)
     {
         SendList(player);
         return;
     }
     TryGiveKit(player, args[0]);
 }
Example #20
0
 public static void deployableKO(DeployableObject dep, DamageEvent e)
 {
     try
     {
         InstaKOCommand command = ChatCommand.GetCommand("instako") as InstaKOCommand;
         if (command.IsOn(e.attacker.client.userID))
         {
             try
             {
                 Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", NetUser.FindByUserID(dep.ownerID).displayName, "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
             }
             catch
             {
                 if (Core.userCache.ContainsKey(dep.ownerID))
                 {
                     Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", Core.userCache[dep.ownerID], "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
                 }
             }
             dep.OnKilled();
         }
         else
         {
             dep.UpdateClientHealth();
         }
     }
     catch
     {
         dep.UpdateClientHealth();
     }
 }
Example #21
0
 void Request(string page, NetUser playertoinsult)
 {
     webrequest.EnqueueGet(page, (code, response) => GetCallback(code, response, page, playertoinsult), this);
 }
Example #22
0
 public static PlayerInventory GetInventory(NetUser netUser) => playerData[netUser].inventory;
Example #23
0
 public static Character GetCharacter(NetUser netUser) => playerData[netUser].character;
Example #24
0
        void ForcePlayerPos(NetUser player, Vector3 xyz)
        {
            var management = RustServerManagement.Get();

            management.TeleportPlayerToWorld(player.playerClient.netPlayer, xyz);
        }
Example #25
0
        void cmdWarp(NetUser player, string cmdd, string[] args)
        {
            if (args.Length == 0)
            {
                if (permission.UserHasPermission(player.userID.ToString(), "warp.admin"))
                {
                    SendReply(player, "[color cyan]Available Commands[color white]");
                    SendReply(player, "[color cyan]-[color white] /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>");
                    SendReply(player, "[color cyan]-[color white] /warp limit");
                    SendReply(player, "[color cyan]-[color white] /warp remove <WarpName>");
                    SendReply(player, "[color cyan]-[color white] /warp wipe");
                    SendReply(player, "[color cyan]-[color white] /warp list");
                    SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list");
                    SendReply(player, "[color cyan]Teleport all online players[color white]: \n[color cyan]-[color white] /warp all <WarpName>");
                }
                else
                {
                    SendReply(player, "[color cyan]Available Commands[color white]");
                    SendReply(player, "[color cyan]-[color white] /warp list");
                    SendReply(player, "[color cyan]-[color white] /warp limit");
                    SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list");
                }
                return;
            }
            ulong steamId = player.userID;
            float nextteletime;

            switch (args[0])
            {
            case "limit":
                SendReply(player, "[color cyan]Current Warp Limits[color white]");

                if (storedData.cantele.TryGetValue(steamId, out nextteletime))
                {
                    int nexttele = Convert.ToInt32(nextteletime - Time.realtimeSinceStartup);
                    if (nexttele <= 0)
                    {
                        nexttele = 0;
                    }
                    SendReply(player, $"You will be able to warp again in {nexttele.ToString()} seconds");
                }
                SendReply(player, $"Warp Cooldown: [color orange]{cooldown.ToString()}[color white]");
                SendReply(player, $"Warp Cooldown Enabled: [color orange]{enablecooldown.ToString()}[color white]");
                SendReply(player, "[color cyan]*************[color white]");
                break;

            case "back":
                if (permission.UserHasPermission(player.userID.ToString(), "canback"))
                {
                    SendReply(player, "Teleporting to you last saved locations in {0} seconds.", warpbacktimer.ToString());
                    timer.Once(warpbacktimer, () => {
                        ForcePlayerPos(player, new Vector3(storedData.lastposition[steamId].OldX, storedData.lastposition[steamId].OldY, storedData.lastposition[steamId].OldZ));
                        SendReply(player, backtolastloc);
                        storedData.lastposition.Remove(steamId);
                        Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                    });
                }
                break;

            /*case "random":
             * player.SendConsoleCommand($"chat.say \"/warp to {GetRandomId(player).ToString()}\" ");
             * break;*/

            case "all":
                if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin"))
                {
                    SendReply(player, "You do not have permission to use this command!");
                    return;
                }
                if (args.Length == 2)
                {
                    foreach (PlayerClient current in PlayerClient.All)
                    {
                        foreach (WarpInfo info in storedData.WarpInfo)
                        {
                            if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString())
                            {
                                var management = RustServerManagement.Get();
                                management.TeleportPlayerToWorld(current.netPlayer, new Vector3(info.WarpX, info.WarpY, info.WarpZ));
                                PrintToChat("Everyone got teleported to [color cyan]" + info.WarpName + "[color white] by [color orange]" + player.displayName + "[color white]");
                            }
                        }
                    }
                }
                else
                {
                    SendReply(player, "[color cyan]Teleport all online players[color white]: \n /warp all <WarpName, WarpId>");
                    return;
                }
                break;

            case "wipe":
                if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin"))
                {
                    SendReply(player, "You do not have permission to use this command!");
                    return;
                }
                storedData.WarpInfo.Clear();
                storedData.cantele.Clear();
                Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                SendReply(player, "You have wiped all the teleports!");
                break;

            case "list":
                SendReply(player, "[color cyan]Current Warps[color white]");
                string maxusesrem;
                foreach (WarpInfo info in storedData.WarpInfo)
                {
                    if (permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup) || info.WarpPermissionGroup == "all")
                    {
                        if (info.WarpMaxUses == 0)
                        {
                            maxusesrem = "[color red]UNLIMITED[color white]";
                        }
                        else if (!storedData.maxuses.ContainsKey(steamId))
                        {
                            maxusesrem = info.WarpMaxUses.ToString();
                        }
                        else
                        {
                            maxusesrem = storedData.maxuses[steamId][info.WarpName].ToString();
                        }

                        SendReply(player, warplist.ToString(), info.WarpName, info.WarpPermissionGroup, info.WarpId, maxusesrem.ToString());
                        SendReply(player, "[color cyan]*************[color white]");
                    }
                }
                SendReply(player, "[color cyan]*************[color white]");
                break;

            case "add":

                if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin"))
                {
                    SendReply(player, "You do not have permission to use this command!");
                    return;
                }
                if (args.Length != 6)
                {
                    SendReply(player, "/warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>");
                    return;
                }
                foreach (WarpInfo info in storedData.WarpInfo)
                {
                    if (args[1].ToString().ToLower() == info.WarpName.ToString().ToLower())
                    {
                        SendReply(player, therealreadyis.ToString());
                        return;
                    }
                }
                string permissionp = args[5];
                string name        = args[1];
                int    warpnum;
                int    timerp   = Convert.ToInt32(args[2]);
                int    randomr  = Convert.ToInt32(args[3]);
                int    maxusess = Convert.ToInt32(args[4]);
                if (storedData.WarpInfo == null)
                {
                    warpnum = 1;
                }
                else
                {
                    warpnum = GetNewId();
                }
                var data = new WarpInfo(name, player, timerp, permissionp, warpnum, randomr, maxusess);
                storedData.WarpInfo.Add(data);
                SendReply(player, warpadded, name.ToString());
                Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                if (!permission.GroupExists(args[5]))
                {
                    permission.CreateGroup(args[5], "", 0);
                }
                cmd.AddChatCommand(name.ToString(), this, "");
                cmd.AddChatCommand(warpnum.ToString(), this, "");
                break;

            case "to":
                if (args.Length != 2)
                {
                    SendReply(player, "/warp to <WarpName> || /warplist");
                    return;
                }
                foreach (WarpInfo info in storedData.WarpInfo)
                {
                    if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString())
                    {
                        if (info.WarpPermissionGroup == "all" || permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup))
                        {
                            if (info.WarpMaxUses > 0)
                            {
                                if (!storedData.maxuses.ContainsKey(steamId))
                                {
                                    storedData.maxuses.Add(
                                        steamId,
                                        new Dictionary <string, int> {
                                        { info.WarpName, 1 }
                                    }
                                        );
                                }
                                if (storedData.maxuses[steamId][info.WarpName] == 5)
                                {
                                    SendReply(player, "You have reached the max uses for this Warp!");
                                    return;
                                }
                                if (storedData.maxuses.ContainsKey(steamId))
                                {
                                    storedData.maxuses[steamId][info.WarpName] = storedData.maxuses[steamId][info.WarpName] + 1;
                                }
                            }

                            if (enablecooldown == true)
                            {
                                if (storedData.cantele.TryGetValue(steamId, out nextteletime))
                                {
                                    if (Time.realtimeSinceStartup >= nextteletime)
                                    {
                                        storedData.cantele[steamId] = Time.realtimeSinceStartup + cooldown;
                                        Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                                        goto Finish;
                                    }
                                    else
                                    {
                                        int nexttele = Convert.ToInt32(nextteletime - Time.realtimeSinceStartup);
                                        SendReply(player, youhavetowait, nexttele.ToString());
                                        return;
                                    }
                                }
                                else
                                {
                                    storedData.cantele.Add(steamId, Time.realtimeSinceStartup + cooldown);
                                    Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                                    goto Finish;
                                }
                            }
Finish:
                            if (storedData.lastposition.ContainsKey(steamId) | !storedData.lastposition.ContainsKey(steamId))
                            {
                                storedData.lastposition.Remove(steamId);
                                Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                                var   cachedVector3 = player.playerClient.lastKnownPosition;
                                float x             = cachedVector3.x;
                                float y             = cachedVector3.y;
                                float z             = cachedVector3.z;
                                var   oldinfo       = new OldPosInfo(x, y, z);
                                storedData.lastposition.Add(steamId, oldinfo);
                                Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                            }

                            SendReply(player, teleportingto, info.WarpTimer, info.WarpName);
                            timer.Once(info.WarpTimer, () => {
                                int posx = UnityEngine.Random.Range(Convert.ToInt32(info.WarpX), info.RandomRange);
                                int posz = UnityEngine.Random.Range(Convert.ToInt32(info.WarpZ), info.RandomRange);
                                if (info.RandomRange == 0)
                                {
                                    ForcePlayerPos(player, new Vector3(info.WarpX, info.WarpY, info.WarpZ));
                                }
                                else
                                {
                                    ForcePlayerPos(player, new Vector3(posx, info.WarpY, posz));
                                }
                                SendReply(player, youhaveteleportedto, info.WarpName);
                            });
                        }
                        else
                        {
                            SendReply(player, "You are not allowed to use this warp!");
                            return;
                        }
                    }
                }
                break;

            case "help":
                if (permission.UserHasPermission(player.userID.ToString(), "warp.admin"))
                {
                    SendReply(player, "[color cyan]Available Commands[color white]");
                    SendReply(player, "[color cyan]-[color white] /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>");
                    SendReply(player, "[color cyan]-[color white] /warp limit");
                    SendReply(player, "[color cyan]-[color white] /warp remove <WarpName>");
                    SendReply(player, "[color cyan]-[color white] /warp wipe");
                    SendReply(player, "[color cyan]-[color white] /warp list");
                    SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list");
                    SendReply(player, "[color cyan]Teleport all online players[color white]: \n[color cyan]-[color white] /warp all <WarpName>");
                }
                else
                {
                    SendReply(player, "[color cyan]Available Commands[color white]");
                    SendReply(player, "[color cyan]-[color white] /warp list");
                    SendReply(player, "[color cyan]-[color white] /warp limit");
                    SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list");
                }
                break;

            case "remove":
                if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin"))
                {
                    SendReply(player, "You do not have permission to use this command!");
                    return;
                }
                if (args.Length != 2)
                {
                    SendReply(player, "/warp remove <WarpName>");
                    return;
                }
                foreach (WarpInfo info in storedData.WarpInfo)
                {
                    if (info.WarpName.ToString() == args[1].ToString())
                    {
                        storedData.WarpInfo.Remove(info);
                        SendReply(player, youhaveremoved, info.WarpName);
                        Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData);
                        break;
                    }
                }
                break;
            }
        }
Example #26
0
 public static PlayerInventory GetInventory(NetUser netUser) => playerData[netUser].inventory;
 internal void NotifyPlayerDisconnect(NetUser netUser) => livePlayers.Remove(netUser.userID.ToString());
Example #28
0
        bool OnPlayerChat(NetUser netuser, string message)
        {
            object obj   = Interface.CallHook("ChatAPIPlayerChat", netuser, message);
            bool   strip = true;

            if (obj is bool)
            {
                if ((bool)obj == false)
                {
                    return(false);
                }
            }
            if (obj is string)
            {
                message = (string)obj;
                strip   = false;
            }
            else
            {
                message = StripBBCode(message);
            }
            object cl = getCP(netuser);

            if (cl is bool)
            {
                return(false);
            }

            ChatPerson cp = (ChatPerson)cl;

            if (cp == null)
            {
                return(false);
            }

            string msg  = string.Format(FormatMessage, cp.chatcolor, message).Trim();
            string ctag = cp.tag;

            if (ctag == null)
            {
                cp.UpdateTag();
                ctag = cp.tag;
            }

            if (cp.listenersplugin != null && cp.listoflisteners.Any())
            {
                foreach (NetUser listener in cp.listoflisteners.ToList())
                {
                    if (listener == null)
                    {
                        continue;
                    }

                    rust.SendChatMessage(listener, ctag, msg);
                }
            }
            else
            {
                rust.BroadcastChat(ctag, msg);
            }

            Puts(ctag + " " + StripBBCode(message));

            return(true);
        }
Example #29
0
 void cmdResetKits(NetUser netuser, string[] args)
 {
     KitsData.Clear();
     SendReply(netuser, "All kits data from players were deleted");
     SaveKitsData();
 }
Example #30
0
 /// <summary>
 /// Constructor parametrizado
 /// </summary>
 /// <param name="targetNetUser">El receptor de este mensaje</param>
 /// <param name="fileId">El id del archivo</param>
 /// <param name="fileHandlerId">El identificador de la transferencia</param>
 public FileRequestMessage(NetUser targetNetUser, Guid fileId, Guid fileHandlerId) : this()
 {
     this.TargetNetUser = targetNetUser;
     this.FileId        = fileId;
     this.FileHandlerId = fileHandlerId;
 }
Example #31
0
        object GiveKit(NetUser netuser, string kitname)
        {
            if (KitsConfig[kitname] == null)
            {
                SendReply(netuser, unknownKit);
                return false;
            }

            if (netuser.playerClient == null || netuser.playerClient.rootControllable == null) return false;

            var inv = netuser.playerClient.rootControllable.idMain.GetComponent<Inventory>();
            var kitdata = (KitsConfig[kitname]) as Dictionary<string, object>;
            var kitsitems = kitdata["items"] as Dictionary<string, object>;
            List<object> wearList = kitsitems["wear"] as List<object>;
            List<object> mainList = kitsitems["main"] as List<object>;
            List<object> beltList = kitsitems["belt"] as List<object>;
            Inventory.Slot.Preference pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Armor,false,Inventory.Slot.KindFlags.Belt);

            if (wearList.Count > 0)
            {
                pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Armor, false, Inventory.Slot.KindFlags.Belt);
                foreach (object items in wearList)
                {
                    foreach (KeyValuePair<string, object> pair in items as Dictionary<string, object>)
                    {
                        GiveItem(inv, (string)pair.Key, (int)pair.Value, pref);
                    }
                }
            }

            if (mainList.Count > 0)
            {
                pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Default, false, Inventory.Slot.KindFlags.Belt);
                foreach (object items in mainList)
                {
                    foreach (KeyValuePair<string, object> pair in items as Dictionary<string, object>)
                    {
                        GiveItem(inv, (string)pair.Key, (int)pair.Value, pref);
                    }
                }
            }
            if (beltList.Count > 0)
            {
                pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Belt, false, Inventory.Slot.KindFlags.Belt);
                foreach (object items in beltList)
                {
                    foreach (KeyValuePair<string, object> pair in items as Dictionary<string, object>)
                    {
                        GiveItem(inv, (string)pair.Key, (int)pair.Value, pref);
                    }
                }
            }
            SendReply(netuser, kitredeemed);
            return true;
        }
Example #32
0
        void cmdEventsConfigurations(NetUser netuser, string command, string[] args)
        {
            var id = netuser.userID.ToString();

            if (!Access(netuser))
            {
                rust.SendChatMessage(netuser, tagChat, GetMessage("NoHaveAcess", id)); return;
            }
            if (args.Length == 0)
            {
                HelpAdmins(netuser); return;
            }
            switch (args[0])
            {
            case "tagchat":
                if (args.Length < 2)
                {
                    rust.SendChatMessage(netuser, tagChat, GetMessage("EventsConfig", id)); return;
                }
                tagChat = args[1].ToString();
                Config["Settings: Tag Chat"] = tagChat;
                rust.Notice(netuser, string.Format(GetMessage("EventsConfig1"), tagChat));
                break;

            case "minimumplayers":
                if (args.Length < 2)
                {
                    rust.SendChatMessage(netuser, tagChat, GetMessage("EventsConfig2", id)); return;
                }
                minimumPlayersEvent = Convert.ToInt32(args[1]);
                Config["Settings: Minimum Players Event"] = minimumPlayersEvent;
                rust.Notice(netuser, string.Format(GetMessage("EventsConfig3"), minimumPlayersEvent));
                break;

            case "timeautoevents":
                if (args.Length < 2)
                {
                    rust.SendChatMessage(netuser, tagChat, GetMessage("EventsConfig4", id)); return;
                }
                timeAutoEvents = Convert.ToSingle(args[1]);
                Config["Settings: Time Auto Events"] = timeAutoEvents;
                rust.Notice(netuser, string.Format(GetMessage("EventsConfig5"), timeAutoEvents));
                break;

            case "timeenterlottery":
                if (args.Length < 2)
                {
                    rust.SendChatMessage(netuser, tagChat, GetMessage("EventsConfig6", id)); return;
                }
                timeToEnterLottery = Convert.ToSingle(args[1]);
                Config["Settings: Time To Enter Lottery"] = timeToEnterLottery;
                rust.Notice(netuser, string.Format(GetMessage("EventsConfig7"), timeToEnterLottery));
                break;

            case "timecloseanswersmath":
                if (args.Length < 2)
                {
                    rust.SendChatMessage(netuser, tagChat, GetMessage("EventsConfig8", id)); return;
                }
                timeCloseAnswersMath = Convert.ToSingle(args[1]);
                Config["Settings: Time Close Answers Math"] = timeCloseAnswersMath;
                rust.Notice(netuser, string.Format(GetMessage("EventsConfig9"), timeCloseAnswersMath));
                break;

            case "maxnumberlottery":
                if (args.Length < 2)
                {
                    rust.SendChatMessage(netuser, tagChat, GetMessage("EventsConfig10", id)); return;
                }
                maximumNumberLottery = Convert.ToInt32(args[1]);
                Config["Settings: Maximum Number Lottery"] = maximumNumberLottery;
                rust.Notice(netuser, string.Format(GetMessage("EventsConfig11"), maximumNumberLottery));
                break;

            default: {
                HelpAdmins(netuser);
                break;
            }
            }
            SaveConfig();
        }
Example #33
0
        void SendList(NetUser netuser)
        {
            var kitEnum = KitsConfig.GetEnumerator();
            bool isadmin = hasAccess(netuser);
            bool isvip = hasVip(netuser,"vip");
            bool isvipp = hasVip(netuser,"vip+");
            bool isvippp = hasVip(netuser, "vip++");

            while (kitEnum.MoveNext())
            {
                string kitdescription = string.Empty;
                string options = string.Empty;
                string kitname = string.Empty;
                options = string.Empty;
                kitname = kitEnum.Current.Key.ToString();
                var kitdata = kitEnum.Current.Value as Dictionary<string, object>;
                if (kitdata.ContainsKey("description"))
                    kitdescription = kitdata["description"].ToString();
                if (kitdata.ContainsKey("max"))
                {
                    options = string.Format("{0} - {1} max", options, kitdata["max"].ToString());
                }
                if (kitdata.ContainsKey("cooldown"))
                {
                    options = string.Format("{0} - {1}s cooldown", options, kitdata["cooldown"].ToString());
                }
                if (kitdata.ContainsKey("admin"))
                {
                    options = string.Format("{0} - {1}", options, "admin");
                    if (!isadmin) continue;
                }
                if (kitdata.ContainsKey("vip"))
                {
                    options = string.Format("{0} - {1}", options, "vip");
                    if (!isvip) continue;
                }
                if (kitdata.ContainsKey("vip+"))
                {
                    options = string.Format("{0} - {1}", options, "vip+");
                    if (!isvipp) continue;
                }
                if (kitdata.ContainsKey("vip++"))
                {
                    options = string.Format("{0} - {1}", options, "vip++");
                    if (!isvippp) continue;
                }
                SendReply(netuser, string.Format("{0} - {1} {2}", kitname, kitdescription, options));
            }
        }
Example #34
0
        void cmdEventsSystems(NetUser netuser, string command, string[] args)
        {
            var id = netuser.userID.ToString();

            if (!Access(netuser))
            {
                rust.SendChatMessage(netuser, tagChat, GetMessage("NoHaveAcess", id)); return;
            }
            if (args.Length == 0)
            {
                HelpAdmins(netuser); return;
            }
            switch (args[0].ToLower())
            {
            case "autoevents":
                if (autoEvents)
                {
                    autoEvents = false;
                    timerAutoEvents.Destroy();
                    rust.BroadcastChat(tagChat, string.Format(GetMessage("EventsSystems"), netuser.displayName));
                }
                else
                {
                    autoEvents = true;
                    AutoStartEvents();
                    rust.BroadcastChat(tagChat, string.Format(GetMessage("EventsSystems1"), netuser.displayName));
                }
                Config["Settings: Auto Events"] = autoEvents;
                break;

            case "eventnow":
                StartEvents();
                break;

            case "lottery":
                if (args.Length > 1)
                {
                    if (args[1].ToString() == "players")
                    {
                        if (lotteryOfPlayers)
                        {
                            lotteryOfPlayers = false;
                        }
                        else
                        {
                            lotteryOfPlayers = true;
                        }
                        rust.Notice(netuser, string.Format(GetMessage("EventsSystems2"), lotteryOfPlayers));
                        Config["Settings: Lottery Of Players"] = lotteryOfPlayers;
                        SaveConfig();
                        return;
                    }
                }
                if (autoLottery)
                {
                    autoLottery = false;
                    autoMath    = true;
                }

                else
                {
                    autoLottery = true;
                    autoMath    = false;
                }
                Config["Settings: Auto Math"]    = autoMath;
                Config["Settings: Auto Lottery"] = autoLottery;
                rust.Notice(netuser, string.Format(GetMessage("EventsSystems3"), autoLottery, autoMath));
                break;

            case "math":
                if (autoMath)
                {
                    autoMath    = false;
                    autoLottery = true;
                }
                else
                {
                    autoMath    = true;
                    autoLottery = false;
                }
                Config["Settings: Auto Math"]    = autoMath;
                Config["Settings: Auto Lottery"] = autoLottery;
                rust.Notice(netuser, string.Format(GetMessage("EventsSystems4"), autoMath, autoLottery));
                break;

            case "randomevents":
                if (randomEvents)
                {
                    randomEvents = false;
                }
                else
                {
                    randomEvents = true;
                }
                Config["Settings: Random Events"] = randomEvents;
                rust.Notice(netuser, string.Format(GetMessage("EventsSystems5"), randomEvents));
                break;

            default: {
                HelpAdmins(netuser);
                break;
            }
            }
            SaveConfig();
        }
 public static void DoProcessUsers()
 {
     if (!bool_1)
     {
         bool_1 = true;
         foreach (UserData data in Users.All)
         {
             Character character;
             NetUser   player = NetUser.FindByUserID(data.SteamID);
             if ((player != null) && !player.did_join)
             {
                 player = null;
             }
             System.Collections.Generic.List <Countdown> list = new System.Collections.Generic.List <Countdown>();
             foreach (Countdown countdown in Users.CountdownList(data.SteamID))
             {
                 if (countdown.Expires)
                 {
                     if (countdown.Expired)
                     {
                         list.Add(countdown);
                     }
                     else if ((countdown.Command.Equals("pvp", StringComparison.OrdinalIgnoreCase) && data.HasFlag(UserFlags.nopvp)) && (Convert.ToInt32(countdown.TimeLeft) < Core.CommandNoPVPCountdown))
                     {
                         data.SetFlag(UserFlags.nopvp, false);
                         if (player != null)
                         {
                             Broadcast.Notice(player, "☢", Config.GetMessage("Command.PvP.Enabled", player, null), 5f);
                         }
                         Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeEnabled", null, data.Username), player, 5f);
                     }
                 }
             }
             foreach (Countdown countdown2 in list)
             {
                 Users.CountdownRemove(data.SteamID, countdown2);
             }
             if ((data.PremiumDate.Millisecond != 0) && (data.PremiumDate < DateTime.Now))
             {
                 Users.SetFlags(data.SteamID, UserFlags.premium, false);
                 Users.SetRank(data.SteamID, Users.DefaultRank);
                 DateTime date = new DateTime();
                 Users.SetPremiumDate(data.SteamID, date);
                 Broadcast.Notice(player, "☢", Config.GetMessage("Player.Premium.Expired", null, null), 5f);
             }
             if (((Core.OwnershipDestroyAutoDisable > 0) && Core.DestoryOwnership.ContainsKey(data.SteamID)) && (Core.DestoryOwnership[data.SteamID] < DateTime.Now))
             {
                 Core.DestoryOwnership.Remove(data.SteamID);
                 if (player != null)
                 {
                     Broadcast.Notice(player, "☢", Config.GetMessage("Command.Destroy.Disabled", null, null), 5f);
                 }
             }
             if (((player != null) && player.did_join) && (player.admin && Character.FindByUser(player.userID, out character)))
             {
                 Metabolism component = character.GetComponent <Metabolism>();
                 if (component.GetCalorieLevel() < 3000f)
                 {
                     component.AddCalories(3000f - component.GetCalorieLevel());
                 }
                 if (component.GetRadLevel() > 0f)
                 {
                     component.AddAntiRad(component.GetRadLevel());
                 }
             }
         }
         bool_1 = false;
         if ((Core.DatabaseType.Equals("MYSQL") && !bool_3) && (DateTime.Now.Subtract(dateTime_0).TotalMilliseconds > Core.MySQL_SyncInterval))
         {
             if (Core.MySQL_LogLevel > 2)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronizing server data from MySQL database", false);
             }
             SystemTimestamp restart = SystemTimestamp.Restart;
             bool_3 = true;
             Core.SQL_UpdateServer();
             if (Core.MySQL_Synchronize)
             {
                 Users.SQL_SynchronizeUsers();
             }
             if (Core.MySQL_Synchronize)
             {
                 Clans.SQL_SynchronizeClans();
             }
             dateTime_0 = DateTime.Now;
             bool_3     = false;
             restart.Stop();
             if (Core.MySQL_LogLevel > 2)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronized, is took " + restart.ElapsedSeconds.ToString("0.0000") + " second(s).", false);
             }
         }
     }
 }
Example #36
0
        void TryGiveKit(NetUser netuser, string kitname)
        {
            if (KitsConfig[kitname] == null)
            {
                SendReply(netuser, unknownKit);
                return;
            }
            object thereturn = Interface.GetMod().CallHook("canRedeemKit", netuser);

            if (thereturn != null)
            {
                if (thereturn is string)
                {
                    SendReply(netuser, (string)thereturn);
                }
                return;
            }

            Dictionary <string, object> kitdata = (KitsConfig[kitname]) as Dictionary <string, object>;
            double cooldown = 0.0;
            int    kitleft  = 1;

            if (kitdata.ContainsKey("max"))
            {
                kitleft = GetKitLeft(netuser, kitname, (int)(kitdata["max"]));
            }
            if (kitdata.ContainsKey("admin"))
            {
                if (!hasAccess(netuser))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            }
            if (kitdata.ContainsKey("vip"))
            {
                if (!hasVip(netuser, "vip"))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            }
            if (kitdata.ContainsKey("vip+"))
            {
                if (!hasVip(netuser, "vip+"))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            }
            if (kitdata.ContainsKey("vip++"))
            {
                if (!hasVip(netuser, "vip++"))
                {
                    SendReply(netuser, cantUseKit);
                    return;
                }
            }
            if (kitleft <= 0)
            {
                SendReply(netuser, maxKitReached);
                return;
            }
            if (kitdata.ContainsKey("cooldown"))
            {
                cooldown = GetKitTimeleft(netuser, kitname, (double)(kitdata["cooldown"]));
            }
            if (cooldown > 0.0)
            {
                SendReply(netuser, string.Format("You must wait {0}s before using this kit again", cooldown.ToString()));
                return;
            }
            object wasGiven = GiveKit(netuser, kitname);

            if ((wasGiven is bool) && !((bool)wasGiven))
            {
                Puts(string.Format("An error occurred while giving the kit {0} to {1}", kitname, netuser.playerClient.userName.ToString()));
                return;
            }
            proccessKitGiven(netuser, kitname, kitdata, kitleft);
        }
Example #37
0
 /// <summary>
 /// Send a reply message in response to a chat command
 /// </summary>
 /// <param name="netUser"></param>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void SendReply(NetUser netUser, string format, params object[] args) => PrintToChat(netUser, format, args);
Example #38
0
        void OnPlayerDisconnect(uLink.NetworkPlayer netplayer)
        {
            NetUser netuser = (NetUser)netplayer.GetLocalData();

            ResetRequest(netuser);
        }
Example #39
0
 /// <summary>
 /// Print a message to a players console log
 /// </summary>
 /// <param name="netUser"></param>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToConsole(NetUser netUser, string format, params object[] args)
 {
     ConsoleNetworker.SendClientCommand(netUser.networkPlayer, "echo " + string.Format(format, args));
 }
Example #40
0
        void cmdChatSetHome(NetUser netuser, string command, string[] args)
        {
            cachedUserid = netuser.playerClient.userID.ToString();
            if (args.Length == 0)
            {
                SendReply(netuser, sethomeHelp1);
                SendReply(netuser, sethomeHelp2);
                return;
            }

            SetHomeData newdata = sethomedatas[cachedUserid];

            if (newdata == null)
            {
                newdata = new SetHomeData(netuser.playerClient);
            }


            if (args.Length == 2 && args[0] == "remove")
            {
                var findhome = newdata.FindHome(args[1].ToString().ToLower());
                if (findhome == null)
                {
                    SendReply(netuser, homeDoesntExist);
                    return;
                }
                newdata.RemoveHome(args[1].ToString().ToLower());
                SendReply(netuser, string.Format(homeErased, args[1]));
            }
            else
            {
                var thereturn = Interface.GetMod().CallHook("canTeleport", new object[] { netuser });
                if (thereturn != null)
                {
                    SendReply(netuser, notAllowedHere);
                    return;
                }
                if (!AllowedSetHome(netuser))
                {
                    return;
                }

                var oldhome = newdata.FindHome(args[0].ToString().ToLower());
                if (oldhome is Vector3)
                {
                    newdata.RemoveHome(args[0].ToString().ToLower());
                    SendReply(netuser, string.Format(homeErased, args[0]));
                }
                if (newdata.savedhomes.Count >= maxAllowed)
                {
                    SendReply(netuser, maxhome);
                    return;
                }
                newdata.AddHome(args[0], netuser.playerClient.lastKnownPosition);
                SendReply(netuser, string.Format(newhome, args[0], netuser.playerClient.lastKnownPosition.ToString()));
            }
            if (sethomedatas[cachedUserid] != null)
            {
                storedData.SetHomeDatas.Remove(sethomedatas[cachedUserid]);
            }
            sethomedatas[cachedUserid] = newdata;
            storedData.SetHomeDatas.Add(sethomedatas[cachedUserid]);
        }
Example #41
0
 public static Character GetCharacter(NetUser netUser) => playerData[netUser].character;
Example #42
0
        object GiveKit(NetUser netuser, string args)
        {
            var kitConfig = GetKit(netuser, args);

            if (kitConfig.Count == 0)
            {
                return(false);
            }
            var kitsitems = kitConfig["items"] as Dictionary <string, object>;

            if (kitsitems == null)
            {
                return(false);
            }
            var inv      = netuser.playerClient.rootControllable.idMain.GetComponent <Inventory>();
            var wearList = kitsitems["wear"] as List <object>;
            var mainList = kitsitems["main"] as List <object>;
            var beltList = kitsitems["belt"] as List <object>;

            Inventory.Slot.Preference pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Armor, false, Inventory.Slot.KindFlags.Belt);
            if (wearList.Count > 0)
            {
                pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Armor, false, Inventory.Slot.KindFlags.Belt);
                foreach (object items in wearList)
                {
                    foreach (KeyValuePair <string, object> pair in items as Dictionary <string, object> )
                    {
                        GiveItem(inv, (string)pair.Key, (int)pair.Value, pref);
                    }
                }
            }
            if (mainList.Count > 0)
            {
                pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Default, false, Inventory.Slot.KindFlags.Belt);
                foreach (object items in mainList)
                {
                    foreach (KeyValuePair <string, object> pair in items as Dictionary <string, object> )
                    {
                        GiveItem(inv, (string)pair.Key, (int)pair.Value, pref);
                    }
                }
            }
            if (beltList.Count > 0)
            {
                pref = Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Belt, false, Inventory.Slot.KindFlags.Belt);
                foreach (object items in beltList)
                {
                    foreach (KeyValuePair <string, object> pair in items as Dictionary <string, object> )
                    {
                        if (listWeaponsMods.Contains((string)pair.Key) && args != nameInventory)
                        {
                            GiveWeaponMods(netuser, (string)pair.Key, (int)pair.Value, new[] { modeWeapon, modeWeapon1 });
                        }
                        else
                        {
                            GiveItem(inv, (string)pair.Key, (int)pair.Value, pref);
                        }
                    }
                }
            }
            return(true);
        }
 internal void NotifyPlayerConnect(NetUser netUser)
 {
     NotifyPlayerJoin(netUser.userID, netUser.displayName);
     livePlayers[netUser.userID.ToString()] = new RustLegacyLivePlayer(netUser);
 }
Example #44
0
        void TeleportPlayer(NetUser netuser, Vector3 location)
        {
            var management = RustServerManagement.Get();

            management.TeleportPlayerToWorld(netuser.playerClient.netPlayer, location);
        }
 /// <summary>
 /// Convierte una estructura de bytes en la meta data de este mensaje
 /// </summary>
 /// <param name="messageMetaPack">un array de bytes con la meta data</param>
 private void metaUnPack(byte[] messageMetaPack)
 {
     MetaType = BitConverter.ToInt32(messageMetaPack, 0);
     Type = BitConverter.ToInt32(messageMetaPack, 4);
     ProtocolType = BitConverter.ToInt32(messageMetaPack, 8);
     SenderNetUser = new NetUser();
     byte[] userId = new byte[16];
     Array.Copy(messageMetaPack, 12, userId, 0, 16);
     SenderNetUser.Id = new Guid(userId);
     byte[] userIP = new byte[4];
     Array.Copy(messageMetaPack, 28, userIP, 0, 4);
     SenderNetUser.Ip = new IPAddress(userIP);
     byte[] messageId = new byte[16];
     Array.Copy(messageMetaPack, 32, messageId, 0, 16);
     Id = new Guid(messageId);
     Jumps = BitConverter.ToInt32(messageMetaPack, 48);
     TargetNetUser = new NetUser();
     byte[] targetId = new byte[16];
     Array.Copy(messageMetaPack, 52, targetId, 0, 16);
     TargetNetUser.Id = new Guid(targetId);
     byte[] targetIP = new byte[4];
     Array.Copy(messageMetaPack, 68, targetIP, 0, 4);
     TargetNetUser.Ip = new IPAddress(targetIP);
 }
Example #46
0
        void cmdTeleport(NetUser netuser, string command, string[] args)
        {
            string ID = netuser.userID.ToString();

            if (!teleports && !AcessAdmin(netuser))
            {
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("Teleport", ID)); return;
            }
            if (args.Length == 0)
            {
                HelpLocationsNames(netuser); return;
            }
            string nameLocation = args[0].ToString().ToLower();

            if (NamesLocations.ContainsKey(nameLocation))
            {
                object[] objectLocation = NamesLocations[nameLocation];
                if (objectLocation.Length < 2)
                {
                    return;
                }
                Vector3 location = new Vector3((float)objectLocation[0], (float)objectLocation[1], (float)objectLocation[2]);
                // TEMPO PARA USAR O COMANDO NOVAMENTE!
                if (OnTeleportPlayers.Contains(ID))
                {
                    rust.SendChatMessage(netuser, chatPrefix, string.Format(GetMessage("TeleportDellay"), TimeTeleportPlayers)); return;
                }
                OnTeleportPlayers.Add(ID);
                timer.Once(TimeTeleportPlayers * 60, () => { OnTeleportPlayers.Remove(ID); });
                // SALVAR O INVENTARIO DO JOGADOR
                var items           = GetInventory(netuser);
                var inventoryPlayer = new Dictionary <string, object>();
                inventoryPlayer.Add("items", items);
                SaveInventory.Add(netuser.userID.ToString(), inventoryPlayer);
                //
                if (!AcessDellay(netuser))
                {
                    rust.Notice(netuser, string.Format(GetMessage("Teleport2", ID), nameLocation));
                    if (netuser.playerClient == null)
                    {
                        return;
                    }
                    if (CostTeleportViP)
                    {
                        object thereturn = (object)MoneySystem?.Call("canMoney", new object[] { netuser });
                        if (thereturn != null)
                        {
                            return;             //
                        }
                        if (MoneySystem == null)
                        {
                            rust.Notice(netuser, GetMessage("MoneySystemNull", ID)); return;
                        }
                        int totalMoney = (int)MoneySystem?.Call("GetTotalMoney", ID);
                        if (totalMoney < CostTeleportPlayerVIP)
                        {
                            rust.Notice(netuser, string.Format(GetMessage("MoneyInvalid", ID), CostTeleportPlayerVIP)); return;
                        }
                        MoneySystem?.Call("TakeMoney", netuser, CostTeleportPlayerVIP);
                    }
                    TeleportPlayer(netuser, location);
                    GodMode(netuser, true);
                    timer.Once(TimeAntiSpawnKill, () => {
                        if (netuser.playerClient == null)
                        {
                            return;
                        }
                        GodMode(netuser, false);
                        timer.Once(1f, () => {
                            GiveKit(netuser, nameInventory);
                            SaveInventory.Remove(netuser.userID.ToString());
                        });
                    });
                }
                else
                {
                    rust.Notice(netuser, string.Format(GetMessage("Teleport1", ID), nameLocation, TimeTeleport));
                    if (CostTeleport)
                    {
                        object thereturn = (object)MoneySystem?.Call("canMoney", new object[] { netuser });
                        if (thereturn != null)
                        {
                            return;             //
                        }
                        if (MoneySystem == null)
                        {
                            rust.Notice(netuser, GetMessage("MoneySystemNull", ID)); return;
                        }
                        int totalMoney = (int)MoneySystem?.Call("GetTotalMoney", ID);
                        if (totalMoney < CostTeleportPlayer)
                        {
                            rust.Notice(netuser, string.Format(GetMessage("MoneyInvalid", ID), CostTeleportPlayer)); return;
                        }
                        MoneySystem?.Call("TakeMoney", netuser, CostTeleportPlayer);
                    }
                    timer.Once(TimeTeleport, () => {
                        if (netuser.playerClient == null)
                        {
                            return;
                        }
                        TeleportPlayer(netuser, location);
                        GodMode(netuser, true);
                    });
                    timer.Once(TimeAntiSpawnKill, () => {
                        if (netuser.playerClient == null)
                        {
                            return;
                        }
                        GodMode(netuser, false);
                        timer.Once(1f, () => {
                            GiveKit(netuser, nameInventory);
                            SaveInventory.Remove(netuser.userID.ToString());
                        });
                    });
                }
            }
            else
            {
                HelpLocationsNames(netuser);
            }
        }
Example #47
0
 void cmdRemoveKit(NetUser netuser, string[] args)
 {
     if (args.Length < 2)
     {
         SendReply(netuser, "Kit must specify the name of the kit that you want to remove");
         return;
     }
     int kitlvl = 0;
     string kitname = args[1].ToString();
     if (KitsConfig[kitname] == null)
     {
         SendReply(netuser, string.Format("The kit {0} doesn't exist", kitname));
         return;
     }
     var kitdata = (KitsConfig[kitname]) as Dictionary<string, object>;
     var newKits = new Dictionary<string, object>();
     var enumkits = KitsConfig.GetEnumerator();
     while (enumkits.MoveNext())
     {
         if (enumkits.Current.Key.ToString() != kitname && enumkits.Current.Value != null)
         {
             newKits.Add(enumkits.Current.Key.ToString(), enumkits.Current.Value);
         }
     }
     KitsConfig.Clear();
     foreach (KeyValuePair<string, object> pair in newKits)
     {
         KitsConfig[pair.Key] = pair.Value;
     }
     SaveKits();
     SendReply(netuser, string.Format("The kit {0} was successfully removed", kitname));
 }
Example #48
0
        void cmdAdminTeleport(NetUser netuser, string command, string[] args)
        {
            string ID           = netuser.userID.ToString();
            string nameLocation = string.Empty;
            bool   IsAdmin      = (bool)AdminControl?.Call("IsAdmin", netuser);
            {
                if (!(netuser.CanAdmin() || IsAdmin || permission.UserHasPermission(ID, permiTeleportAdmin)))
                {
                    rust.SendChatMessage(netuser, chatPrefix, GetMessage("NoPermission", ID));
                    return;
                }
                if (args.Length == 0)
                {
                    HelpsAdmins(netuser); return;
                }
                switch (args[0].ToLower())
                {
                case "chatPrefix":
                    if (args.Length < 2)
                    {
                        rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins1", ID)); return;
                    }
                    chatPrefix = args[1].ToString();
                    Config["Settings: Chat Tag"] = chatPrefix;
                    rust.Notice(netuser, string.Format(GetMessage("AdminTeleport", ID), chatPrefix));
                    break;

                case "onof":
                    if (teleports)
                    {
                        teleports = false;
                        rust.BroadcastChat(chatPrefix, string.Format(GetMessage("AdminTeleport1", ID), netuser.displayName));
                    }
                    else
                    {
                        teleports = true;
                        rust.BroadcastChat(chatPrefix, string.Format(GetMessage("AdminTeleport2", ID), netuser.displayName));
                    }
                    Config["Settings: Teleports"] = teleports;
                    break;

                case "add":
                    if (args.Length < 2)
                    {
                        rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins3", ID)); return;
                    }
                    nameLocation = args[1].ToString().ToLower();
                    Vector3 location = netuser.playerClient.lastKnownPosition;
                    if (NamesLocations.ContainsKey(nameLocation))
                    {
                        NamesLocations.Remove(nameLocation);
                    }
                    NamesLocations.Add(nameLocation, new object[] { location.x, location.y, location.z });
                    rust.Notice(netuser, string.Format(GetMessage("AdminTeleport3", ID), nameLocation));
                    Config["Settings: Names Locations"] = NamesLocations;
                    break;

                case "remove":
                    if (args.Length < 2)
                    {
                        rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins4", ID)); return;
                    }
                    nameLocation = args[1].ToString().ToLower();
                    if (NamesLocations.ContainsKey(nameLocation))
                    {
                        NamesLocations.Remove(nameLocation);
                        rust.Notice(netuser, string.Format(GetMessage("AdminTeleport4", ID), nameLocation));
                        Config["Settings: Names Locations"] = NamesLocations;
                    }
                    else
                    {
                        rust.SendChatMessage(netuser, chatPrefix, string.Format(GetMessage("NoFoundTeleport", ID), nameLocation));
                    }
                    break;

                case "clear":
                    NamesLocations.Clear();
                    rust.Notice(netuser, GetMessage("AdminTeleport5", ID));
                    Config["Settings: Names Locations"] = NamesLocations;
                    break;

                default: {
                    HelpsAdmins(netuser);
                    break;
                }
                }
                SaveConfig();
            }
        }
Example #49
0
 int GetKitLeft(NetUser netuser, string kitname, int max)
 {
     if (KitsData[netuser.playerClient.userID.ToString()] == null) return max;
     var data = KitsData[netuser.playerClient.userID.ToString()] as Dictionary<string, object>;
     if (!(data.ContainsKey(kitname))) return max;
     var currentkit = data[kitname] as Dictionary<string, object>;
     if (!(currentkit.ContainsKey("used"))) return max;
     return (max - (int)currentkit["used"]);
 }
Example #50
0
        private void Hooks_OnCommand(Fougerite.Player player, string cmd, string[] args)
        {
            if (cmd == "who")
            {
                Who.opbjectWho(player);
            }
            else if (cmd == "cvip")
            {
                if (player.Admin)
                {
                    if (args.Length == 2)
                    {
                        Fougerite.Player player1 = Fougerite.Player.FindByName(args[0]);
                        if (player1 == null)
                        {
                            player.Message("查询无果,找不到此玩家");
                            return;
                        }
                        else
                        {
                            Vip.SetVip(args[1], player1.SteamID);
                            player.Message("充值成功");
                            player1.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player1.Name,
                                "成功充值VIP",
                                args[1],
                                "突破[",
                                Vip.GetCH(args[1]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                    }
                    else
                    {
                        player.Message("您输入有误[/cvip 玩家名 等级]");
                    }
                }
            }
            else if (cmd == "svip")
            {
                if (player.Admin)
                {
                    if (args.Length == 2)
                    {
                        Fougerite.Player player1 = Fougerite.Player.FindByName(args[0]);
                        if (player1 == null)
                        {
                            player.Message("查询无果,找不到此玩家");
                            return;
                        }
                        else
                        {
                            Vip.SetVip(args[1], player1.SteamID);
                            player.Message("设置成功");
                        }
                    }
                    else
                    {
                        player.Message("您输入有误[/cvip 玩家名 等级]");
                    }
                }
            }
            else if (cmd == "kit")
            {
                string kitlist = string.Concat(new string[] {
                    "starter[小礼包]❀",
                    "xklb[小康礼包]❀",
                    "vip[VIP大礼包]❀",
                    "vipyf[VIP隐身衣]"
                });
                if (args.Length == 0)
                {
                    player.Message(kitlist);
                }
                else if (args.Length == 1)
                {
                    if (args[0] == "starter")
                    {
                        Kit.starter(player);
                    }
                    else if (args[0] == "xklb")
                    {
                        Kit.xklb(player);
                    }
                    else if (args[0] == "vip")
                    {
                        Kit.vip(player);
                    }
                    else if (args[0] == "vipyf")
                    {
                        Kit.vipyf(player);
                    }
                }
            }
            else if (cmd == "vipsearch")
            {
                if (args.Length == 0)
                {
                    Vip.Vipsearch(player);
                }
                if (args.Length == 1)
                {
                    Vip.Vipsearch(Fougerite.Player.FindByName(args[0]));
                }
            }
            else if (cmd == "remove")
            {
                if (args.Length == 0)
                {
                    Kit.remove(player, player.Name);
                }
                if (args.Length == 1)
                {
                    Kit.remove(player, args[0]);
                }
            }
            else if (cmd == "fps")
            {
                NetUser Sender = NetUser.FindByUserID(player.UID);
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssaa false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssao false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.bloom false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.grain false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.shafts false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.tonemap false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.on false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.forceredraw false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.displacement false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowcast false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowreceive false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.level 0");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.vsync false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.level -1");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.reflection false");
                player.Notice("优化完毕");
            }
            else if (cmd == "quality")
            {
                NetUser Sender = NetUser.FindByUserID(player.UID);
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssaa true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssao true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.bloom true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.grain true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.shafts true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.tonemap true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.on true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.forceredraw true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.displacement true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowcast true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowreceive true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.level 1");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.vsync true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.level 1");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.reflection true");
                player.Notice("成功开启最高特效");
            }
            else if (cmd == "suicide")
            {
                NetUser Sender = NetUser.FindByUserID(player.UID);
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "suicide");
            }
            else if (cmd == "dvip")
            {
                if (args.Length == 1)
                {
                    if (args[0] == "1")
                    {
                        if (Money.HasMoney(player, 1000))
                        {
                            Money.RemoveMoney(player, 1000);
                            Vip.SetVip(args[0], player.SteamID);
                            player.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player.Name,
                                "成功充值VIP",
                                args[0],
                                "突破[",
                                Vip.GetCH(args[0]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                        else
                        {
                            player.Message("抱歉,您的斩仙币不足");
                        }
                    }
                    else if (args[0] == "2")
                    {
                        if (Money.HasMoney(player, 2000))
                        {
                            Money.RemoveMoney(player, 2000);
                            Vip.SetVip(args[0], player.SteamID);
                            player.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player.Name,
                                "成功充值VIP",
                                args[0],
                                "突破[",
                                Vip.GetCH(args[0]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                        else
                        {
                            player.Message("抱歉,您的斩仙币不足");
                        }
                    }
                    else if (args[0] == "3")
                    {
                        if (Money.HasMoney(player, 3000))
                        {
                            Money.RemoveMoney(player, 3000);
                            Vip.SetVip(args[0], player.SteamID);
                            player.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player.Name,
                                "成功充值VIP",
                                args[0],
                                "突破[",
                                Vip.GetCH(args[0]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                        else
                        {
                            player.Message("抱歉,您的斩仙币不足");
                        }
                    }
                }
                else
                {
                    player.Message("输入/dvip+空格+等级即可兑换(目前最高为3级)");
                    player.Message("VIP1-1000斩仙币");
                    player.Message("VIP2-2000斩仙币");
                    player.Message("VIP3-3000斩仙币");
                }
            }

            /*else if (cmd == "changeowner")
             * {
             *   if (player.Admin)
             *   {
             *       if (args.Length == 2)
             *       {
             *           Fougerite.Player player1 = Fougerite.Player.FindBySteamID(args[0]);
             *           if (player1 != null)
             *           {
             *               foreach (Fougerite.Entity ob in Fougerite.World.GetWorld().Entities)
             *               {
             *                   if (ob.OwnerID == args[1]) ob.ChangeOwner(player1);
             *               }
             *               player.Message("更改成功");
             *           }
             *           else player.Message("找不到玩家");
             *       }
             *       else player.Message("您输入有误");
             *   }
             * }  */
        }
Example #51
0
        Dictionary<string, object> GetNewKitFromPlayer(NetUser netuser)
        {
            Dictionary<string, object> kitsitems = new Dictionary<string, object>();
            List<object> wearList = new List<object>();
            List<object> mainList = new List<object>();
            List<object> beltList = new List<object>();

            IInventoryItem item;
            var inv = netuser.playerClient.rootControllable.idMain.GetComponent<Inventory>();
            for (int i = 0; i < 40; i++)
            {
                if(inv.GetItem(i, out item))
                {
                    Dictionary<string, object> newObject = new Dictionary<string, object>();
                    newObject.Add(item.datablock.name.ToString().ToLower(), item.datablock._splittable?(int)item.uses :1);
                    if (i>=0 && i<30)
                        mainList.Add(newObject);
                    else if(i>=30 && i < 36)
                        beltList.Add(newObject);
                    else
                        wearList.Add(newObject);
                }
            }
            inv.Clear();
            kitsitems.Add("wear", wearList);
            kitsitems.Add("main", mainList);
            kitsitems.Add("belt", beltList);
            return kitsitems;
        }
Example #52
0
 internal void NotifyPlayerConnect(NetUser netUser)
 {
     NotifyPlayerJoin(netUser.userID, netUser.displayName);
     livePlayers[netUser.userID.ToString()] = new RustLegacyLivePlayer(netUser);
 }
Example #53
0
 bool hasAccess(NetUser netuser)
 {
     if (netuser.CanAdmin())
         return true;
     return false;
 }
Example #54
0
 void cmdResetKits(NetUser netuser, string[] args)
 {
     KitsData.Clear();
     SendReply(netuser, "All kits data from players were deleted");
     SaveKitsData();
 }
Example #55
0
        void proccessKitGiven(NetUser netuser, string kitname, Dictionary<string, object> kitdata, int kitleft)
        {
            string userid = netuser.playerClient.userID.ToString();
            if (KitsData[userid] == null)
            {
                (KitsData[userid]) = new Dictionary<string, object>();
            }
            var playerData = (KitsData[userid]) as Dictionary<string, object>;
            var currentKitData = new Dictionary<string, object>();
            bool write = false;
            if (kitdata.ContainsKey("max"))
            {
                currentKitData.Add("used", (((int)kitdata["max"] - kitleft) + 1));
                write = true;
            }
            if (kitdata.ContainsKey("cooldown"))
            {
                currentKitData.Add("cooldown", ((double)kitdata["cooldown"] + CurrentTime()));
                write = true;
            }
            if (write)
            {
                if (playerData.ContainsKey(kitname))
                    playerData[kitname] = currentKitData;
                else
                    playerData.Add(kitname, currentKitData);
                KitsData[userid] = playerData;

            }
        }
Example #56
0
        void cmdAddKit(NetUser netuser, string[] args)
        {
            if (args.Length < 3)
            {
                SendReply(netuser, "/kit add \"KITNAME\" \"DESCRIPTION\" -option1 -option2 etc, Everything you have in your inventory will be used in the kit");
                SendReply(netuser, "Options avaible:");
                SendReply(netuser, "-maxXX => max times someone can use this kit. Default is infinite.");
                SendReply(netuser, "-cooldownXX => cooldown of the kit. Default is none.");
                SendReply(netuser, "-vip => Allow to give this kit only to vip & admins");
                SendReply(netuser, "-admin => Allow to give this kit only to admins (set this for the autokit!!!!)");
                return;
            }
            string kitname     = args[1].ToString();
            string description = args[2].ToString();
            bool   vip         = false;
            bool   vipp        = false;
            bool   vippp       = false;
            bool   admin       = false;
            int    max         = -1;
            double cooldown    = 0.0;

            if (KitsConfig[kitname] != null)
            {
                SendReply(netuser, string.Format("The kit {0} already exists. Delete it first or change the name.", kitname));
                return;
            }
            if (args.Length > 3)
            {
                object validoptions = VerifyOptions(args, out admin, out vip, out vipp, out vippp, out max, out cooldown);
                if (validoptions is string)
                {
                    SendReply(netuser, (string)validoptions);
                    return;
                }
            }
            Dictionary <string, object> kitsitems = GetNewKitFromPlayer(netuser);
            Dictionary <string, object> newkit    = new Dictionary <string, object>();

            newkit.Add("items", kitsitems);
            if (admin)
            {
                newkit.Add("admin", true);
            }
            if (vip)
            {
                newkit.Add("vip", true);
            }
            if (vipp)
            {
                newkit.Add("vip+", true);
            }
            if (vippp)
            {
                newkit.Add("vip++", true);
            }
            if (max >= 0)
            {
                newkit.Add("max", max);
            }
            if (cooldown > 0.0)
            {
                newkit.Add("cooldown", cooldown);
            }
            newkit.Add("description", description);
            KitsConfig[kitname] = newkit;
            SaveKits();
        }
Example #57
0
 void StripAndGiveKit(NetUser netuser, string kitname)
 {
     if(shouldstrip) netuser.playerClient.rootControllable.idMain.GetComponent<Inventory>().Clear();
     GiveKit(netuser, kitname);
 }
Example #58
0
        void SendList(NetUser netuser)
        {
            var  kitEnum = KitsConfig.GetEnumerator();
            bool isadmin = hasAccess(netuser);
            bool isvip   = hasVip(netuser, "vip");
            bool isvipp  = hasVip(netuser, "vip+");
            bool isvippp = hasVip(netuser, "vip++");

            while (kitEnum.MoveNext())
            {
                string kitdescription = string.Empty;
                string options        = string.Empty;
                string kitname        = string.Empty;
                options = string.Empty;
                kitname = kitEnum.Current.Key.ToString();
                var kitdata = kitEnum.Current.Value as Dictionary <string, object>;
                if (kitdata.ContainsKey("description"))
                {
                    kitdescription = kitdata["description"].ToString();
                }
                if (kitdata.ContainsKey("max"))
                {
                    options = string.Format("{0} - {1} max", options, kitdata["max"].ToString());
                }
                if (kitdata.ContainsKey("cooldown"))
                {
                    options = string.Format("{0} - {1}s cooldown", options, kitdata["cooldown"].ToString());
                }
                if (kitdata.ContainsKey("admin"))
                {
                    options = string.Format("{0} - {1}", options, "admin");
                    if (!isadmin)
                    {
                        continue;
                    }
                }
                if (kitdata.ContainsKey("vip"))
                {
                    options = string.Format("{0} - {1}", options, "vip");
                    if (!isvip)
                    {
                        continue;
                    }
                }
                if (kitdata.ContainsKey("vip+"))
                {
                    options = string.Format("{0} - {1}", options, "vip+");
                    if (!isvipp)
                    {
                        continue;
                    }
                }
                if (kitdata.ContainsKey("vip++"))
                {
                    options = string.Format("{0} - {1}", options, "vip++");
                    if (!isvippp)
                    {
                        continue;
                    }
                }
                SendReply(netuser, string.Format("{0} - {1} {2}", kitname, kitdescription, options));
            }
        }
Example #59
0
        void OnStructureBuilt(StructureComponent component, NetUser netuser)
        {
            var structurecheck = component.gameObject.AddComponent <StructureCheck>();

            structurecheck.owner  = netuser.playerClient.controllable.GetComponent <Character>();
            structurecheck.radius = 0f;
            if ((antiPillarStash || antiPillarBarricade) && component.IsPillar())
            {
                structurecheck.radius = 0.2f;
            }
            else if (antiFoundationGlitch && (component.type == StructureComponent.StructureComponentType.Foundation))
            {
                structurecheck.radius      = 3.0f;
                structurecheck.position.y += 2f;
            }
            else if (component.type == StructureComponent.StructureComponentType.Ramp)
            {
                if (antiRampStack)
                {
                    if (MeshBatchPhysics.Raycast(structurecheck.position + Vector3ABitUp, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
                    {
                        if (cachedhitInstance != null)
                        {
                            cachedComponent = cachedhitInstance.physicalColliderReferenceOnly.GetComponent <StructureComponent>();
                            if (cachedComponent.type == StructureComponent.StructureComponentType.Foundation || cachedComponent.type == StructureComponent.StructureComponentType.Ceiling)
                            {
                                var weight = getweight.GetValue(cachedComponent._master) as Dictionary <StructureComponent, HashSet <StructureComponent> >;
                                int ramps  = 0;
                                if (weight.ContainsKey(cachedComponent))
                                {
                                    foreach (StructureComponent structure in weight[cachedComponent])
                                    {
                                        if (structure.type == StructureComponent.StructureComponentType.Ramp)
                                        {
                                            ramps++;
                                        }
                                    }
                                }
                                if (ramps > rampstackMax)
                                {
                                    TakeDamage.KillSelf(component.GetComponent <IDMain>());
                                    if (structurecheck.owner != null && structurecheck.owner.playerClient != null)
                                    {
                                        ConsoleNetworker.SendClientCommand(structurecheck.owner.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("You are not allowed to stack more than {0} ramps", rampstackMax.ToString())));
                                    }
                                    timer.Once(0.01f, () => GameObject.Destroy(structurecheck));
                                    return;
                                }
                            }
                        }
                    }
                }
                if (antiRampGlitch)
                {
                    structurecheck.radius      = 3.0f;
                    structurecheck.position.y += 2f;
                }
            }
            timer.Once(0.05f, () => { if (structurecheck != null)
                                      {
                                          structurecheck.CheckCollision();
                                      }
                       });
        }
Example #60
0
 internal RustLegacyPlayer(NetUser netUser) : this(netUser.userID, netUser.displayName)
 {
     this.netUser = netUser;
 }