コード例 #1
0
        public void DocumentOptionSelectedEvent(Client player, int tramitation)
        {
            int money = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_MONEY);

            switch (tramitation)
            {
            case Constants.TRAMITATE_IDENTIFICATION:
                if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_DOCUMENTATION) > 0)
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_HAS_IDENTIFICATION);
                }
                else if (money < Constants.PRICE_IDENTIFICATION)
                {
                    String message = String.Format(Messages.ERR_PLAYER_NOT_IDENTIFICATION_MONEY, Constants.PRICE_IDENTIFICATION);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + message);
                }
                else
                {
                    String message = String.Format(Messages.INF_PLAYER_HAS_INDENTIFICATION, Constants.PRICE_IDENTIFICATION);
                    NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, money - Constants.PRICE_IDENTIFICATION);
                    NAPI.Data.SetEntityData(player, EntityData.PLAYER_DOCUMENTATION, Globals.GetTotalSeconds());
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + message);
                    Database.LogPayment(player.Name, Messages.GEN_FACTION_TOWNHALL, Messages.GEN_IDENTIFICATION, Constants.PRICE_IDENTIFICATION);
                }
                break;

            case Constants.TRAMITATE_MEDICAL_INSURANCE:
                if (NAPI.Data.GetEntityData(player, EntityData.PLAYER_MEDICAL_INSURANCE) > Globals.GetTotalSeconds())
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_HAS_MEDICAL_INSURANCE);
                }
                else if (money < Constants.PRICE_MEDICAL_INSURANCE)
                {
                    String message = String.Format(Messages.ERR_PLAYER_NOT_MEDICAL_INSURANCE_MONEY, Constants.PRICE_MEDICAL_INSURANCE);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + message);
                }
                else
                {
                    String message = String.Format(Messages.INF_PLAYER_HAS_MEDICAL_INSURANCE, Constants.PRICE_MEDICAL_INSURANCE);
                    NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, money - Constants.PRICE_MEDICAL_INSURANCE);
                    NAPI.Data.SetEntityData(player, EntityData.PLAYER_MEDICAL_INSURANCE, Globals.GetTotalSeconds() + 1209600);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + message);
                    Database.LogPayment(player.Name, Messages.GEN_FACTION_TOWNHALL, Messages.GEN_MEDICAL_INSURANCE, Constants.PRICE_MEDICAL_INSURANCE);
                }
                break;

            case Constants.TRAMITATE_TAXI_LICENSE:
                if (DrivingSchool.GetPlayerLicenseStatus(player, Constants.LICENSE_TAXI) > 0)
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_HAS_TAXI_LICENSE);
                }
                else if (money < Constants.PRICE_TAXI_LICENSE)
                {
                    String message = String.Format(Messages.ERR_PLAYER_NOT_TAXI_LICENSE_MONEY, Constants.PRICE_TAXI_LICENSE);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + message);
                }
                else
                {
                    String message = String.Format(Messages.INF_PLAYER_HAS_TAXI_LICENSE, Constants.PRICE_TAXI_LICENSE);
                    NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, money - Constants.PRICE_TAXI_LICENSE);
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + message);
                    DrivingSchool.SetPlayerLicense(player, Constants.LICENSE_TAXI, 1);
                    Database.LogPayment(player.Name, Messages.GEN_FACTION_TOWNHALL, Messages.GEN_TAXI_LICENSE, Constants.PRICE_TAXI_LICENSE);
                }
                break;

            case Constants.TRAMITATE_FINE_LIST:
                List <FineModel> fineList = Database.LoadPlayerFines(player.Name);
                if (fineList.Count > 0)
                {
                    NAPI.ClientEvent.TriggerClientEvent(player, "showPlayerFineList", NAPI.Util.ToJson(fineList));
                }
                else
                {
                    NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + Messages.INF_PLAYER_NO_FINES);
                }
                break;
            }
        }
