private void RewardPlayer(IPlayer player) { if (_config.UseServerRewards && ServerRewards) { ServerRewards?.Call("AddPoints", player.Id, _config.ServerRewardPoints); player.Message(Lang("EventAward", player.Id, Lang("EventPoints", player.Id, _config.ServerRewardPoints))); } if (_config.UseEconomics && Economics) { Economics?.Call("Deposit", player.Id, _config.EconomicsPoints); player.Message(Lang("EventAward", player.Id, Lang("EventPoints", player.Id, _config.EconomicsPoints))); } if (_config.UseAwardItems) { FindRewardData(player.Id).Rewards++; SaveData(); player.Message(Lang("EventClaim", player.Id)); } BroadcastAll("EventWinner", player.Name, _currentWord); ResetEvent(); }
void OnEntityDeath(BaseCombatEntity entity, HitInfo info) { if (!Economics) { return; } if (!entity.GetComponent("BaseNPC")) { return; } if (!info.Initiator?.ToPlayer()) { return; } var player = info.Initiator?.ToPlayer(); var animal = UppercaseFirst(entity.ShortPrefabName.Replace(".prefab", "")); int amount; if (!config.Settings.Rewards.TryGetValue(animal, out amount) || amount <= 0) { return; } Economics.CallHook("Deposit", player.userID, amount); if (config.Settings.ShowMessages) { PrintToChat(player, string.Format(config.Messages[PluginMessage.ReceivedForKill], amount, animal.ToLower())); } }
private Hash <string, object> GetPanel(BasePlayer player) { Panel panel = _pluginConfig.Panel; PanelText text = panel.Text; if (text != null) { text.Text = string.Format(_textFormat, Economics?.Call <double>("Balance", player.userID) ?? 0); } return(panel.ToHash()); }
void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item) { if (!Economics) { return; } var player = entity.ToPlayer(); if (player) { var shortName = item.info.shortname; string resource = null; var amount = 0; if (shortName.Contains(".ore")) { amount = config.Settings.Rewards[PluginRewards.Ore]; resource = "ore"; } if (shortName.Equals("stones")) { amount = config.Settings.Rewards[PluginRewards.Stones]; resource = "stones"; } if (dispenser.GetComponentInParent <TreeEntity>()) { amount = config.Settings.Rewards[PluginRewards.Wood]; resource = "wood"; } if (resource == null || amount <= 0) { return; } Economics.CallHook("Deposit", player.userID, amount); if (config.Settings.ShowMessages) { PrintToChat(player, string.Format(config.Messages[PluginMessage.ReceivedForGather], amount, resource)); } } }
public bool TakeMoney(BasePlayer player, double amount) { if (useEconomics) { if (Economics == null) { Send(player, GetMessage("NoEconomics")); return(false); } bool canBuy = (bool)Economics.CallHook("Withdraw", player.userID, amount); if (canBuy) { return(true); } else { Send(player, GetMessage("NoMoney")); return(false); } } else if (useServerRewards) { if (Economics == null) { Send(player, GetMessage("NoServerRewards")); return(false); } bool canBuy = (bool)ServerRewards?.Call("TakePoints", player.userID, Convert.ToInt32(amount)); if (canBuy) { return(true); } else { Send(player, GetMessage("NoMoney")); return(false); } } return(false); }
/* * ChargePlayer * * Charge RP from a player */ bool ChargePlayer(IPlayer player, bool called_by_player) { object result = null; if (called_by_player && player.HasPermission("respawnbradley.nocosts")) { return(true); } if (called_by_player && !this.config_data.Options.ChargeOnPlayerCommand) { return(true); } if (!called_by_player && !this.config_data.Options.ChargeOnServerCommand) { return(true); } if (this.config_data.Options.UseServerRewards && ServerRewards != null) { result = ServerRewards.Call("TakePoints", Convert.ToUInt64(player.Id), Convert.ToInt32(this.config_data.Options.RespawnCosts)); } else if (this.config_data.Options.UseEconomics && Economics != null) { result = Economics.Call("Withdraw", player.Id, Convert.ToDouble(this.config_data.Options.RespawnCosts)); } else { // No supported rewards plugin loaded or configured player.Reply(GetMSG("UnableToCharge", player.Id).Replace("{amount}", this.config_data.Options.RespawnCosts.ToString()).Replace("{currency}", this.config_data.Options.CurrencySymbol)); return(false); } if (result == null || (result is bool && (bool)result == false)) { player.Reply(GetMSG("UnableToCharge", player.Id).Replace("{amount}", this.config_data.Options.RespawnCosts.ToString()).Replace("{currency}", this.config_data.Options.CurrencySymbol)); return(false); } player.Reply(GetMSG("PlayerCharged", player.Id).Replace("{amount}", this.config_data.Options.RespawnCosts.ToString()).Replace("{currency}", this.config_data.Options.CurrencySymbol)); return(true); }
private void StealMoney(BasePlayer victim, BasePlayer attacker) { var chance = random.NextDouble() * (config.MaxChanceMoney / 100f); // Economics plugin support - http://oxidemod.org/plugins/economics.717/ if (Economics != null) { var balance = (double)Economics.Call("GetPlayerMoney", victim.userID); var money = Math.Floor(balance * chance); if (money > 0) { Economics.Call("Transfer", victim.userID, attacker.userID, money); Player.Reply(attacker, Lang("StoleMoney", attacker.UserIDString, money, victim.displayName)); } else { Player.Reply(attacker, Lang("StoleNothing", attacker.UserIDString, victim.displayName)); } } // UEconomics plugin support - http://oxidemod.org/plugins/ueconomics.2129/ if (UEconomics != null) { var balance = (int)UEconomics.Call("GetPlayerMoney", victim.UserIDString); var money = Math.Floor(balance * chance); if (money > 0) { UEconomics.Call("Withdraw", victim.UserIDString, money); UEconomics.Call("Deposit", attacker.UserIDString, money); Player.Reply(attacker, Lang("StoleMoney", attacker.UserIDString, money, victim.displayName)); } else { Player.Reply(attacker, Lang("StoleNothing", attacker.UserIDString, victim.displayName)); } } }
private void GivePlayerRewards(BasePlayer player, RewardInfo rewardInfo) { if (rewardInfo.econAmount > 0 && Economics) { Economics?.Call("Deposit", player.UserIDString, (double)rewardInfo.econAmount); } if (rewardInfo.rpAmount > 0 && ServerRewards) { ServerRewards?.Call("AddPoints", player.userID, rewardInfo.rpAmount); } if (rewardInfo.rewardItems.Count > 0) { foreach (RewardInfo.ItemData itemData in rewardInfo.rewardItems) { Item item = CreateItem(itemData); player.GiveItem(item, BaseEntity.GiveItemReason.PickedUp); } } SendReply(player, msg("reward_claimed", player.userID)); }
void OnPlayerLoot(PlayerLoot lootInventory, BaseEntity targetEntity) { if (!(targetEntity is BasePlayer)) { return; } var targetPlayer = (BasePlayer)targetEntity; var player = lootInventory.GetComponent("BasePlayer") as BasePlayer; var amount = config.Settings.Rewards[PluginRewards.Corpse]; if (!player || amount <= 0) { return; } Economics.CallHook("Deposit", player.userID, amount); if (config.Settings.ShowMessages) { PrintToChat(player, string.Format(config.Messages[PluginMessage.ReceivedForLoot], amount, targetPlayer.displayName)); } }
private object OnItemAction(Item item, string action) { if (action != "crush") { return(null); } if (item.info.shortname != "skull.human") { return(null); } string skullName = null; if (item.name != null) { skullName = item.name.Substring(10, item.name.Length - 11); } if (string.IsNullOrEmpty(skullName)) { return(DecideReturn(item)); } BasePlayer ownerPlayer = item.GetOwnerPlayer(); if (ownerPlayer == null) { if (nullCrusherMessage) { rust.BroadcastChat(null, string.Format(msg("Null Crusher"), skullName)); } return(DecideReturn(item)); } if (ownerPlayer.displayName == skullName) { if (ownCrusherMessage) { rust.BroadcastChat(null, string.Format(msg("Crushed own skull"), ownerPlayer.displayName)); } return(DecideReturn(item)); } BasePlayer skullOwner = BasePlayer.Find(skullName); if (skullOwner) { if (friendsSupport || clansSupport || teamsSupport) { if (IsTeamed(ownerPlayer, skullOwner)) { return(DecideReturn(item)); } } } if (!cacheDic.ContainsKey(ownerPlayer.UserIDString)) { cacheDic.Add(ownerPlayer.UserIDString, 0); } cacheDic[ownerPlayer.UserIDString]++; if (useEconomy) { if (Economics) { if (sendNotificaitionMessage) { ownerPlayer.ChatMessage(string.Format(msg("Economy Notice", ownerPlayer.UserIDString), moneyPerSkullCrush)); } Economics.CallHook("Deposit", ownerPlayer.userID, moneyPerSkullCrush); } } if (useServerRewards) { if (ServerRewards) { if (sendNotificaitionMessage) { ownerPlayer.ChatMessage(string.Format(msg("ServerRewards Notice", ownerPlayer.UserIDString), RPPerSkullCrush)); } ServerRewards.Call("AddPoints", ownerPlayer.userID, RPPerSkullCrush); } } if (normalCrusherMessage) { rust.BroadcastChat(null, string.Format(msg("Default Crush Message"), skullName, ownerPlayer.displayName)); } return(DecideReturn(item)); }
private void cmdBounty(BasePlayer player, string command, string[] args) { if (!permission.UserHasPermission(player.UserIDString, "bounty.use")) { SendReply(player, msg("no_permission", player.userID)); return; } if (args.Length == 0) { SendReply(player, string.Format(msg("title", player.userID), Title, Version)); if (configData.Rewards.AllowItems) { SendReply(player, msg("help1", player.userID)); } if (configData.Rewards.AllowServerRewards && ServerRewards) { SendReply(player, msg("help2", player.userID)); } if (configData.Rewards.AllowEconomics && Economics) { SendReply(player, msg("help3", player.userID)); } SendReply(player, msg("help4", player.userID)); SendReply(player, msg("help5", player.userID)); SendReply(player, msg("help6", player.userID)); SendReply(player, msg("help7", player.userID)); SendReply(player, msg("help8", player.userID)); if (player.IsAdmin || permission.UserHasPermission(player.UserIDString, "bounty.admin")) { SendReply(player, msg("help9", player.userID)); } return; } switch (args[0].ToLower()) { case "add": { if (args.Length < 3) { SendReply(player, msg("invalid_syntax", player.userID)); return; } List <BasePlayer> players = FindPlayer(args[2]); if (players.Count == 0) { SendReply(player, msg("no_player_found", player.userID)); return; } if (players.Count > 1) { SendReply(player, msg("multiple_players_found", player.userID)); return; } BasePlayer targetPlayer = players[0]; if (targetPlayer == null) { SendReply(player, msg("no_player_found", player.userID)); return; } if (targetPlayer == player) { SendReply(player, msg("cant_bounty_self", player.userID)); return; } PlayerData playerData; if (!storedData.players.TryGetValue(targetPlayer.userID, out playerData)) { playerData = new PlayerData(targetPlayer.displayName); storedData.players.Add(targetPlayer.userID, playerData); } if (playerData.activeBounties.Find(x => x.initiatorId == player.userID) != null) { SendReply(player, msg("has_active_bounty", player.userID)); return; } switch (args[1].ToLower()) { case "items": SpawnItemContainer(player); if (bountyCreator.ContainsKey(player.userID)) { bountyCreator[player.userID] = targetPlayer.userID; } else { bountyCreator.Add(player.userID, targetPlayer.userID); } return; case "rp": if (!configData.Rewards.AllowServerRewards || !ServerRewards || args.Length != 4) { SendReply(player, msg("invalid_syntax", player.userID)); return; } int rpAmount; if (!int.TryParse(args[3], out rpAmount)) { SendReply(player, msg("no_value_entered", player.userID)); return; } int availableRp = (int)ServerRewards?.Call("CheckPoints", player.userID); if (availableRp < rpAmount || !(bool)ServerRewards?.Call("TakePoints", player.userID, rpAmount)) { SendReply(player, msg("not_enough_rp", player.userID)); return; } CreateNewBounty(player, targetPlayer.userID, rpAmount, 0, null); return; case "eco": if (!configData.Rewards.AllowEconomics || !Economics || args.Length != 4) { SendReply(player, msg("invalid_syntax", player.userID)); return; } int ecoAmount; if (!int.TryParse(args[3], out ecoAmount)) { SendReply(player, msg("no_value_entered", player.userID)); return; } double availableEco = (double)Economics?.Call("Balance", player.UserIDString); if (availableEco < ecoAmount || !(bool)Economics?.Call("Withdraw", player.UserIDString, (double)ecoAmount)) { SendReply(player, msg("not_enough_eco", player.userID)); return; } CreateNewBounty(player, targetPlayer.userID, 0, ecoAmount, null); return; default: SendReply(player, msg("invalid_syntax", player.userID)); return; } } case "cancel": { if (args.Length < 2) { SendReply(player, msg("invalid_syntax", player.userID)); return; } IPlayer targetPlayer = covalence.Players.FindPlayer(args[1]); if (targetPlayer == null) { SendReply(player, msg("no_player_found", player.userID)); return; } CancelBounty(player, targetPlayer); } return; case "claim": { PlayerData playerData; if (!storedData.players.TryGetValue(player.userID, out playerData) || playerData.unclaimedRewards.Count == 0) { SendReply(player, msg("no_rewards_pending", player.userID)); return; } if (args.Length < 2) { SendReply(player, msg("help10", player.userID)); foreach (int rewardId in playerData.unclaimedRewards) { RewardInfo rewardInfo = storedData.rewards[rewardId]; string reward = string.Empty; if (rewardInfo.rewardItems.Count > 1) { for (int i = 0; i < rewardInfo.rewardItems.Count; i++) { RewardInfo.ItemData itemData = rewardInfo.rewardItems.ElementAt(i); reward += (string.Format(msg("reward_item", player.userID), itemData.amount, idToDisplayName[itemData.itemid]) + (i < rewardInfo.rewardItems.Count - 1 ? ", " : "")); } } else { reward = rewardInfo.econAmount > 0 ? string.Format(msg("reward_econ", player.userID), rewardInfo.econAmount) : string.Format(msg("reward_rp", player.userID), rewardInfo.rpAmount); } SendReply(player, string.Format(msg("reward_info", player.userID), rewardId, reward)); } } else { int rewardId; if (!int.TryParse(args[1], out rewardId) || !playerData.unclaimedRewards.Contains(rewardId)) { SendReply(player, msg("invalid_reward_id", player.userID)); return; } RewardInfo rewardInfo = storedData.rewards[rewardId]; GivePlayerRewards(player, rewardInfo); storedData.rewards.Remove(rewardId); playerData.unclaimedRewards.Remove(rewardId); } } return; case "view": { if (args.Length < 2) { SendReply(player, msg("invalid_syntax", player.userID)); return; } IPlayer targetPlayer = covalence.Players.FindPlayer(args[1]); if (targetPlayer == null) { SendReply(player, msg("no_player_found", player.userID)); return; } PlayerData playerData; if (!storedData.players.TryGetValue(ulong.Parse(targetPlayer.Id), out playerData) || playerData.activeBounties.Count == 0) { SendReply(player, msg("no_active_bounties", player.userID)); return; } SendReply(player, string.Format(msg("player_has_bounties", player.userID), targetPlayer.Name, playerData.activeBounties.Count)); foreach (var bounty in playerData.activeBounties) { RewardInfo rewardInfo = storedData.rewards[bounty.rewardId]; string reward = string.Empty; if (rewardInfo.rewardItems.Count > 1) { for (int i = 0; i < rewardInfo.rewardItems.Count; i++) { RewardInfo.ItemData itemData = rewardInfo.rewardItems.ElementAt(i); reward += (string.Format(msg("reward_item", player.userID), itemData.amount, idToDisplayName[itemData.itemid]) + (i < rewardInfo.rewardItems.Count - 1 ? ", " : "")); } } else { reward = rewardInfo.econAmount > 0 ? string.Format(msg("reward_econ", player.userID), rewardInfo.econAmount) : string.Format(msg("reward_rp", player.userID), rewardInfo.rpAmount); } SendReply(player, string.Format(msg("bounty_info", player.userID), bounty.initiatorName, FormatTime(CurrentTime() - bounty.initiatedTime), reward)); } } return; case "top": IEnumerable <PlayerData> top10Hunters = storedData.players.Values.OrderByDescending(x => x.bountiesClaimed).Take(10); string hunterMessage = msg("top_hunters", player.userID); foreach (PlayerData playerData in top10Hunters) { hunterMessage += string.Format(msg("top_hunter_entry", player.userID), playerData.displayName, playerData.bountiesClaimed); } SendReply(player, hunterMessage); return; case "wanted": IEnumerable <PlayerData> top10Hunted = storedData.players.Values.OrderByDescending(x => x.totalWantedTime + x.GetCurrentWantedTime()).Take(10); string wantedMessage = msg("top_wanted", player.userID); foreach (PlayerData playerData in top10Hunted) { wantedMessage += string.Format(msg("top_wanted_entry", player.userID), playerData.displayName, FormatTime(playerData.totalWantedTime + playerData.GetCurrentWantedTime()), playerData.totalBounties); } SendReply(player, wantedMessage); return; case "clear": { if (args.Length < 2) { SendReply(player, msg("invalid_syntax", player.userID)); return; } IPlayer targetPlayer = covalence.Players.FindPlayer(args[1]); if (targetPlayer == null) { SendReply(player, msg("no_player_found", player.userID)); return; } PlayerData playerData; if (!storedData.players.TryGetValue(ulong.Parse(targetPlayer.Id), out playerData) || playerData.activeBounties.Count == 0) { SendReply(player, msg("no_active_bounties", player.userID)); return; } foreach (var bounty in playerData.activeBounties) { storedData.rewards.Remove(bounty.rewardId); } playerData.activeBounties.Clear(); SendReply(player, string.Format(msg("bounties_cleared", player.userID), targetPlayer.Name)); } return; default: SendReply(player, msg("invalid_syntax", player.userID)); break; } }
[ChatCommand("x")] // SUR COMMANDE CHAT /x ou /X private void TellMeXCommand(BasePlayer player, string command, string[] args) { if (TellMeXIsOn == false) // SI GAME !ON, DISPLAY NEXT { float ToNext = Time.time - NextTellMeXTime; // CALCUL INTERVALLE EN SECONDES ToWait = ToNext.ToString("######;######"); // ARRONDI ET SUPPRESSION DU NEGATIF // NextTellMeXMsg = "Next 'Tell Me X' will start in "; Player.Message(player, $"<color={ChatColor}> {lang.GetMessage("NextTellMeXMsg", this, player.UserIDString)} {ToWait} seconds</color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon); return; } if (TellMeXPlayerIDs.Contains(player.userID)) // CHECK IF ALREADY PLAYED { float ToNext = TellMeXRate - (Time.time - NextTellMeXTime) + TellMeXRate; //v0.2 ToWait = ToNext.ToString("######"); // AlreadyTellMeXMsg = "You've already played !\nTry again in "; Player.Message(player, $"<color={ChatColor}> {lang.GetMessage("AlreadyTellMeXMsg", this, player.UserIDString)} {ToWait} seconds</color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon); return; } if (args.Length != 1) // si les arguments sont vides { // InvalidTellMeXMsg = "Invalid guess.\nTry something like <color=yellow>/x 1234</color>"; Player.Message(player, $"<color={ChatColor}> {lang.GetMessage("InvalidTellMeXMsg", this, player.UserIDString)} </color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon); return; } int PlayerNumber; // déclaration de l integer PlayerNumber bool isNumeric = int.TryParse(args[0], out PlayerNumber); // si c est numerique, on arrondi les args de la commande pour en sortir le PLayerNumber if (!isNumeric) // if chat is not numeric { // NotNumericTellMeXMsg par defaut : "" Player.Message(player, $"<color={ChatColor}> {lang.GetMessage("NotNumericTellMeXMsg", this, player.UserIDString)} </color>", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon); return; } if (args.Contains(XToFind)) // WINNER SI X EST DANS LES ARGS DE LA COMMANDE PLAYER { TellMeXIsOn = false; // GAME IS !ON NextTellMeXTime = Time.time + TellMeXRate; // NEXT TIME = TIMER + RATE TellMeXPlayerIDs.Clear(); // VIDE LA LISTE DES JOUEURS GivePlayerGift(player, ItemToWin); // EXECUTE GIVEPLAYER AVEC player ET ItemToWin string message = $"<color={ChatColor}> <color={WinnerColor}>{player.displayName}</color> {lang.GetMessage("WonTellMeXMsg", this, player.UserIDString)} [{ItemWon}]</color>"; if (UseServerRewards == true) { if (ServerRewards == true) { message = $"{message} + <color=#ffe556>[{RPOnWin}.RP]</color>"; ServerRewards?.Call("AddPoints", player.userID, (int)RPOnWin); // HOOK VERS PLUGIN ServerRewards POUR ADD RPWin } } if (UseEconomics == true) { if (Economics == true) { double amount = Convert.ToDouble(EcoOnWin); message = $"{message} + <color=#ffe556>[{EcoOnWin}.$]</color>"; Economics.Call("Deposit", player.userID, amount); // HOOK VERS PLUGIN Economics POUR ADD EcoWin } } Server.Broadcast($"{message}", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon); BroadcastMath(false); // PASSE LE VOID BROADCAST A FALSE } else // WE COULD SAY LOSER { string message = $"<color={ChatColor}> {lang.GetMessage("LoseTellMeXMsg", this, player.UserIDString)} </color>"; if (UseServerRewards == true) { if (ServerRewards == true) { message = $"{message} + <color=#ffe556>[{RPOnLose}.RP]</color>"; ServerRewards?.Call("AddPoints", player.userID, (int)RPOnLose); // HOOK VERS PLUGIN ServerRewards POUR ADD RPWin } } if (UseEconomics == true) { if (Economics == true) { double amount = Convert.ToDouble(EcoOnLose); message = $"{message} + <color=#ffe556>[{EcoOnLose}.$]</color>"; Economics.Call("Deposit", player.userID, amount); // HOOK VERS PLUGIN Economics POUR ADD EcoWin } } Player.Message(player, $"{message}", $"<color={PrefixColor}> {Prefix} </color>", SteamIDIcon); TellMeXPlayerIDs.Add(player.userID); // ADD PLAYER TO THOSE WHO TRIED TO FIND X } }