void RewardForPlayerKill(BasePlayer player, BasePlayer victim, double multiplier = 1) { if (rewardrates.human > 0) { bool success = true; bool isFriend = false; if (IsFriendsLoaded) { isFriend = (bool)Friends?.CallHook("HasFriend", player.userID, victim.userID); } if (!isFriend && IsClansLoaded) { string pclan = (string)Clans?.CallHook("GetClanOf", player); string vclan = (string)Clans?.CallHook("GetClanOf", victim); if (pclan == vclan) { isFriend = true; } } if (!isFriend) { var reward = rewardrates.human * multiplier; if (IsEconomicsLoaded) //Eco { if (options.Economincs_TakeMoneyFromVictim) { if (!(bool)Economics?.Call("Transfer", victim.UserIDString, player.UserIDString, rewardrates.human * multiplier)) { SendChatMessage(player, Lang("VictimNoMoney", player.UserIDString, victim.displayName), Lang("Prefix")); success = false; } } else { Economics?.Call("Deposit", player.UserIDString, reward); } } if (IsServerRewardsLoaded) //ServerRewards { if (options.ServerRewards_TakeMoneyFromVictim) { ServerRewards?.Call("TakePoints", new object [] { victim.userID, rewardrates.human * multiplier }); } ServerRewards?.Call("AddPoints", player.userID, (int)(reward)); success = true; } if (success) //Send message if transaction was successful { SendChatMessage(player, Lang("KillReward", player.UserIDString, rewardrates.human * multiplier, victim.displayName), Lang("Prefix")); LogToFile(Name, $"[{DateTime.Now}] " + player.displayName + " got " + rewardrates.human * multiplier + " for killing " + victim.displayName, this); if (options.PrintToConsole) { Puts(player.displayName + " got " + reward + " for killing " + victim.displayName); } } } } }
private bool IsFriend(ulong playerid, ulong ownerid) { if (configData.Settings.useFriends && Friends != null) { var fr = Friends?.CallHook("AreFriends", playerid, ownerid); if (fr != null && (bool)fr) { return(true); } } if (configData.Settings.useClans && Clans != null) { string playerclan = (string)Clans?.CallHook("GetClanOf", playerid); string ownerclan = (string)Clans?.CallHook("GetClanOf", ownerid); if (playerclan != null && ownerclan != null) { if (playerclan == ownerclan) { return(true); } } } if (configData.Settings.useTeams) { BasePlayer player = BasePlayer.FindByID(playerid); if (player != null) { if (player.currentTeam != 0) { RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindTeam(player.currentTeam); if (playerTeam != null) { if (playerTeam.members.Contains(ownerid)) { return(true); } } } } } return(false); }
private void OnEntityDeath(BaseCombatEntity entity, HitInfo info) { if (entity == null) { return; } if (!Economics && !ServerRewards) { return; } if (!info?.Initiator?.ToPlayer()) { return; } var player = info.Initiator.ToPlayer(); var animal = UppercaseFirst(entity.LookupPrefab().ToString().Replace("[0]", "")); amount = 0; if (entity.ToPlayer() != null && !(entity is NPCPlayer)) { var victim = entity.ToPlayer(); if (player == victim) { return; } amount = config.Settings.Rewards[PluginRewards.Player]; animal = "player"; if (Friends && config.Settings.Rewards[PluginRewards.PlayerFriend] != 0) { bool isFriend = (bool)Friends?.CallHook("HasFriend", victim.userID, player.userID); bool isFriendReverse = (bool)Friends?.CallHook("HasFriend", player.userID, victim.userID); if (isFriend && isFriendReverse) { amount = config.Settings.Rewards[PluginRewards.PlayerFriend]; animal = "friend"; } } if (Clans && config.Settings.Rewards[PluginRewards.ClanMember] != 0) { string victimclan = (string)Clans?.CallHook("GetClanOf", victim); string playerclan = (string)Clans?.CallHook("GetClanOf", player); if (victimclan == playerclan) { amount = config.Settings.Rewards[PluginRewards.ClanMember]; animal = "clan member"; } } } else { if (entity is NPCMurderer) { animal = "Murderer"; config.Settings.Rewards.TryGetValue(animal, out amount); } else if (entity is NPCPlayerApex) { animal = "Scientist"; config.Settings.Rewards.TryGetValue(animal, out amount); } else if (entity.GetComponent("BaseNpc")) { animal = UppercaseFirst(entity.LookupPrefab().ToString().Replace("[0]", "")); config.Settings.Rewards.TryGetValue(animal, out amount); } } if (amount != 0) { GiveCredit(player, "kill", amount, animal); } }