コード例 #2
0
        public void DocumentOptionSelectedEvent(Client player, int tramitation)
        {
            int money = player.GetSharedData(EntityData.PLAYER_MONEY);

            switch (tramitation)
            {
            case Constants.TRAMITATE_IDENTIFICATION:
                if (player.GetData(EntityData.PLAYER_DOCUMENTATION) > 0)
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_has_identification);
                }
                else if (money < Constants.PRICE_IDENTIFICATION)
                {
                    string message = string.Format(ErrRes.player_not_identification_money, Constants.PRICE_IDENTIFICATION);
                    player.SendChatMessage(Constants.COLOR_ERROR + message);
                }
                else
                {
                    string message = string.Format(InfoRes.player_has_indentification, Constants.PRICE_IDENTIFICATION);
                    player.SetSharedData(EntityData.PLAYER_MONEY, money - Constants.PRICE_IDENTIFICATION);
                    player.SetData(EntityData.PLAYER_DOCUMENTATION, Globals.GetTotalSeconds());
                    player.SendChatMessage(Constants.COLOR_INFO + message);


                    Task.Factory.StartNew(() =>
                    {
                        // Log the payment made
                        Database.LogPayment(player.Name, GenRes.faction_townhall, GenRes.identification, Constants.PRICE_IDENTIFICATION);
                    });
                }
                break;

            case Constants.TRAMITATE_MEDICAL_INSURANCE:
                if (player.GetData(EntityData.PLAYER_MEDICAL_INSURANCE) > Globals.GetTotalSeconds())
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_has_medical_insurance);
                }
                else if (money < Constants.PRICE_MEDICAL_INSURANCE)
                {
                    string message = string.Format(ErrRes.player_not_medical_insurance_money, Constants.PRICE_MEDICAL_INSURANCE);
                    player.SendChatMessage(Constants.COLOR_ERROR + message);
                }
                else
                {
                    string message = string.Format(InfoRes.player_has_medical_insurance, Constants.PRICE_MEDICAL_INSURANCE);
                    player.SetSharedData(EntityData.PLAYER_MONEY, money - Constants.PRICE_MEDICAL_INSURANCE);
                    player.SetData(EntityData.PLAYER_MEDICAL_INSURANCE, Globals.GetTotalSeconds() + 1209600);
                    player.SendChatMessage(Constants.COLOR_INFO + message);


                    Task.Factory.StartNew(() =>
                    {
                        // Log the payment made
                        Database.LogPayment(player.Name, GenRes.faction_townhall, GenRes.medical_insurance, Constants.PRICE_MEDICAL_INSURANCE);
                    });
                }
                break;

            case Constants.TRAMITATE_TAXI_LICENSE:
                if (DrivingSchool.GetPlayerLicenseStatus(player, Constants.LICENSE_TAXI) > 0)
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_has_taxi_license);
                }
                else if (money < Constants.PRICE_TAXI_LICENSE)
                {
                    string message = string.Format(ErrRes.player_not_taxi_license_money, Constants.PRICE_TAXI_LICENSE);
                    player.SendChatMessage(Constants.COLOR_ERROR + message);
                }
                else
                {
                    string message = string.Format(InfoRes.player_has_taxi_license, Constants.PRICE_TAXI_LICENSE);
                    player.SetSharedData(EntityData.PLAYER_MONEY, money - Constants.PRICE_TAXI_LICENSE);
                    player.SendChatMessage(Constants.COLOR_INFO + message);
                    DrivingSchool.SetPlayerLicense(player, Constants.LICENSE_TAXI, 1);


                    Task.Factory.StartNew(() =>
                    {
                        // Log the payment made
                        Database.LogPayment(player.Name, GenRes.faction_townhall, GenRes.taxi_license, Constants.PRICE_TAXI_LICENSE);
                    });
                }
                break;

            case Constants.TRAMITATE_FINE_LIST:
                Task.Factory.StartNew(() =>
                {
                    List <FineModel> fineList = Database.LoadPlayerFines(player.Name);
                    if (fineList.Count > 0)
                    {
                        player.TriggerEvent("showPlayerFineList", NAPI.Util.ToJson(fineList));
                    }
                    else
                    {
                        player.SendChatMessage(Constants.COLOR_INFO + InfoRes.player_no_fines);
                    }
                });
                break;
            }
        }
