Пример #1
0
        public override bool OnPlayerDisconnect(Client player)
        {
            Opponent curOp = Opponents.FirstOrDefault(op => op.Client == player);

            if (curOp == null)
            {
                return(true);
            }

            if (RememberedBlips.ContainsKey(player.NetConnection.RemoteUniqueIdentifier))
            {
                RememberedBlips[player.NetConnection.RemoteUniqueIdentifier] = curOp.Blip;
            }
            else
            {
                RememberedBlips.Add(player.NetConnection.RemoteUniqueIdentifier, curOp.Blip);
            }

            if (curOp.Vehicle != 0)
            {
                Program.ServerInstance.SendNativeCallToPlayer(player, 0xAD738C3085FE7E11, curOp.Vehicle, true, false);
                Program.ServerInstance.SendNativeCallToPlayer(player, 0xAE3CBE5BF394C9C9, curOp.Vehicle);
            }

            if (curOp.Blip != 0)
            {
                Program.ServerInstance.SendNativeCallToPlayer(player, 0x45FF974EEE1C8734, curOp.Blip, 0);
            }

            lock (Opponents) Opponents.Remove(curOp);
            return(true);
        }
Пример #2
0
    public void onDisconnect(Client player, string reason)
    {
        Opponent curOp = Opponents.FirstOrDefault(op => op.Client == player);

        if (curOp == null)
        {
            return;
        }
        API.deleteEntity(curOp.Vehicle);
        lock (Opponents) Opponents.Remove(curOp);
    }
Пример #3
0
        public override bool OnChatMessage(Client sender, string message)
        {
            if (message == "/votemap" && !IsVoteActive() && (!IsRaceOngoing || DateTime.UtcNow.Subtract(RaceStart).TotalSeconds > 60))
            {
                StartVote();
                return(false);
            }
            else if (message.StartsWith("/vote"))
            {
                if (DateTime.Now.Subtract(VoteStart).TotalSeconds > 60)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "No current vote is in progress.");
                    return(false);
                }

                var args = message.Split();

                if (args.Length <= 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/vote [id]");
                    return(false);
                }

                if (Voters.Contains(sender))
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "ERROR", "You have already voted!");
                    return(false);
                }

                int choice;
                if (!int.TryParse(args[1], out choice) || choice <= 0 || choice > AvailableChoices.Count)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/vote [id]");
                    return(false);
                }

                Votes[choice]++;
                Program.ServerInstance.SendChatMessageToPlayer(sender, "You have voted for " + AvailableChoices[choice].Name);
                Voters.Add(sender);
                return(false);
            }
            else if (message == "/q")
            {
                Opponent curOp = Opponents.FirstOrDefault(op => op.Client == sender);

                if (curOp != null)
                {
                    if (curOp.Blip != 0)
                    {
                        Program.ServerInstance.SendNativeCallToPlayer(sender, 0x45FF974EEE1C8734, curOp.Blip, 0);
                        //Program.ServerInstance.SendNativeCallToPlayer(sender, 0x86A652570E5F25DD, new PointerArgumentInt() {Data = curOp.Blip});
                    }

                    lock (Opponents) Opponents.Remove(curOp);
                }

                Program.ServerInstance.KickPlayer(sender, "requested");
                return(false);
            }
            return(true);
        }
Пример #4
0
 void RemoveOpponent(Opponent opponent)
 {
     Opponents.Remove(opponent);
 }