Exemple #1
0
        public void PayPlayerFinesEvent(Client player, string finesJson)
        {
            Task.Factory.StartNew(() => {
                var fineList       = Database.LoadPlayerFines(player.Name);
                var removedFines   = NAPI.Util.FromJson <List <FineModel> >(finesJson);
                int money          = player.GetSharedData(EntityData.PLAYER_MONEY);
                var finesProcessed = 0;
                var amount         = 0;

                // Get the money amount for all the fines
                foreach (var fine in removedFines)
                {
                    amount += fine.amount;
                    finesProcessed++;
                }

                if (amount == 0)
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_no_fines);
                }
                else if (amount > money)
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_fine_money);
                }
                else
                {
                    // Remove money from player
                    player.SetSharedData(EntityData.PLAYER_MONEY, money - amount);

                    // Delete paid fines
                    Database.RemoveFines(removedFines);
                    DBBankCommands.LogPayment(player.Name, GenRes.faction_townhall, GenRes.fines_payment, amount);

                    // Check if all fines were paid
                    if (finesProcessed == fineList.Count)
                    {
                        player.TriggerEvent("backTownHallIndex");
                    }

                    var message = string.Format(InfoRes.player_fines_paid, amount);
                    player.SendChatMessage(Constants.COLOR_INFO + message);
                }
            });
        }
Exemple #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)
                {
                    var message = string.Format(ErrRes.player_not_identification_money,
                                                Constants.PRICE_IDENTIFICATION);
                    player.SendChatMessage(Constants.COLOR_ERROR + message);
                }
                else
                {
                    var message = string.Format(InfoRes.player_has_indentification, Constants.PRICE_IDENTIFICATION);
                    player.SetSharedData(EntityData.PLAYER_MONEY, money - Constants.PRICE_IDENTIFICATION);
                    player.SetData(EntityData.PLAYER_DOCUMENTATION, Scheduler.GetTotalSeconds());
                    player.SendChatMessage(Constants.COLOR_INFO + message);


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

                break;

            case Constants.TRAMITATE_MEDICAL_INSURANCE:
                if (player.GetData(EntityData.PLAYER_MEDICAL_INSURANCE) > Scheduler.GetTotalSeconds())
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_has_medical_insurance);
                }
                else if (money < Constants.PRICE_MEDICAL_INSURANCE)
                {
                    var message = string.Format(ErrRes.player_not_medical_insurance_money,
                                                Constants.PRICE_MEDICAL_INSURANCE);
                    player.SendChatMessage(Constants.COLOR_ERROR + message);
                }
                else
                {
                    var 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, Scheduler.GetTotalSeconds() + 1209600);
                    player.SendChatMessage(Constants.COLOR_INFO + message);


                    Task.Factory.StartNew(() => {
                        // Log the payment made
                        DBBankCommands.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)
                {
                    var message = string.Format(ErrRes.player_not_taxi_license_money, Constants.PRICE_TAXI_LICENSE);
                    player.SendChatMessage(Constants.COLOR_ERROR + message);
                }
                else
                {
                    var 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
                        DBBankCommands.LogPayment(player.Name, GenRes.faction_townhall, GenRes.taxi_license,
                                                  Constants.PRICE_TAXI_LICENSE);
                    });
                }

                break;

            case Constants.TRAMITATE_FINE_LIST:
                Task.Factory.StartNew(() => {
                    var 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;
            }
        }
Exemple #3
0
        public void AcceptHookerCommand(Client player)
        {
            if (player.GetData(EntityData.HOOKER_TYPE_SERVICE) == null)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.no_service_offered);
            }
            else if (player.GetData(EntityData.PLAYER_ALREADY_FUCKING) != null)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.already_fucking);
            }
            else if (player.VehicleSeat != (int)VehicleSeat.Driver)
            {
                player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_vehicle_driving);
            }
            else
            {
                if (player.Vehicle.EngineStatus)
                {
                    player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.engine_on);
                }
                else
                {
                    Client target = player.GetData(EntityData.PLAYER_JOB_PARTNER);
                    if (player.GetData(EntityData.HOOKER_TYPE_SERVICE) != null)
                    {
                        int amount = player.GetData(EntityData.JOB_OFFER_PRICE);
                        int money  = player.GetSharedData(EntityData.PLAYER_MONEY);

                        if (target.GetData(EntityData.PLAYER_PLAYING) != null)
                        {
                            if (amount > money)
                            {
                                player.SendChatMessage(
                                    Constants.COLOR_ERROR + ErrRes.player_not_enough_money);
                            }
                            else
                            {
                                int targetMoney = target.GetSharedData(EntityData.PLAYER_MONEY);
                                player.SetSharedData(EntityData.PLAYER_MONEY, money - amount);
                                target.SetSharedData(EntityData.PLAYER_MONEY, targetMoney + amount);

                                var playerMessage = string.Format(InfoRes.service_paid, amount);
                                var targetMessage = string.Format(InfoRes.service_received, amount);
                                player.SendChatMessage(Constants.COLOR_INFO + playerMessage);
                                target.SendChatMessage(Constants.COLOR_INFO + targetMessage);

                                player.SetData(EntityData.PLAYER_ANIMATION, target);
                                player.SetData(EntityData.PLAYER_ALREADY_FUCKING, target);
                                target.SetData(EntityData.PLAYER_ALREADY_FUCKING, player);

                                // Reset the entity data
                                player.ResetData(EntityData.JOB_OFFER_PRICE);
                                player.ResetData(EntityData.PLAYER_JOB_PARTNER);

                                // Check the type of the service
                                if (player.GetData(EntityData.HOOKER_TYPE_SERVICE) ==
                                    Constants.HOOKER_SERVICE_BASIC)
                                {
                                    player.PlayAnimation("mini@prostitutes@sexlow_veh",
                                                         "low_car_bj_loop_player", (int)Constants.AnimationFlags.Loop);
                                    target.PlayAnimation("mini@prostitutes@sexlow_veh",
                                                         "low_car_bj_loop_female", (int)Constants.AnimationFlags.Loop);

                                    // Timer to finish the service
                                    var sexTimer = new Timer(OnSexServiceTimer, player, 120000,
                                                             Timeout.Infinite);
                                    sexTimerList.Add(player.Value, sexTimer);
                                }
                                else
                                {
                                    player.PlayAnimation("mini@prostitutes@sexlow_veh",
                                                         "low_car_sex_loop_player", (int)Constants.AnimationFlags.Loop);
                                    target.PlayAnimation("mini@prostitutes@sexlow_veh",
                                                         "low_car_sex_loop_female", (int)Constants.AnimationFlags.Loop);

                                    // Timer to finish the service
                                    var sexTimer = new Timer(OnSexServiceTimer, player, 180000,
                                                             Timeout.Infinite);
                                    sexTimerList.Add(player.Value, sexTimer);
                                }

                                Task.Factory.StartNew(() => {
                                    // Save the log into the database
                                    DBBankCommands.LogPayment(player.Name, target.Name, GenRes.hooker, amount);
                                });
                            }
                        }
                        else
                        {
                            player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_found);
                        }
                    }
                }
            }
        }