コード例 #3
0
        public void LicenseCommand(Client player, string args)
        {
            if (player.GetData(EntityData.PLAYER_FACTION) == Constants.FACTION_POLICE && player.GetData(EntityData.PLAYER_RANK) == 6)
            {
                string[] arguments = args.Trim().Split(' ');
                if (arguments.Length == 3 || arguments.Length == 4)
                {
                    Client target = null;

                    // Get the target player
                    if (int.TryParse(arguments[2], out int targetId) && arguments.Length == 3)
                    {
                        target = Globals.GetPlayerById(targetId);
                    }
                    else
                    {
                        target = NAPI.Player.GetPlayerFromName(arguments[2] + arguments[3]);
                    }

                    // Check whether the target player is connected
                    if (target == null || target.HasData(EntityData.PLAYER_PLAYING) == false)
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_FOUND);
                    }
                    else if (player.Position.DistanceTo(target.Position) > 2.5f)
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_PLAYER_TOO_FAR);
                    }
                    else
                    {
                        string playerMessage = string.Empty;
                        string targetMessage = string.Empty;

                        switch (arguments[0].ToLower())
                        {
                        case Messages.ARG_GIVE:
                            switch (arguments[1].ToLower())
                            {
                            case Messages.ARG_WEAPON:
                                // Add one month to the license
                                target.SetData(EntityData.PLAYER_WEAPON_LICENSE, Globals.GetTotalSeconds() + 2628000);

                                playerMessage = string.Format(Messages.INF_WEAPON_LICENSE_GIVEN, target.Name);
                                targetMessage = string.Format(Messages.INF_WEAPON_LICENSE_RECEIVED, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            default:
                                player.SendChatMessage(Constants.COLOR_HELP + Messages.GEN_LICENSE_COMMAND);
                                break;
                            }
                            break;

                        case Messages.ARG_REMOVE:
                            switch (arguments[1].ToLower())
                            {
                            case Messages.ARG_WEAPON:
                                // Adjust the date to the current one
                                target.SetData(EntityData.PLAYER_WEAPON_LICENSE, Globals.GetTotalSeconds());

                                playerMessage = string.Format(Messages.INF_WEAPON_LICENSE_REMOVED, target.Name);
                                targetMessage = string.Format(Messages.INF_WEAPON_LICENSE_LOST, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            case Messages.ARG_CAR:
                                // Remove car license
                                DrivingSchool.SetPlayerLicense(target, Constants.LICENSE_CAR, -1);

                                playerMessage = string.Format(Messages.INF_CAR_LICENSE_REMOVED, target.Name);
                                targetMessage = string.Format(Messages.INF_CAR_LICENSE_LOST, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            case Messages.ARG_MOTORCYCLE:
                                // Remove motorcycle license
                                DrivingSchool.SetPlayerLicense(target, Constants.LICENSE_MOTORCYCLE, -1);

                                playerMessage = string.Format(Messages.INF_MOTO_LICENSE_REMOVED, target.Name);
                                targetMessage = string.Format(Messages.INF_MOTO_LICENSE_LOST, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            default:
                                break;
                            }
                            break;

                        default:
                            player.SendChatMessage(Constants.COLOR_HELP + Messages.GEN_LICENSE_COMMAND);
                            break;
                        }
                    }
                }
                else
                {
                    player.SendChatMessage(Constants.COLOR_HELP + Messages.GEN_LICENSE_COMMAND);
                }
            }
            else
            {
                player.SendChatMessage(Constants.COLOR_ERROR + Messages.ERR_NOT_POLICE_CHIEF);
            }
        }
コード例 #4
0
ファイル: Police.cs プロジェクト: xentripetal/XenRP
        public void LicenseCommand(Client player, string args)
        {
            if (Faction.IsPoliceMember(player) && player.GetData(EntityData.PLAYER_RANK) == 6)
            {
                var arguments = args.Trim().Split(' ');
                if (arguments.Length == 3 || arguments.Length == 4)
                {
                    Client target;

                    // Get the target player
                    if (int.TryParse(arguments[2], out var targetId) && arguments.Length == 3)
                    {
                        target = Globals.GetPlayerById(targetId);
                    }
                    else
                    {
                        target = NAPI.Player.GetPlayerFromName(arguments[2] + arguments[3]);
                    }

                    // Check whether the target player is connected
                    if (target == null || target.GetData(EntityData.PLAYER_PLAYING) == null)
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_found);
                    }
                    else if (player.Position.DistanceTo(target.Position) > 2.5f)
                    {
                        player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_too_far);
                    }
                    else
                    {
                        string playerMessage;
                        string targetMessage;

                        switch (arguments[0].ToLower())
                        {
                        case Commands.ARG_GIVE:
                            switch (arguments[1].ToLower())
                            {
                            case Commands.ARG_WEAPON:
                                // Add one month to the license
                                target.SetData(EntityData.PLAYER_WEAPON_LICENSE,
                                               Scheduler.GetTotalSeconds() + 2628000);

                                playerMessage = string.Format(InfoRes.weapon_license_given, target.Name);
                                targetMessage = string.Format(InfoRes.weapon_license_received, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            default:
                                player.SendChatMessage(Constants.COLOR_HELP + Commands.HLP_LICENSE_COMMAND);
                                break;
                            }

                            break;

                        case Commands.ARG_REMOVE:
                            switch (arguments[1].ToLower())
                            {
                            case Commands.ARG_WEAPON:
                                // Adjust the date to the current one
                                target.SetData(EntityData.PLAYER_WEAPON_LICENSE, Scheduler.GetTotalSeconds());

                                playerMessage = string.Format(InfoRes.weapon_license_removed, target.Name);
                                targetMessage = string.Format(InfoRes.weapon_license_lost, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            case Commands.ARG_CAR:
                                // Remove car license
                                DrivingSchool.SetPlayerLicense(target, Constants.LICENSE_CAR, -1);

                                playerMessage = string.Format(InfoRes.car_license_removed, target.Name);
                                targetMessage = string.Format(InfoRes.car_license_lost, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;

                            case Commands.ARG_MOTORCYCLE:
                                // Remove motorcycle license
                                DrivingSchool.SetPlayerLicense(target, Constants.LICENSE_MOTORCYCLE, -1);

                                playerMessage = string.Format(InfoRes.moto_license_removed, target.Name);
                                targetMessage = string.Format(InfoRes.moto_license_lost, player.Name);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);
                                break;
                            }

                            break;

                        default:
                            player.SendChatMessage(Constants.COLOR_HELP + Commands.HLP_LICENSE_COMMAND);
                            break;
                        }
                    }
                }
                else
                {
                    player.SendChatMessage(Constants.COLOR_HELP + Commands.HLP_LICENSE_COMMAND);
                }
            }
            else
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_police_chief);
            }
        }