Esempio n. 1
0
 private static void PlayerDisconnectedHandler(IPlayer player, string reason)
 {
     try
     {
         if (player == null || !player.Exists)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"PL-{charId}").ToList())
         {
             if (veh == null || !veh.Exists)
             {
                 continue;
             }
             ServerVehicles.RemoveVehiclePermanently(veh);
             veh.Remove();
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 2
0
 public async Task BuyVehicle(IPlayer player, int shopid, string hash)
 {
     try
     {
         Stopwatch stopwatch = new Stopwatch();
         stopwatch.Start();
         if (player == null || !player.Exists || shopid <= 0 || hash == "")
         {
             return;
         }
         ulong fHash  = Convert.ToUInt64(hash);
         int   charId = User.GetPlayerOnline(player);
         if (charId == 0 || fHash == 0)
         {
             return;
         }
         int      Price     = ServerVehicleShops.GetVehicleShopPrice(shopid, fHash);
         bool     PlaceFree = true;
         Position ParkOut   = ServerVehicleShops.GetVehicleShopOutPosition(shopid);
         Rotation RotOut    = ServerVehicleShops.GetVehicleShopOutRotation(shopid);
         foreach (IVehicle veh in Alt.Server.GetVehicles().ToList())
         {
             if (veh.Position.IsInRange(ParkOut, 2f))
             {
                 PlaceFree = false; break;
             }
         }
         if (!PlaceFree)
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Der Ausladepunkt ist belegt."); return;
         }
         int rnd = new Random().Next(100000, 999999);
         if (ServerVehicles.ExistServerVehiclePlate($"NL{rnd}"))
         {
             BuyVehicle(player, shopid, hash); return;
         }
         if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < Price)
         {
             HUDHandler.SendNotification(player, 4, 5000, $"Du hast nicht genügend Bargeld dabei ({Price}$)."); return;
         }
         CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", Price, "inventory");
         ServerVehicles.CreateVehicle(fHash, charId, 0, 0, false, 25, ParkOut, RotOut, $"NL{rnd}", 134, 134);
         CharactersInventory.AddCharacterItem(charId, $"Fahrzeugschluessel NL{rnd}", 2, "inventory");
         HUDHandler.SendNotification(player, 2, 5000, $"Fahrzeug erfolgreich gekauft.");
         if (!CharactersTablet.HasCharacterTutorialEntryFinished(charId, "buyVehicle"))
         {
             CharactersTablet.SetCharacterTutorialEntryState(charId, "buyVehicle", true);
             HUDHandler.SendNotification(player, 1, 2500, "Erfolg freigeschaltet: Mobilität");
         }
         stopwatch.Stop();
         if (stopwatch.Elapsed.Milliseconds > 30)
         {
             Alt.Log($"{charId} - BuyVehicle benötigte {stopwatch.Elapsed.Milliseconds}ms");
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 3
0
        private void createnewmod(IPlayer player, string MName, int MType, int MID)
        {
            try
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                if (player.IsInVehicle)
                {
                    if (player.Vehicle == null || !player.Vehicle.Exists)
                    {
                        return;
                    }
                    uint vehHash = player.Vehicle.Model;

                    bool success = ServerVehicles.AddVehicleMods(vehHash, MName, MType, MID);
                    if (success)
                    {
                        HUDHandler.SendNotification(player, 2, 2500, $"Mod gespeichert: {vehHash} - {MName} - {MType} - {MID}");
                        Alt.Log($"Mod erfolgreich gespeichert");
                    }
                    else
                    {
                        HUDHandler.SendNotification(player, 4, 2500, $"Mod konnte nicht gespeichert werden (existiert er schon?): {vehHash} - {MName} - {MType} - {MID}");
                        Alt.Log($"FEHLER: MOD NICHT GESPEICHERT {MType} - {MID} - {MName}");
                    }
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 4
0
        public static void CMD_ParkALlVehs(IPlayer player)
        {
            try
            {
                if (player == null || !player.Exists || player.AdminLevel() <= 8)
                {
                    return;
                }
                int count = 0;
                foreach (var veh in Alt.Server.GetVehicles().ToList().Where(x => x != null && x.Exists && x.HasVehicleId()))
                {
                    if (veh == null || !veh.Exists || !veh.HasVehicleId())
                    {
                        continue;
                    }
                    int currentGarageId = ServerVehicles.GetVehicleGarageId(veh);
                    if (currentGarageId <= 0)
                    {
                        continue;
                    }
                    ServerVehicles.SetVehicleInGarage(veh, true, currentGarageId);
                    count++;
                }

                player.SendChatMessage($"{count} Fahrzeuge eingeparkt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 5
0
 public async Task RepairVehicle(IPlayer player, IVehicle vehicle)
 {
     try
     {
         if (player == null || !player.Exists || vehicle == null || !vehicle.Exists)
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0 || player.HasPlayerRopeCuffs() || player.HasPlayerHandcuffs() || player.IsPlayerUnconscious())
         {
             return;
         }
         if (!CharactersInventory.ExistCharacterItem(charId, "Reparaturkit", "inventory") && !CharactersInventory.ExistCharacterItem(charId, "Reparaturkit", "backpack"))
         {
             HUDHandler.SendNotification(player, 4, 2000, "Du besitzt kein Reparaturkit."); return;
         }
         if (CharactersInventory.ExistCharacterItem(charId, "Reparaturkit", "inventory"))
         {
             CharactersInventory.RemoveCharacterItemAmount(charId, "Reparaturkit", 1, "inventory");
         }
         else if (CharactersInventory.ExistCharacterItem(charId, "Reparaturkit", "backpack"))
         {
             CharactersInventory.RemoveCharacterItemAmount(charId, "Reparaturkit", 1, "backpack");
         }
         //ToDo: Reparatur-Animation abspielen
         ServerVehicles.SetVehicleEngineHealthy(vehicle, true);
         Alt.EmitAllClients("Client:Utilities:repairVehicle", vehicle);
         //player.EmitLocked("Client:Utilities:repairVehicle", vehicle);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 6
0
 public async Task LSPDAppSearchVehiclePlate(IPlayer player, string targetPlate)
 {
     try
     {
         if (player == null || !player.Exists || targetPlate == "")
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 4, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
         }
         if (!ServerFactions.IsCharacterInAnyFaction(charId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keiner Fraktion."); return;
         }
         if (ServerFactions.GetCharacterFactionId(charId) != 2 && ServerFactions.GetCharacterFactionId(charId) != 1)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht im L.S.P.D. oder der Justiz angestellt."); return;
         }
         if (!ServerFactions.IsCharacterInFactionDuty(charId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht im Dienst."); return;
         }
         if (!ServerVehicles.ExistServerVehiclePlate(targetPlate))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Fehler: Das angegebene Kennzeichen wurde nicht gefunden."); return;
         }
         int vehicleId = ServerVehicles.GetVehicleIdByPlate(targetPlate);
         if (vehicleId <= 0)
         {
             return;
         }
         int ownerId = ServerVehicles.GetVehicleOwnerById(vehicleId);
         if (ownerId <= 0)
         {
             return;
         }
         string owner      = Characters.GetCharacterName(ownerId);
         string vehName    = ServerVehicles.GetVehicleNameOnHash(ServerVehicles.GetVehicleHashById(vehicleId));
         string manufactor = ServerVehicles.GetVehicleManufactorOnHash(ServerVehicles.GetVehicleHashById(vehicleId));
         string buyDate    = $"{ServerVehicles.GetVehicleBuyDate(vehicleId).ToString("d", CultureInfo.CreateSpecificCulture("de-DE"))}";
         string trunk      = $"{ServerVehicles.GetVehicleTrunkCapacityOnHash(ServerVehicles.GetVehicleHashById(vehicleId))}kg";
         string tax        = $"{ServerAllVehicles.GetVehicleTaxes(ServerVehicles.GetVehicleHashById(vehicleId))}$";
         string maxfuel    = $"{ServerVehicles.GetVehicleFuelLimitOnHash(ServerVehicles.GetVehicleHashById(vehicleId))}";
         string fuelType   = ServerVehicles.GetVehicleFuelTypeOnHash(ServerVehicles.GetVehicleHashById(vehicleId));
         player.EmitLocked("Client:Tablet:SetLSPDAppSearchVehiclePlateData", owner, vehName, manufactor, buyDate, trunk, maxfuel, tax, fuelType);
         HUDHandler.SendNotification(player, 2, 1500, $"Fahrzeugabfrage durchgeführt: {targetPlate}");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 7
0
        internal static void StartMinijob(IPlayer player)
        {
            try
            {
                if (player == null || !player.Exists || !((ClassicColshape)startJobShape).IsInRange((ClassicPlayer)player))
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijob() == "Elektrolieferant")
                {
                    //Job abbrechen
                    foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"EL-{charId}").ToList())
                    {
                        if (veh == null || !veh.Exists)
                        {
                            continue;
                        }
                        ServerVehicles.RemoveVehiclePermanently(veh);
                        veh.Remove();
                    }
                    HUDHandler.SendNotification(player, 2, 1500, "Du hast den Minijob: Elektrolieferant beendet.");
                    player.SetPlayerCurrentMinijob("None");
                    player.SetPlayerCurrentMinijobStep("None");
                    player.SetPlayerCurrentMinijobActionCount(0);
                    player.SetPlayerCurrentMinijobRouteId(0);
                    return;
                }
                else if (player.GetPlayerCurrentMinijob() == "None")
                {
                    //Job annehmen
                    foreach (var veh in Alt.Server.GetVehicles().ToList())
                    {
                        if (veh == null || !veh.Exists)
                        {
                            continue;
                        }
                        if (veh.Position.IsInRange(Constants.Positions.Minijob_Elektrolieferant_VehOutPos, 5f))
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Der Ausparkpunkt links vom Haupteingang ist blockiert."); return;
                        }
                    }

                    ServerVehicles.CreateVehicle(2307837162, charId, 2, 0, false, 0, Constants.Positions.Minijob_Elektrolieferant_VehOutPos, Constants.Positions.Minijob_Elektrolieferant_VehOutRot, $"EL-{charId}", 132, 132);
                    player.SetPlayerCurrentMinijob("Elektrolieferant");
                    player.SetPlayerCurrentMinijobStep("FirstStepInVehicle");
                    HUDHandler.SendNotification(player, 1, 2500, "Du hast den Minijob begonnen. Wir haben dir ein Fahrzeug mit Energiezellen links vom Haupteingang abgestellt.");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 8
0
        public async Task switchTuningColor(IPlayer player, IVehicle vehicle, string Type, string Data, int R, int G, int B)
        {
            try
            {
                if (player == null || !player.Exists || vehicle == null || !vehicle.Exists)
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                int vehId  = (int)vehicle.GetVehicleId();
                if (charId <= 0 || vehId <= 0)
                {
                    return;
                }
                vehicle.ModKit = 1;
                if (Type == "Test")
                {
                    switch (Data)
                    {
                    case "Neonröhren":
                        vehicle.NeonColor = new Rgba((byte)R, (byte)G, (byte)B, 255);
                        vehicle.SetNeonActive(true, true, true, true);
                        break;

                    case "Reifenqualm":
                        vehicle.TireSmokeColor = new Rgba((byte)R, (byte)G, (byte)B, 255);
                        break;
                    }
                }
                else if (Type == "Build")
                {
                    switch (Data)
                    {
                    case "Neonröhren":
                        vehicle.SetNeonActive(true, true, true, true);
                        ServerVehicles.InstallVehicleMod(vehicle, 300, R);
                        ServerVehicles.InstallVehicleMod(vehicle, 301, G);
                        ServerVehicles.InstallVehicleMod(vehicle, 302, B);
                        break;

                    case "Reifenqualm":
                        ServerVehicles.InstallVehicleMod(vehicle, 400, R);
                        ServerVehicles.InstallVehicleMod(vehicle, 401, G);
                        ServerVehicles.InstallVehicleMod(vehicle, 402, B);
                        break;
                    }
                    LoggingService.NewFactionLog(4, charId, vehId, "tuneVehColor", $"{Characters.GetCharacterName(charId)} hat Fahrzeug ({vehId}) modifiziert ({Data} - ({R}-{G}-{B}))");
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 9
0
 internal static void TryStartMinijob(IPlayer player)
 {
     try
     {
         if (player == null || !player.Exists || !((ClassicColshape)startJobShape).IsInRange((ClassicPlayer)player))
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (player.GetPlayerCurrentMinijob() == "Busfahrer")
         {
             //Job abbrechen
             foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"BUS-{charId}").ToList())
             {
                 if (veh == null || !veh.Exists)
                 {
                     continue;
                 }
                 ServerVehicles.RemoveVehiclePermanently(veh);
                 veh.Remove();
             }
             HUDHandler.SendNotification(player, 2, 1500, "Du hast den Minijob: Busfahrer beendet.");
             player.SetPlayerCurrentMinijob("None");
             player.SetPlayerCurrentMinijobRouteId(0);
             player.SetPlayerCurrentMinijobStep("None");
             player.SetPlayerCurrentMinijobActionCount(0);
             player.EmitLocked("Client:Minijob:RemoveJobMarker");
             return;
         }
         else if (player.GetPlayerCurrentMinijob() == "None")
         {
             //Levelauswahl anzeigen
             if (!CharactersMinijobs.ExistCharacterMinijobEntry(charId, "Busfahrer"))
             {
                 CharactersMinijobs.CreateCharacterMinijobEntry(charId, "Busfahrer");
             }
             var availableRoutes = Model.GetAvailableRoutes(charId);
             if (availableRoutes == "[]")
             {
                 return;
             }
             player.EmitLocked("Client:MinijobBusdriver:openCEF", availableRoutes);
             return;
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 10
0
 public async Task StartMiniJob(IPlayer player, int routeId)
 {
     try
     {
         if (player == null || !player.Exists || routeId <= 0)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (player.GetPlayerCurrentMinijob() != "None")
         {
             return;
         }
         if (!Model.ExistRoute(routeId))
         {
             return;
         }
         if (CharactersMinijobs.GetCharacterMinijobEXP(charId, "Busfahrer") < Model.GetRouteNeededEXP(routeId))
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht die benötigen EXP für diese Linie ({Model.GetRouteNeededEXP(routeId)}EXP - du hast {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Busfahrer")}EXP)."); return;
         }
         foreach (var veh in Alt.Server.GetVehicles().ToList())
         {
             if (veh == null || !veh.Exists)
             {
                 continue;
             }
             if (veh.Position.IsInRange(Constants.Positions.Minijob_Busdriver_VehOutPos, 8f))
             {
                 HUDHandler.SendNotification(player, 3, 5000, "Der Ausparkpunkt ist blockiert."); return;
             }
         }
         ServerVehicles.CreateVehicle(Model.GetRouteVehicleHash(routeId), charId, 2, 0, false, 0, Constants.Positions.Minijob_Busdriver_VehOutPos, Constants.Positions.Minijob_Busdriver_VehOutRot, $"BUS-{charId}", 132, 132);
         player.SetPlayerCurrentMinijob("Busfahrer");
         player.SetPlayerCurrentMinijobStep("FirstStepInVehicle");
         player.SetPlayerCurrentMinijobRouteId((ulong)routeId);
         player.SetPlayerCurrentMinijobActionCount(1);
         HUDHandler.SendNotification(player, 1, 2500, "Du hast den Minijob begonnen. Wir haben dir einen Bus am Tor ausgeparkt, steige ein.");
         return;
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 11
0
 public async Task OnPlayerEnterVehicle_Handler(IVehicle vehicle, IPlayer client, byte seat)
 {
     try
     {
         if (client == null || !client.Exists)
         {
             return;
         }
         client.EmitLocked("Client:HUD:updateHUDPosInVeh", true, ServerVehicles.GetVehicleFuel(vehicle), ServerVehicles.GetVehicleKM(vehicle));
         client.EmitLocked("Client:HUD:GetDistanceForVehicleKM");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 12
0
 private static void PlayerEnterVehicle(IVehicle vehicle, IPlayer player, byte seat)
 {
     try
     {
         if (player == null || vehicle == null || !player.Exists || !vehicle.Exists)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (ServerVehicles.GetVehicleType(vehicle) != 2)
         {
             return;
         }
         if (ServerVehicles.GetVehicleOwner(vehicle) != charId)
         {
             return;
         }
         if (player.GetPlayerCurrentMinijob() != "Müllmann")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijobStep() == "None")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijobStep() == "FirstStepInVehicle")
         {
             HUDHandler.SendNotification(player, 1, 2500, "Fahre zum ersten Zielort um den Müll abzuholen, dieser wurde auf deinem GPS markiert.");
             var spot = Model.GetCharacterMinijobNextSpot(player);
             if (spot == null)
             {
                 return;
             }
             player.SetPlayerCurrentMinijobStep("PICKUP_TRASH");
             player.EmitLocked("Client:Minijob:CreateJobMarker", "Minijob: Müll abholen", 3, 514, 1, spot.posX, spot.posY, spot.posZ, false);
             return;
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 13
0
 private static void PlayerEnterVehicle(IVehicle vehicle, IPlayer player, byte seat)
 {
     try
     {
         if (player == null || vehicle == null || !player.Exists || !vehicle.Exists)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (ServerVehicles.GetVehicleType(vehicle) != 2)
         {
             return;
         }
         if (ServerVehicles.GetVehicleOwner(vehicle) != charId)
         {
             return;
         }
         if (player.GetPlayerCurrentMinijob() == "None")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijobStep() == "None")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijob() != "Pilot")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijobStep() == "FirstStepInVehicle")
         {
             player.SetPlayerCurrentMinijobStep("DRIVE_TO_DESTINATION");
             player.SetPlayerCurrentMinijobActionCount(1);
             HUDHandler.SendNotification(player, 1, 2500, "Fahre zum ersten Punkt und warte dort 15 Sekunden.");
             player.EmitLocked("Client:Minijob:CreateJobMarker", "Pilot: Checkpoint", 3, 514, 30, MinijobSpots_[0].depositShape.Position.X, MinijobSpots_[0].depositShape.Position.Y, MinijobSpots_[0].depositShape.Position.Z, true);
             return;
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 14
0
 private static void PlayerEnterVehicle(IVehicle vehicle, IPlayer player, byte seat)
 {
     try
     {
         if (player == null || vehicle == null || !player.Exists || !vehicle.Exists)
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (ServerVehicles.GetVehicleType(vehicle) != 2)
         {
             return;
         }
         if (ServerVehicles.GetVehicleOwner(vehicle) != charId)
         {
             return;
         }
         if (player.GetPlayerCurrentMinijob() != "Busfahrer")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijobStep() == "None")
         {
             return;
         }
         if (player.GetPlayerCurrentMinijobStep() == "FirstStepInVehicle")
         {
             var spot = Model.GetCharacterMinijobNextSpot(player);
             if (spot == null)
             {
                 return;
             }
             HUDHandler.SendNotification(player, 1, 25000, "Fahre zur ersten Haltestelle und warte dort 10 Sekunden.");
             player.SetPlayerCurrentMinijobStep("DRIVE_TO_NEXT_STATION");
             player.EmitLocked("Client:Minijob:CreateJobMarker", "Minijob: Haltestelle", 3, 80, 30, spot.posX, spot.posY, spot.posZ, false);
             return;
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 15
0
        public static string GetTabletVehicleStoreItems()
        {
            var items = ServerVehicleShopsItems_.Where(x => x.isOnlyOnlineAvailable == true).Select(x => new
            {
                x.shopId,
                name       = ServerVehicles.GetVehicleNameOnHash(x.hash),
                manufactor = ServerVehicles.GetVehicleManufactorOnHash(x.hash),
                fueltype   = ServerVehicles.GetVehicleFuelTypeOnHash(x.hash),
                fuellimit  = ServerVehicles.GetVehicleFuelLimitOnHash(x.hash),
                storage    = ServerVehicles.GetVehicleTrunkCapacityOnHash(x.hash),
                seats      = ServerVehicles.GetVehicleMaxSeatsOnHash(x.hash),
                hash       = x.hash.ToString(),
                x.price,
            }).OrderBy(x => x.name).ToList();

            return(JsonConvert.SerializeObject(items));
        }
Esempio n. 16
0
        public async Task TowVehicle(IPlayer player, IVehicle vehicle)
        {
            try
            {
                if (player == null || !player.Exists || vehicle == null || !vehicle.Exists)
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                int vehId  = (int)vehicle.GetVehicleId();
                if (charId <= 0 || player.HasPlayerRopeCuffs() || player.HasPlayerHandcuffs() || player.IsPlayerUnconscious() || !ServerFactions.IsCharacterInAnyFaction(charId) || !vehicle.Position.IsInRange(Constants.Positions.AutoClubLosSantos_StoreVehPosition, 5f) || vehId <= 0)
                {
                    return;
                }
                if (ServerFactions.GetCharacterFactionId(charId) != 4)
                {
                    return;
                }
                int vehClass = ServerAllVehicles.GetVehicleClass(vehicle.Model);
                switch (vehClass)
                {
                case 0:     //Fahrzeuge
                    ServerVehicles.SetVehicleInGarage(vehicle, true, 10);
                    break;

                case 1:     //Boote
                    break;

                case 2:     //Flugzeuge
                    break;

                case 3:     //Helikopter
                    break;
                }
                ServerFactions.SetFactionBankMoney(4, ServerFactions.GetFactionBankMoney(4) + 1500); //ToDo: Anpassen
                HUDHandler.SendNotification(player, 2, 2000, "Fahrzeug erfolgreich verwahrt.");
                LoggingService.NewFactionLog(4, charId, vehId, "towVehicle", $"{Characters.GetCharacterName(charId)} hat das Fahrzeug mit der ID {vehId} abgeschleppt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 17
0
 public async Task resetTuningToNormal(IPlayer player, IVehicle vehicle)
 {
     try
     {
         if (player == null || !player.Exists || vehicle == null || !vehicle.Exists)
         {
             return;
         }
         if (player.GetCharacterMetaId() <= 0 || vehicle.GetVehicleId() <= 0)
         {
             return;
         }
         ServerVehicles.SetVehicleModsCorrectly(vehicle);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 18
0
        public static void SendInformationToVehicleHUD(IPlayer player)
        {
            if (player == null || !player.Exists)
            {
                return;
            }
            IVehicle Veh = player.Vehicle;

            if (!Veh.Exists)
            {
                return;
            }
            ulong vehID = Veh.GetVehicleId();

            if (vehID == 0)
            {
                return;
            }
            player.EmitLocked("Client:HUD:SetPlayerHUDVehicleInfos", ServerVehicles.GetVehicleFuel(Veh), ServerVehicles.GetVehicleKM(Veh));
        }
Esempio n. 19
0
        public static string GetCharacterTabletVehicles(int charId)
        {
            if (charId == 0)
            {
                return("");
            }
            var items = ServerVehicles.ServerVehicles_.Where(x => x.charid == charId).Select(x => new
            {
                x.id,
                name = ServerVehicles.GetVehicleNameOnHash(x.hash),
                x.plate,
                lastgarage = ServerGarages.GetGarageName(x.garageId),
                parkstate  = x.isInGarage,
                hasgps     = true,
                posX       = GetCharacterTabletVehiclePosition(x.id).X,
                posY       = GetCharacterTabletVehiclePosition(x.id).Y,
            }).ToList();

            return(JsonConvert.SerializeObject(items));
        }
Esempio n. 20
0
        public static string GetVehicleShopItems(int vehShopId)
        {
            if (vehShopId <= 0)
            {
                return("undefined");
            }

            var items = ServerVehicleShopsItems_.Where(x => x.shopId == vehShopId && x.isOnlyOnlineAvailable == false).Select(x => new
            {
                name          = ServerVehicles.GetVehicleNameOnHash(x.hash),
                manufactor    = ServerVehicles.GetVehicleManufactorOnHash(x.hash),
                fueltype      = ServerVehicles.GetVehicleFuelTypeOnHash(x.hash),
                maxfuel       = ServerVehicles.GetVehicleFuelLimitOnHash(x.hash),
                trunkcapacity = ServerVehicles.GetVehicleTrunkCapacityOnHash(x.hash),
                seats         = ServerVehicles.GetVehicleMaxSeatsOnHash(x.hash),
                hash          = x.hash.ToString(),
                price         = x.price,
            }).ToList();

            return(JsonConvert.SerializeObject(items));
        }
Esempio n. 21
0
 public static void CMD_parkVehicleById(IPlayer player, int vehId)
 {
     try
     {
         if (player == null || !player.Exists || player.AdminLevel() <= 8 || vehId <= 0)
         {
             return;
         }
         var vehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x != null && x.Exists && x.HasVehicleId() && (int)x.GetVehicleId() == vehId);
         if (vehicle == null)
         {
             return;
         }
         ServerVehicles.SetVehicleInGarage(vehicle, true, 25);
         HUDHandler.SendNotification(player, 4, 5000, $"Fahrzeug {vehId} in Garage 1(Pillbox) eingeparkt");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 22
0
 public static void CMD_parkVehicle(IPlayer player, string plate)
 {
     try
     {
         if (player == null || !player.Exists || player.AdminLevel() <= 1 || string.IsNullOrWhiteSpace(plate))
         {
             return;
         }
         var vehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x != null && x.Exists && x.HasVehicleId() && (int)x.GetVehicleId() > 0 && x.NumberplateText.ToLower() == plate.ToLower());
         if (vehicle == null)
         {
             return;
         }
         ServerVehicles.SetVehicleInGarage(vehicle, true, 25);
         HUDHandler.SendNotification(player, 4, 5000, $"Fahrzeug mit dem Kennzeichen {plate} in Garage 1 (Pillbox) eingeparkt");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 23
0
        internal static void OpenLicensingCEF(IPlayer player)
        {
            try
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                if (!player.Position.IsInRange(Constants.Positions.VehicleLicensing_Position, 3f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du hast dich zu weit entfernt."); return;
                }

                var vehicleList = Alt.Server.GetVehicles().Where(x => x.GetVehicleId() > 0 && x.Position.IsInRange(Constants.Positions.VehicleLicensing_VehPosition, 10f) && ServerVehicles.GetVehicleOwner(x) == charId).Select(x => new
                {
                    vehId    = x.GetVehicleId(),
                    ownerId  = ServerVehicles.GetVehicleOwner(x),
                    vehName  = ServerVehicles.GetVehicleNameOnHash(x.Model),
                    vehPlate = x.NumberplateText,
                }).ToList();

                if (vehicleList.Count <= 0)
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Keines deiner Fahrzeuge steht hinter dem Rathaus (an der roten Fahrzeugmarkierung)."); return;
                }
                player.EmitLocked("Client:VehicleLicensing:openCEF", JsonConvert.SerializeObject(vehicleList));
                Alt.Log($"{JsonConvert.SerializeObject(vehicleList)}");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 24
0
 public async Task UpdateVehicleKM(IPlayer player, float km)
 {
     //KM = bei 600 Meter = 600
     //600 / 1000 = 0,6   = 0,6km ?
     try
     {
         if (player == null || !player.Exists || km <= 0)
         {
             return;
         }
         if (!player.IsInVehicle || player.Vehicle == null)
         {
             return;
         }
         float fKM = km / 1000;
         fKM = fKM + ServerVehicles.GetVehicleKM(player.Vehicle);
         ServerVehicles.SetVehicleKM(player.Vehicle, fKM);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Esempio n. 25
0
        public async Task FuelVehicle(IPlayer player, int vID, int fuelstationId, string fueltype, int selectedLiterAmount, int selectedLiterPrice)
        {
            try
            {
                if (player == null || !player.Exists || vID == 0 || fuelstationId == 0 || fueltype == "" || selectedLiterAmount <= 0 || selectedLiterPrice == 0)
                {
                    return;
                }
                ulong vehID  = Convert.ToUInt64(vID);
                int   charId = User.GetPlayerOnline(player);
                if (vehID <= 0 || charId <= 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                var vehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == vehID);
                if (vehicle == null || !vehicle.Exists)
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten. [FEHLERCODE: FUEL-004]"); return;
                }
                if (ServerVehicles.GetVehicleType(vehicle) == 0)
                {
                    if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory"))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du hast nicht genügend Bargeld dabei."); return;
                    }
                    if (CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < selectedLiterPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du hast nicht genügend Bargeld dabei."); return;
                    }
                }
                if (!player.Position.IsInRange(vehicle.Position, 8f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Du hast dich zu weit vom Fahrzeug entfernt."); return;
                }
                if (ServerVehicles.GetVehicleFuel(vehicle) >= ServerVehicles.GetVehicleFuelLimitOnHash(vehicle.Model))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Das Fahrzeug ist bereits voll getankt."); return;
                }
                var fuelStation = ServerFuelStations.ServerFuelStations_.FirstOrDefault(x => x.id == fuelstationId);
                if (fuelStation == null)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Ein unerwarteter Fehler ist aufgetreten. [FEHLERCODE: FUEL-005]"); return;
                }
                int duration = 500 * selectedLiterAmount;
                HUDHandler.SendNotification(player, 1, duration, "Fahrzeug wird betankt, bitte warten..");
                await Task.Delay(duration);

                lock (player)
                {
                    if (!player.Position.IsInRange(vehicle.Position, 8f))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Du hast dich zu weit vom Fahrzeug entfernt."); return;
                    }
                }
                float fuelVal = ServerVehicles.GetVehicleFuel(vehicle) + selectedLiterAmount;
                if (fuelVal > ServerVehicles.GetVehicleFuelLimitOnHash(vehicle.Model))
                {
                    fuelVal = ServerVehicles.GetVehicleFuelLimitOnHash(vehicle.Model);
                }
                if (ServerVehicles.GetVehicleType(vehicle) == 0)
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", selectedLiterPrice, "inventory");
                }
                ServerVehicles.SetVehicleFuel(vehicle, fuelVal);
                if (ServerVehicles.GetVehicleFuelTypeOnHash(vehicle.Model) != fueltype)
                {
                    ServerVehicles.SetVehicleEngineState(vehicle, false); ServerVehicles.SetVehicleEngineHealthy(vehicle, false); return;
                }
                ServerFuelStations.SetFuelStationBankMoney(fuelstationId, ServerFuelStations.GetFuelStationBankMoney(fuelstationId) + selectedLiterPrice);

                if (ServerFuelStations.GetFuelStationOwnerId(fuelstationId) != 0)
                {
                    ServerFuelStations.SetFuelStationAvailableLiters(fuelstationId, ServerFuelStations.GetFuelStationAvailableLiters(fuelstationId) - selectedLiterAmount);
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 26
0
        public async Task StartMiniJob(IPlayer player, int level)
        {
            try
            {
                if (player == null || !player.Exists || level <= 0)
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijob() != "None")
                {
                    return;
                }
                foreach (var veh in Alt.Server.GetVehicles().ToList())
                {
                    if (veh == null || !veh.Exists)
                    {
                        continue;
                    }
                    if (veh.Position.IsInRange(Constants.Positions.Minijob_Pilot_VehOutPos, 8f))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Der Hangar ist blockiert."); return;
                    }
                }
                switch (level)
                {
                case 1:
                    ServerVehicles.CreateVehicle(2621610858, charId, 2, 0, false, 0, Constants.Positions.Minijob_Pilot_VehOutPos, Constants.Positions.Minijob_Pilot_VehOutRot, $"PL-{charId}", 132, 132);
                    break;

                case 2:
                    if (CharactersMinijobs.GetCharacterMinijobEXP(charId, "Pilot") < 50)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht die nötigen EXP für diese Stufe (50 EXP - du hast {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Pilot")}EXP)."); return;
                    }
                    ServerVehicles.CreateVehicle(1341619767, charId, 2, 0, false, 0, Constants.Positions.Minijob_Pilot_VehOutPos, Constants.Positions.Minijob_Pilot_VehOutRot, $"PL-{charId}", 132, 132);
                    break;

                case 3:
                    if (CharactersMinijobs.GetCharacterMinijobEXP(charId, "Pilot") < 100)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht die nötigen EXP für diese Stufe (100 EXP - du hast {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Pilot")}EXP)."); return;
                    }
                    ServerVehicles.CreateVehicle(2999939664, charId, 2, 0, false, 0, Constants.Positions.Minijob_Pilot_VehOutPos, Constants.Positions.Minijob_Pilot_VehOutRot, $"PL-{charId}", 132, 132);
                    break;
                }
                player.SetPlayerCurrentMinijob("Pilot");
                player.SetPlayerCurrentMinijobStep("FirstStepInVehicle");
                player.SetPlayerCurrentMinijobActionCount(0);
                player.EmitLocked("Client:Minijob:RemoveJobMarker");
                HUDHandler.SendNotification(player, 1, 2500, "Du hast den Minijob begonnen. Wir haben dir ein Flugzeug im Hangar abgestellt, steige ein.");
                return;
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 27
0
        public async Task UseItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer)
        {
            try
            {
                string ECData     = null,
                       CarKeyData = null;
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || User.GetPlayerOnline(player) == 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (ServerItems.IsItemUseable(ServerItems.ReturnNormalItemName(itemname)) == false)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Dieser Gegenstand ist nicht benutzbar ({itemname})!"); return;
                }
                int charId = player.CharacterId;
                if (charId <= 0 || CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer) == false)
                {
                    return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Die angegeben zu nutzende Anzahl ist nicht vorhanden ({itemname})!"); return;
                }
                if (itemname.Contains("EC Karte"))
                {
                    string[] SplittedItemName = itemname.Split(' '); ECData = itemname.Replace("EC Karte ", ""); itemname = "EC Karte";
                }
                else if (itemname.Contains("Fahrzeugschluessel"))
                {
                    string[] SplittedItemName = itemname.Split(' '); CarKeyData = itemname.Replace("Fahrzeugschluessel ", ""); itemname = "Autoschluessel";
                }

                if (ServerItems.IsItemDesire(itemname))
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    Characters.SetCharacterHunger(charId, Characters.GetCharacterHunger(charId) + ServerItems.GetItemDesireFood(itemname) * itemAmount);
                    Characters.SetCharacterThirst(charId, Characters.GetCharacterThirst(charId) + ServerItems.GetItemDesireDrink(itemname) * itemAmount);
                    player.EmitLocked("Client:HUD:UpdateDesire", Characters.GetCharacterHunger(charId), Characters.GetCharacterThirst(charId)); //HUD updaten
                }
                else if (itemname == "Beamtenschutzweste")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Beamtenschutzweste", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 100);
                    player.Armor = 100;
                }
                if (itemname == "Rucksack" || itemname == "Tasche")
                {
                    if (fromContainer == "backpack")
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Kleidungen & Taschen können nicht aus dem Rucksack aus benutzt werden."); return;
                    }
                    if (Characters.GetCharacterBackpack(charId) == "Rucksack")
                    {
                        if (itemname == "Rucksack")
                        {
                            if (CharactersInventory.GetCharacterBackpackItemCount(charId) == 0)
                            {
                                Characters.SetCharacterBackpack(player, "None");
                                HUDHandler.SendNotification(player, 2, 5000, "Du hast deinen Rucksack ausgezogen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast zuviele Sachen im Rucksack, du kannst deinen Rucksack nicht ablegen.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast bereits eine Tasche angelegt, lege diese vorher ab um deinen Rucksack anzulegen.");
                        }
                    }
                    else if (Characters.GetCharacterBackpack(charId) == "Tasche")
                    {
                        if (itemname == "Tasche")
                        {
                            if (CharactersInventory.GetCharacterBackpackItemCount(charId) == 0)
                            {
                                Characters.SetCharacterBackpack(player, "None");
                                HUDHandler.SendNotification(player, 2, 5000, "Du hast deine Tasche ausgezogen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast zuviele Sachen in deiner Tasche, du kannst deine Tasche nicht ablegen.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast bereits einen Rucksack angelegt, lege diesen vorher ab um deine Tasche anzulegen.");
                        }
                    }
                    else if (Characters.GetCharacterBackpack(charId) == "None")
                    {
                        Characters.SetCharacterBackpack(player, itemname);
                        HUDHandler.SendNotification(player, 2, 5000, "Du hast deine Tasche / deinen Rucksack angezogen.");
                    }
                }
                else if (itemname == "EC Karte")
                {
                    var atmPos = ServerATM.ServerATM_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1f));
                    if (atmPos == null || player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du bist an keinem ATM oder sitzt in einem Auto."); return;
                    }
                    int usingAccountNumber = Convert.ToInt32(ECData);
                    if (CharactersBank.GetBankAccountLockStatus(usingAccountNumber))
                    {
                        if (CharactersInventory.ExistCharacterItem(charId, "EC Karte " + usingAccountNumber, "inventory"))
                        {
                            CharactersInventory.RemoveCharacterItemAmount(charId, "EC Karte " + usingAccountNumber, 1, "inventory");
                        }
                        HUDHandler.SendNotification(player, 3, 5000, $"Ihre EC Karte wurde einzogen da diese gesperrt ist."); return;
                    }
                    player.EmitLocked("Client:ATM:BankATMcreateCEF", CharactersBank.GetBankAccountPIN(usingAccountNumber), usingAccountNumber, atmPos.zoneName);
                }
                else if (ServerItems.GetItemType(itemname) == "weapon")
                {
                    if (itemname.Contains("Munitionsbox"))
                    {
                        string wName = itemname.Replace(" Munitionsbox", "");
                        CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                        CharactersInventory.AddCharacterItem(charId, $"{wName} Munition", 30 * itemAmount, fromContainer);
                    }
                    else if (itemname.Contains("Munition"))
                    {
                        WeaponHandler.EquipCharacterWeapon(player, "Ammo", itemname, itemAmount, fromContainer);
                    }
                    else
                    {
                        WeaponHandler.EquipCharacterWeapon(player, "Weapon", itemname, 0, fromContainer);
                    }
                }
                else if (itemname == "Brecheisen")
                {
                    var house = ServerHouses.ServerHouses_.FirstOrDefault(x => x.ownerId > 0 && x.isLocked && ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                    if (house != null)
                    {
                        HouseHandler.BreakIntoHouse(player, house.id);
                        return;
                    }
                }
                else if (itemname == "Verbandskasten")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Verbandskasten", 1, fromContainer);
                    Characters.SetCharacterHealth(charId, 200);
                    player.Health = 200;
                }
                else if (itemname == "Benzinkanister" && player.IsInVehicle && player.Vehicle.Exists)
                {
                    if (ServerVehicles.GetVehicleFuel(player.Vehicle) >= ServerVehicles.GetVehicleFuelLimitOnHash(player.Vehicle.Model))
                    {
                        HUDHandler.SendNotification(player, 4, 2000, "Der Tank ist bereits voll."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Benzinkanister", 1, fromContainer);
                    ServerVehicles.SetVehicleFuel(player.Vehicle, ServerVehicles.GetVehicleFuel(player.Vehicle) + 15.0f);
                    HUDHandler.SendNotification(player, 2, 2000, "Du hast das Fahrzeug erfolgreich aufgetankt.");
                }
                else if (itemname == "Weste")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Weste", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 100);
                    player.Armor = 100;
                    if (Characters.GetCharacterGender(charId))
                    {
                        player.EmitLocked("Client:SpawnArea:setCharClothes", 9, 17, 2);
                    }
                    else
                    {
                        player.EmitLocked("Client:SpawnArea:setCharClothes", 9, 15, 2);
                    }
                }
                else if (itemname == "Pedalo")
                {
                    HUDHandler.SendNotification(player, 1, 3500, "Bruder muss los..");
                    player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", true, 0);  //Ragdoll setzen
                    player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", false, 0); //Ragdoll setzen
                }
                else if (itemname == "Kokain")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Kokain", 1, fromContainer);
                    HUDHandler.SendNotification(player, 2, 2000, "Du hast Koks gezogen du bist nun 15 Minuten effektiver.");
                    player.EmitLocked("Client:Inventory:PlayEffect", "DrugsMichaelAliensFight", 900000);
                    Characters.SetCharacterFastFarm(charId, true, 15);
                }
                else if (itemname == "Joint")
                {
                    if (player.Armor >= 60)
                    {
                        HUDHandler.SendNotification(player, 3, 2000, "Weiter kannst du dich nicht selbst heilen."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Joint", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 15);
                    player.Armor = +15;
                }
                else if (itemname == "Smartphone")
                {
                    Alt.Log("Phone benutzt.");
                    if (Characters.IsCharacterPhoneEquipped(charId))
                    {
                        Alt.Log("Phone benutzt2.");
                        player.EmitLocked("Client:Smartphone:equipPhone", false, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                        HUDHandler.SendNotification(player, 2, 1500, "Smartphone ausgeschaltet.");
                    }
                    else
                    {
                        Alt.Log("Phone benutzt3.");
                        player.EmitLocked("Client:Smartphone:equipPhone", true, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                        HUDHandler.SendNotification(player, 2, 1500, "Smartphone eingeschaltet.");
                    }
                    Characters.SetCharacterPhoneEquipped(charId, !Characters.IsCharacterPhoneEquipped(charId));
                    SmartphoneHandler.RequestLSPDIntranet((ClassicPlayer)player);
                }

                if (ServerItems.hasItemAnimation(ServerItems.ReturnNormalItemName(itemname)))
                {
                    InventoryAnimation(player, ServerItems.GetItemAnimationName(ServerItems.ReturnNormalItemName(itemname)), 0);
                }

                RequestInventoryItems(player);
                //HUDHandler.SendNotification(player, 2, 5000, $"DEBUG: Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich aus ({fromContainer}) benutzt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 28
0
        private static void PlayerExitVehicle(IVehicle vehicle, IPlayer player, byte seat)
        {
            try
            {
                if (player == null || vehicle == null || !player.Exists || !vehicle.Exists)
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                if (ServerVehicles.GetVehicleType(vehicle) != 2)
                {
                    return;
                }
                if (ServerVehicles.GetVehicleOwner(vehicle) != charId)
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijob() == "None")
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijobStep() == "None")
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijob() != "Pilot")
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijobStep() == "DRIVE_BACK_TO_START" && vehicle.Position.IsInRange(Constants.Positions.Minijob_Pilot_VehOutPos, 10f))
                {
                    var model = vehicle.Model;
                    foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"PL-{charId}").ToList())
                    {
                        if (veh == null || !veh.Exists)
                        {
                            continue;
                        }
                        ServerVehicles.RemoveVehiclePermanently(veh);
                        veh.Remove();
                    }
                    player.SetPlayerCurrentMinijob("None");
                    player.SetPlayerCurrentMinijobRouteId(0);
                    player.SetPlayerCurrentMinijobStep("None");
                    player.SetPlayerCurrentMinijobActionCount(0);
                    int rnd    = 0;
                    int rndExp = 0;
                    switch (model)
                    {
                    case 2621610858:     //Velum
                        rnd    = new Random().Next(250, 500);
                        rndExp = new Random().Next(1, 5);
                        break;

                    case 1341619767:     //Vestra
                        rnd    = new Random().Next(450, 650);
                        rndExp = new Random().Next(3, 8);
                        break;

                    case 2999939664:     //Nimbus
                        rnd    = new Random().Next(550, 850);
                        rndExp = new Random().Next(5, 11);
                        break;
                    }
                    if (!CharactersBank.HasCharacterBankMainKonto(charId))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Dein Gehalt i.H.v. {rnd}$ konnte nicht überwiesen werden da du kein Hauptkonto hast."); return;
                    }
                    int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                    if (accNumber <= 0)
                    {
                        return;
                    }
                    CharactersMinijobs.IncreaseCharacterMinijobEXP(charId, "Pilot", rndExp);
                    CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + rnd);
                    ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "San Andreas Flights", "Minijob Gehalt", $"+{rnd}$", "Online Banking");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Minijob erfolgreich abgeschlossen. Dein Gehalt i.H.v. {rnd}$ wurde dir auf dein Hauptkonto überwiesen. Du hast {rndExp}EXP dazu bekommen.");
                    player.EmitLocked("Client:Minijob:RemoveJobMarker");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 29
0
        private static async void PlayerExitVehicle(IVehicle vehicle, IPlayer player, byte seat)
        {
            try
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                if (vehicle == null || !vehicle.Exists)
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                if (ServerVehicles.GetVehicleType(vehicle) != 2)
                {
                    return;
                }
                if (ServerVehicles.GetVehicleOwner(vehicle) != charId)
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijob() != "Busfahrer")
                {
                    return;
                }
                if (player.GetPlayerCurrentMinijobStep() != "DRIVE_BACK_TO_START")
                {
                    return;
                }
                if (!vehicle.Position.IsInRange(Constants.Positions.Minijob_Busdriver_VehOutPos, 8f))
                {
                    return;
                }
                player.EmitLocked("Client:Minijob:RemoveJobMarker");
                foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"BUS-{charId}").ToList())
                {
                    if (veh == null || !veh.Exists)
                    {
                        continue;
                    }
                    ServerVehicles.RemoveVehiclePermanently(veh);
                    await Task.Delay(5000);

                    veh.Remove();
                }
                int givenEXP   = Model.GetRouteGivenEXP((int)player.GetPlayerCurrentMinijobRouteId());
                int givenMoney = Model.GetRouteGivenMoney((int)player.GetPlayerCurrentMinijobRouteId());
                player.SetPlayerCurrentMinijob("None");
                player.SetPlayerCurrentMinijobStep("None");
                player.SetPlayerCurrentMinijobActionCount(0);
                player.SetPlayerCurrentMinijobRouteId(0);
                CharactersMinijobs.IncreaseCharacterMinijobEXP(charId, "Busfahrer", givenEXP);
                if (!CharactersBank.HasCharacterBankMainKonto(charId))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Dein Gehalt i.H.v. {givenMoney}$ konnte nicht überwiesen werden da du kein Hauptkonto hast. Du hast aber {givenEXP}EXP erhalten (du hast nun: {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Busfahrer")}EXP)."); return;
                }
                int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                if (accNumber <= 0)
                {
                    return;
                }
                CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + givenMoney);
                ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Los Santos Transit", "Minijob Gehalt", $"+{givenMoney}$", "Online Banking");
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Minijob erfolgreich abgeschlossen. Dein Gehalt i.H.v. {givenMoney}$ wurde dir auf dein Hauptkonto überwiesen. Du hast {givenEXP} erhalten (deine EXP: {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Busfahrer")})");
                return;
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Esempio n. 30
0
        public static async void OnEntityTimer(object sender, ElapsedEventArgs e)
        {
            try
            {
                Console.WriteLine($"Timer - Thread = {Thread.CurrentThread.ManagedThreadId}");
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                foreach (IVehicle Veh in Alt.Server.GetVehicles().ToList())
                {
                    if (Veh == null || !Veh.Exists)
                    {
                        continue;
                    }
                    using (var vRef = new VehicleRef(Veh))
                    {
                        if (!vRef.Exists)
                        {
                            continue;
                        }
                        lock (Veh)
                        {
                            if (Veh == null || !Veh.Exists)
                            {
                                continue;
                            }
                            ulong vehID = Veh.GetVehicleId();
                            if (vehID <= 0)
                            {
                                continue;
                            }
                            ServerVehicles.SaveVehiclePositionAndStates(Veh);
                            if (Veh.EngineOn == true)
                            {
                                ServerVehicles.SetVehicleFuel(Veh, ServerVehicles.GetVehicleFuel(Veh) - 0.03f);
                            }
                        }
                    }
                }

                stopwatch.Stop();
                Alt.Log($"OnEntityTimer: Vehicle Foreach benötigte: {stopwatch.Elapsed}");

                stopwatch.Reset();
                stopwatch.Start();
                foreach (IPlayer player in Alt.Server.GetPlayers().ToList())
                {
                    if (player == null)
                    {
                        continue;
                    }
                    using (var playerReference = new PlayerRef(player))
                    {
                        if (!playerReference.Exists)
                        {
                            return;
                        }
                        if (player == null || !player.Exists)
                        {
                            continue;
                        }
                        lock (player)
                        {
                            if (player == null || !player.Exists)
                            {
                                continue;
                            }
                            int charId = User.GetPlayerOnline(player);
                            if (charId > 0)
                            {
                                Characters.SetCharacterLastPosition(charId, player.Position, player.Dimension);
                                if (User.IsPlayerBanned(player))
                                {
                                    player.kickWithMessage($"Du bist gebannt. (Grund: {User.GetPlayerBanReason(player)}).");
                                }
                                Characters.SetCharacterHealth(charId, player.Health);
                                Characters.SetCharacterArmor(charId, player.Armor);
                                WeatherHandler.SetRealTime(player);
                                if (player.IsInVehicle)
                                {
                                    player.EmitLocked("Client:HUD:GetDistanceForVehicleKM"); HUDHandler.SendInformationToVehicleHUD(player);
                                }
                                Characters.IncreaseCharacterPaydayTime(charId);

                                if (Characters.IsCharacterUnconscious(charId))
                                {
                                    int unconsciousTime = Characters.GetCharacterUnconsciousTime(charId);
                                    if (unconsciousTime > 0)
                                    {
                                        Characters.SetCharacterUnconscious(charId, true, unconsciousTime - 1);
                                    }
                                    else if (unconsciousTime <= 0)
                                    {
                                        Characters.SetCharacterUnconscious(charId, false, 0);
                                        DeathHandler.closeDeathscreen(player);
                                        player.Spawn(new Position(355.54285f, -596.33405f, 28.75768f));
                                        player.Health = player.MaxHealth;
                                    }
                                }

                                if (Characters.IsCharacterFastFarm(charId))
                                {
                                    int fastFarmTime = Characters.GetCharacterFastFarmTime(charId);
                                    if (fastFarmTime > 0)
                                    {
                                        Characters.SetCharacterFastFarm(charId, true, fastFarmTime - 1);
                                    }
                                    else if (fastFarmTime <= 0)
                                    {
                                        Characters.SetCharacterFastFarm(charId, false, 0);
                                    }
                                }

                                if (Characters.IsCharacterInJail(charId))
                                {
                                    int jailTime = Characters.GetCharacterJailTime(charId);
                                    if (jailTime > 0)
                                    {
                                        Characters.SetCharacterJailTime(charId, true, jailTime - 1);
                                    }
                                    else if (jailTime <= 0)
                                    {
                                        if (CharactersWanteds.HasCharacterWanteds(charId))
                                        {
                                            int jailTimes = CharactersWanteds.GetCharacterWantedFinalJailTime(charId);
                                            int jailPrice = CharactersWanteds.GetCharacterWantedFinalJailPrice(charId);
                                            if (CharactersBank.HasCharacterBankMainKonto(charId))
                                            {
                                                int accNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                                                int bankMoney = CharactersBank.GetBankAccountMoney(accNumber);
                                                CharactersBank.SetBankAccountMoney(accNumber, bankMoney - jailPrice);
                                                HUDHandler.SendNotification(player, 1, 7500, $"Durch deine Inhaftierung wurden dir {jailPrice}$ vom Konto abgezogen.");
                                            }
                                            HUDHandler.SendNotification(player, 1, 7500, $"Du sitzt nun für {jailTimes} Minuten im Gefängnis.");
                                            Characters.SetCharacterJailTime(charId, true, jailTimes);
                                            CharactersWanteds.RemoveCharacterWanteds(charId);
                                            player.Position = new Position(1691.4594f, 2565.7056f, 45.556763f);
                                            if (Characters.GetCharacterGender(charId) == false)
                                            {
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 11, 5, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 3, 5, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 4, 7, 15);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 6, 7, 0);
                                                player.EmitLocked("Client:SpawnArea:setCharClothes", 8, 1, 88);
                                            }
                                            else
                                            {
                                            }
                                        }
                                        else
                                        {
                                            Characters.SetCharacterJailTime(charId, false, 0);
                                            Characters.SetCharacterCorrectClothes(player);
                                            player.Position = new Position(1846.022f, 2585.8945f, 45.657f);
                                            HUDHandler.SendNotification(player, 1, 2500, "Du wurdest aus dem Gefängnis entlassen.");
                                        }
                                    }
                                }

                                if (Characters.GetCharacterPaydayTime(charId) >= 60)
                                {
                                    Characters.IncreaseCharacterPlayTimeHours(charId);
                                    Characters.ResetCharacterPaydayTime(charId);
                                    if (CharactersBank.HasCharacterBankMainKonto(charId))
                                    {
                                        int accountNumber = CharactersBank.GetCharacterBankMainKonto(charId);
                                        CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + 250); //250$ Stütze
                                        ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Staat", "Arbeitslosengeld", "+250$", "Unbekannt");

                                        if (!Characters.IsCharacterCrimeFlagged(charId) && Characters.GetCharacterJob(charId) != "None" && DateTime.Now.Subtract(Convert.ToDateTime(Characters.GetCharacterLastJobPaycheck(charId))).TotalHours >= 12 && !ServerFactions.IsCharacterInAnyFaction(charId))
                                        {
                                            if (Characters.GetCharacterJobHourCounter(charId) >= ServerJobs.GetJobNeededHours(Characters.GetCharacterJob(charId)) - 1)
                                            {
                                                int jobCheck = ServerJobs.GetJobPaycheck(Characters.GetCharacterJob(charId));
                                                Characters.SetCharacterLastJobPaycheck(charId, DateTime.Now);
                                                Characters.ResetCharacterJobHourCounter(charId);
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + jobCheck);
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Arbeitsamt", $"Gehalt: {Characters.GetCharacterJob(charId)}", $"+{jobCheck}$", "Unbekannt");
                                                HUDHandler.SendNotification(player, 1, 5000, $"Gehalt erhalten (Beruf: {Characters.GetCharacterJob(charId)} | Gehalt: {jobCheck}$)");
                                            }
                                            else
                                            {
                                                Characters.IncreaseCharacterJobHourCounter(charId);
                                            }
                                        }

                                        if (ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId))
                                        {
                                            int factionid       = ServerFactions.GetCharacterFactionId(charId);
                                            int factionPayCheck = ServerFactions.GetFactionRankPaycheck(factionid, ServerFactions.GetCharacterFactionRank(charId));
                                            if (ServerFactions.GetFactionBankMoney(factionid) >= factionPayCheck)
                                            {
                                                ServerFactions.SetFactionBankMoney(factionid, ServerFactions.GetFactionBankMoney(factionid) - factionPayCheck);
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + factionPayCheck);
                                                HUDHandler.SendNotification(player, 1, 5000, $"Du hast deinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))})");
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", $"{ServerFactions.GetFactionFullName(factionid)}", $"Gehalt: {ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}", $"+{factionPayCheck}$", "Dauerauftrag");
                                                LoggingService.NewFactionLog(factionid, charId, 0, "paycheck", $"{Characters.GetCharacterName(charId)} hat seinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}).");
                                            }
                                            else
                                            {
                                                HUDHandler.SendNotification(player, 3, 5000, $"Deine Fraktion hat nicht genügend Geld um dich zu bezahlen ({factionPayCheck}$).");
                                            }
                                        }

                                        var playerVehicles = ServerVehicles.ServerVehicles_.Where(x => x.id > 0 && x.charid == charId && x.plate.Contains("NL"));
                                        int taxMoney       = 0;
                                        foreach (var i in playerVehicles)
                                        {
                                            if (!i.plate.Contains("NL"))
                                            {
                                                continue;
                                            }
                                            taxMoney += ServerAllVehicles.GetVehicleTaxes(i.hash);
                                        }

                                        if (playerVehicles != null && taxMoney > 0)
                                        {
                                            if (CharactersBank.GetBankAccountMoney(accountNumber) < taxMoney)
                                            {
                                                HUDHandler.SendNotification(player, 3, 5000, $"Deine Fahrzeugsteuern konnten nicht abgebucht werden ({taxMoney}$)");
                                            }
                                            else
                                            {
                                                CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) - taxMoney);
                                                ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Zulassungsamt", $"Fahrzeugsteuer", $"-{taxMoney}$", "Bankeinzug");
                                                HUDHandler.SendNotification(player, 1, 5000, $"Du hast deine Fahrzeugsteuern i.H.v. {taxMoney}$ bezahlt.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        HUDHandler.SendNotification(player, 3, 5000, $"Dein Einkommen konnte nicht überwiesen werden da du kein Hauptkonto hast.");
                                    }
                                }
                            }
                        }
                    }
                }
                stopwatch.Stop();
                Alt.Log($"OnEntityTimer: Player Foreach benötigte: {stopwatch.Elapsed}");
            }
            catch (Exception ex)
            {
                Alt.Log($"{ex}");
            }
        }