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())); } }
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); }
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)); }