Exemplo n.º 1
0
 private async Task Test()
 {
     foreach (Player player in Players)
     {
         if (player != Game.Player)
         {
             if (player.IsDead)
             {
                 if (deadPlayers.Contains(player.Character.Handle))
                 {
                     return;
                 }
                 deadPlayers.Add(player.Character.Handle);
                 Entity ent = player.Character.GetKiller();
                 if (ent != null)
                 {
                     if (ent.Handle == Game.Player.Character.Handle)
                     {
                         Debug.WriteLine("You killed " + player.Name);
                         while (ClientHandler.BountiesUpdating)
                         {
                             await Delay(10);
                         }
                         ClientBounty bounty = ClientHandler.GetBountyForPlayer(player.ServerId);
                         if (bounty != null)
                         {
                             Debug.WriteLine("Bounty is not null for entity");
                             TriggerServerEvent("es_me:addMoney", bounty.RewardAmount);
                             Debug.WriteLine("Rewarded player for bounty: " + bounty.RewardAmount);
                             ClientHandler.NotifyPlayer("You have killed ~p~" + GetSafePlayerName(player.Name) + " ~s~for a total bounty reward of ~g~$" + bounty.RewardAmount + "~s~.");
                             TriggerServerEvent("zBounties:notifyAll", "~p~" + GetSafePlayerName(Game.Player.Name) + " ~s~has killed ~p~" + GetSafePlayerName(player.Name) + " ~s~for a total bounty reward of ~g~$" + bounty.RewardAmount + "~s~.");
                             if (ClientHandler.CurrWantedLevel < 3)
                             {
                                 Debug.WriteLine("Removed bounty for good behaviour (less than 3 stars)");
                                 ClientHandler.UpdateWantedLevel(0, false);
                                 TriggerServerEvent("zBounties:resetBounty");
                             }
                             while (ClientHandler.BountiesUpdating)
                             {
                                 await Delay(10);
                             }
                             ClientHandler.RemoveClientBounty(bounty);
                         }
                     }
                 }
             }
             else
             {
                 if (deadPlayers.Contains(player.Character.Handle))
                 {
                     deadPlayers.Remove(player.Character.Handle);
                 }
             }
         }
     }
     await Delay(10);
 }
Exemplo n.º 2
0
 public static void RemoveClientBounty(ClientBounty bounty)
 {
     foreach (var cB in bounties)
     {
         if (bounty == cB)
         {
             bounties.Remove(cB);
         }
     }
 }
Exemplo n.º 3
0
        private async Task MonitorPlayerKills()
        {
            int  entHandle = 0;
            bool entExists = GetEntityPlayerIsFreeAimingAt(Game.Player.Handle, ref entHandle);

            if (entExists)
            {
                Debug.WriteLine("Entity Exists");
                if (IsEntityAPed(entHandle))
                {
                    Debug.WriteLine("Entity is a Ped");
                    foreach (Player player in Players)
                    {
                        if (player.Character.Handle == entHandle)
                        {
                            Debug.WriteLine("Entity is " + player.Name);
                            if (player.IsDead)
                            {
                                Debug.WriteLine("Player is dead");
                                if (deadPlayers.Contains(entHandle))
                                {
                                    return;
                                }
                                deadPlayers.Add(entHandle);
                                Debug.WriteLine("Entity added to dead players list");
                                if (player.Character.GetKiller().Handle == Game.Player.Character.Handle)
                                {
                                    Debug.WriteLine("You killed " + player.Name);
                                    while (ClientHandler.BountiesUpdating)
                                    {
                                        await Delay(1);
                                    }
                                    ClientBounty bounty = ClientHandler.GetBountyForPlayer(player.ServerId);
                                    if (bounty != null)
                                    {
                                        Debug.WriteLine("Bounty is not null for entity");
                                        TriggerServerEvent("es_me:addMoney", bounty.RewardAmount);
                                        Debug.WriteLine("Rewarded player for bounty: " + bounty.RewardAmount);
                                        ClientHandler.NotifyPlayer("You have killed ~p~" + GetSafePlayerName(player.Name) + " ~s~for a total bounty reward of ~g~$" + bounty.RewardAmount + "~s~.");
                                        TriggerServerEvent("zBounties:notifyAll", "~p~" + GetSafePlayerName(Game.Player.Name) + " ~s~has killed ~p~" + GetSafePlayerName(player.Name) + " ~s~for a total bounty reward of ~g~$" + bounty.RewardAmount + "~s~.");
                                        if (ClientHandler.CurrWantedLevel < 3)
                                        {
                                            Debug.WriteLine("Removed bounty for good behaviour (less than 3 stars)");
                                            ClientHandler.UpdateWantedLevel(0, false);
                                            TriggerServerEvent("zBounties:resetBounty");
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (deadPlayers.Contains(entHandle))
                                {
                                    deadPlayers.Remove(entHandle);
                                }
                            }
                        }
                    }
                }
            }
            await Delay(1);
        }