コード例 #1
0
        private void BuyItem(BasePlayer player, string key)
        {
            PlayerData.PData pdata = PlayerData.Get(player);

            if (player == null || pdata == null || !items.ContainsKey(key))
            {
                return;
            }

            ShopItem item = items[key];

            pdata.LoadRewardPoints(points =>
            {
                if (item.price > points)
                {
                    UpdateStatusUI(player, "<color=#B70E30>Not enough Reward Points</color> visit https://rust.gamelimits.com/ to buy Reward Points.");
                    return;
                }

                pdata.GiveRewardPoints(-item.price, $"Bought {item.name} from the shop", newPoints =>
                {
                    string[] commands = item.command.Split('|');
                    foreach (string command in commands)
                    {
                        Helper.ExecuteCommand(player, command);
                    }

                    UpdateStatusUI(player, $"<color=#0E84B7>Bought</color> {item.name}");
                });
            });
        }
コード例 #2
0
        private void Reward(BasePlayer player)
        {
            PlayerData.PData pdata = PlayerData.Get(player);

            if (player == null || pdata == null || !timeInfo.ContainsKey(player.userID))
            {
                return;
            }

            int rewardPoints = 2;

            if (Helper.HasMinimumVipRank(pdata, "vip"))
            {
                rewardPoints = 10;
            }

            pdata.GiveRewardPoints(rewardPoints, $"You have been rewarded {rewardPoints} RP for playing on this server.", points =>
            {
                player.ChatMessage($"You have been rewarded <color=#0E84B7>{rewardPoints} RP</color> for playing on this server.\n" +
                                   $"You have <color=#0E84B7>{points} Reward Points (RP)</color>. Type /s to spend them in the shop");

                Puts($"[{pdata.id}:{player.UserIDString}] has been rewarded {rewardPoints} RP for playing on this server (total: {points} RP)");
            });
        }