public void OnScriptsStarted(IScript[] scripts) { //var chat = new Chat(); //AltChat.Init(chat); foreach (var script in scripts) { RegisterEvents(script /*, chat*/); } Alt.OnClient <IPlayer, string>("chat:message", OnChatMessage, OnChatMessageParser); //Alt.OnServer<IPlayer, string>("chat:message", OnChatMessage, OnChatMessageParserServer); }
public static bool ExistAccountTattoo(int charId, int id) { try { return(CharactersTattoos_.ToList().Exists(x => x.charId == charId && x.tattooId == id)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static bool ExistClothes(string clothesName) { try { return(ServerClothes_.ToList().Exists(x => x.clothesName == clothesName)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static string GetGarageParkOutString(IPlayer player, int garageId, int charId, bool isFaction, string factionShort) { try { if (player == null || !player.Exists || garageId == 0 || charId == 0) { return("undefined"); } List <Server_Vehicles> inGarageVehs = null; if (isFaction == false) { inGarageVehs = ServerVehicles.ServerVehicles_.Where(x => x.isInGarage == true && x.garageId == garageId).ToList(); } else if (isFaction == true) { inGarageVehs = ServerVehicles.ServerVehicles_.Where(x => x.isInGarage == true && x.garageId == garageId && x.plate.Contains(factionShort)).ToList(); } dynamic array = new JArray() as dynamic; dynamic entry = new JObject(); foreach (var vehicle in inGarageVehs) { bool hasKey = false; if (isFaction == false) { hasKey = CharactersInventory.ExistCharacterItem(charId, "Fahrzeugschluessel " + vehicle.plate, "inventory"); } else if (isFaction == true) { hasKey = CharactersInventory.ExistCharacterItem(charId, "Fahrzeugschluessel " + factionShort, "inventory"); } bool isOwner = vehicle.charid == charId; if (!hasKey && !isOwner) { continue; } entry = new JObject(); entry.vehid = vehicle.id; entry.plate = vehicle.plate; entry.hash = vehicle.hash; entry.name = ServerAllVehicles.GetVehicleNameOnHash(vehicle.hash); array.Add(entry); } return(array.ToString()); } catch (Exception e) { Alt.Log($"{e}"); } return("[]"); }
public Jsonreader() { String jsonIn = File.ReadAllText(@"C:\Users\elach\Documents\GitHub\AltV\objectslocations\worldAirMasts.json"); PostionJson[] postions = JsonSerializer.Deserialize <PostionJson[]>(jsonIn); for (int i = 0; i < postions.Length; i++) { vec3 pos = postions[i].Position; Alt.CreateBlip(BlipType.Pickup, new Position(pos.X, pos.Y, pos.Z)); } }
public static bool ExistCharacterClothes(int charId, string clothesName) { try { return(CharactersOwnedClothes_.ToList().Exists(x => x.charId == charId && x.clothesName == clothesName)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static bool ExistChatByNumbers(int phoneNumber, int anotherNumber) { try { return(CharactersPhoneChats_.ToList().Exists(x => (x.phoneNumber == phoneNumber && x.anotherNumber == anotherNumber) || (x.phoneNumber == anotherNumber && x.anotherNumber == phoneNumber))); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static bool ExistChatById(int chatId) { try { return(CharactersPhoneChats_.ToList().Exists(x => x.chatId == chatId)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static int GetMaxInteriorsCount() { try { return(ServerHousesInteriors_.Count()); } catch (Exception e) { Alt.Log($"{e}"); } return(0); }
public static bool ExistContactByNumber(int phoneNumber, int contactNumber) { try { return(CharactersPhoneContacts_.ToList().Exists(x => x.phoneNumber == phoneNumber && x.contactNumber == contactNumber)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static void Initialize() { Alt.Log("Lade Minijob: Elektrolieferant..."); Alt.OnColShape += ColshapeEnterExitHandler; Alt.OnPlayerEnterVehicle += PlayerEnterVehicle; Alt.OnPlayerLeaveVehicle += PlayerExitVehicle; Alt.OnPlayerDisconnect += PlayerDisconnectedHandler; var data = new Server_Peds { model = "s_m_y_dockwork_01", posX = startJobShape.Position.X, posY = startJobShape.Position.Y, posZ = startJobShape.Position.Z - 1, rotation = -24.444355010986328f }; ServerPeds.ServerPeds_.Add(data); var MarkerData = new Server_Markers { type = 39, posX = Constants.Positions.Minijob_Elektrolieferant_VehOutPos.X, posY = Constants.Positions.Minijob_Elektrolieferant_VehOutPos.Y, posZ = (Constants.Positions.Minijob_Elektrolieferant_VehOutPos.Z + 0.25f), scaleX = 1, scaleY = 1, scaleZ = 1, red = 46, green = 133, blue = 232, alpha = 150, bobUpAndDown = true }; ServerBlips.ServerMarkers_.Add(MarkerData); MinijobSpots_.Add(new Minijob_Spots() { id = 1, pos = new Position((float)974.2866821289062, (float)7.489353656768799, (float)80.36315155029297), depositPos = new Position((float)974.350341796875, (float)12.931292533874512, (float)81.04092407226562), depositColshape = Alt.CreateColShapeSphere(new Position((float)974.350341796875, (float)12.931292533874512, (float)81.04092407226562), 2f) }); //Casino MinijobSpots_.Add(new Minijob_Spots() { id = 2, pos = new Position((float)-1052.0967, (float)-249.11209, (float)37.064453), depositPos = new Position((float)-1041.5845947265625, (float)-241.25299072265625, (float)37.95166015625), depositColshape = Alt.CreateColShapeSphere(new Position((float)-1041.5845947265625, (float)-241.25299072265625, (float)37.95166015625), 2f) }); //Lifeinvader MinijobSpots_.Add(new Minijob_Spots() { id = 3, pos = new Position((float)-532.53625, (float)-889.25275, (float)24.106934), depositPos = new Position((float)-537.14306640625, (float)-886.7233276367188, (float)25.197668075561523), depositColshape = Alt.CreateColShapeSphere(new Position((float)-537.14306640625, (float)-886.7233276367188, (float)25.197668075561523), 2f) }); //Weazel News MinijobSpots_.Add(new Minijob_Spots() { id = 4, pos = new Position((float)-1398.3956, (float)-463.14725, (float)33.694458), depositPos = new Position((float)-1371.060546875, (float)-460.3683776855469, (float)34.4775390625), depositColshape = Alt.CreateColShapeSphere(new Position((float)-1371.060546875, (float)-460.3683776855469, (float)34.4775390625), 2f) }); //Maze Bank MinijobSpots_.Add(new Minijob_Spots() { id = 5, pos = new Position((float)-1152.0396, (float)-204.94945, (float)37.182373), depositPos = new Position((float)-1139.5904541015625, (float)-199.96868896484375, (float)37.96001052856445), depositColshape = Alt.CreateColShapeSphere(new Position((float)-1139.5904541015625, (float)-199.96868896484375, (float)37.96001052856445), 2f) }); //Crastenburg Hotel MinijobSpots_.Add(new Minijob_Spots() { id = 6, pos = new Position((float)-199.8989, (float)-1381.1736, (float)30.476196), depositPos = new Position((float)-229.72915649414062, (float)-1377.137939453125, (float)31.25824737548828), depositColshape = Alt.CreateColShapeSphere(new Position((float)-229.72915649414062, (float)-1377.137939453125, (float)31.25824737548828), 2f) }); //Glass Heroes Alt.Log("Minijob: Elektrolieferant geladen..."); startJobShape.Radius = 2f; foreach (var item in MinijobSpots_) { ((ClassicColshape)item.depositColshape).Radius = 2f; } }
public static bool HasCharacterWanteds(int charId) { try { return(CharactersWanteds_.Exists(x => x.charId == charId)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public static bool ExistWantedEntry(int id) { try { return(CharactersWanteds_.Exists(x => x.id == id)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public async Task RevivePlayer(IPlayer player, IPlayer targetPlayer) { try { if (player == null || !player.Exists || targetPlayer == null || !targetPlayer.Exists) { return; } int targetId = (int)targetPlayer.GetCharacterMetaId(); int charId = (int)player.GetCharacterMetaId(); if (charId <= 0 || targetId <= 0 || !Characters.IsCharacterUnconscious(targetId)) { return; } if (!CharactersInventory.ExistCharacterItem(charId, "Defibrilator", "inventory") && !CharactersInventory.ExistCharacterItem(charId, "Defibrilator", "backpack")) { HUDHandler.SendNotification(player, 3, 3500, "Du hast keinen Defibrilator dabei."); return; } InventoryHandler.InventoryAnimation(player, "revive", 15000); int rnd = new Random().Next(1, 100); await Task.Delay(15000); if (rnd >= 1 && rnd <= 50) { //Reanimation erfolgreich if (!player.IsInVehicle) { InventoryHandler.StopAnimation(player, "missheistfbi3b_ig8_2", "cpr_loop_paramedic"); } if (targetId <= 0 || !Characters.IsCharacterUnconscious(targetId)) { return; } Characters.SetCharacterUnconscious(targetId, false, 0); DeathHandler.revive(targetPlayer); Characters.SetCharacterHealth(targetId, 115); targetPlayer.Health = 115; } else if (rnd >= 51 && rnd <= 100) { //Reanimation nicht erfolgreich if (!player.IsInVehicle) { InventoryHandler.StopAnimation(player, "missheistfbi3b_ig8_2", "cpr_loop_paramedic"); } HUDHandler.SendNotification(player, 3, 3500, "Die Renimation war nicht erfolgreich, versuch es weiter!"); } } catch (Exception e) { Alt.Log($"{e}"); } }
private void _voiceServer_VoiceClientMicrophoneStatusChanged(long connectionId, bool isMuted) { using (var threadSafeList = new AltVPlayerList()) { var p = GetPlayerByConnectionId(threadSafeList.AllPlayers, connectionId); if (p != null) { OnVoiceLogging?.Invoke(LogLevel.Debug, $"{p.Name} Mic muted {isMuted}"); Alt.Emit("PUREVOICE_CLIENT_MICROPHONESTATUS", p, isMuted); } } }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash + 23 * Ctrl.GetHashCode(); hash = hash + 23 * Alt.GetHashCode(); hash = hash + 23 * Shift.GetHashCode(); hash = hash + 23 * Key.GetHashCode(); return(hash); } }
public void groundZ(Player player, float height, int id) { if (height == 0) { Data.CurrentLobby.Items.Remove(id); Alt.Log("nullig"); } else { Data.CurrentLobby.Items[id].Z = (height + 0.1f); } }
public async Task OnEnterPlayerVehicle(IVehicle vehicle, IPlayer player, byte seat) => await AltAsync.Do(() => { if (!vehicle.GetVehicleEntity().TrunkOpen) { return; } //if ((int)seat != 1) return; Alt.Log("Dotarł event z OnEnterPlayerVehicle TRUNK"); DisposeVehicleTrunk(vehicle, player); });
public override int GetHashCode() { unchecked { var hashCode = Key.GetHashCode(); hashCode = (hashCode * 397) ^ KeyLetter.GetHashCode(); hashCode = (hashCode * 397) ^ Shift.GetHashCode(); hashCode = (hashCode * 397) ^ Alt.GetHashCode(); hashCode = (hashCode * 397) ^ Control.GetHashCode(); return(hashCode); } }
public async Task TakeHotelItem(IPlayer player, int apartmentId, string itemName, int itemAmount) { try { if (player == null || !player.Exists || apartmentId <= 0 | itemAmount <= 0 || itemName == "" || itemName == "undefined") { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs()) { HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return; } if (!ServerHotels.ExistServerHotelStorageItem(apartmentId, itemName)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert im Lager nicht."); return; } if (ServerHotels.GetServerHotelStorageItemAmount(apartmentId, itemName) < itemAmount) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Lager."); return; } float itemWeight = ServerItems.GetItemWeight(itemName) * itemAmount; float invWeight = CharactersInventory.GetCharacterItemWeight(charId, "inventory"); float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack"); if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId))) { HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return; } ServerHotels.RemoveServerHotelStorageItemAmount(apartmentId, itemName, itemAmount); //LoggingService.NewFactionLog(factionId, charId, 0, "storage", $"{Characters.GetCharacterName(charId)} ({charId}) hat den Gegenstand '{itemName} ({amount}x)' aus seinem Spind entnommen."); // ToDo: Hotel Log if (invWeight + itemWeight <= 15f) { HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus deinem Lager genommen (Lagerort: Inventar)."); CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory"); return; } if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId))) { HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus deinem Lager genommen (Lagerort: Rucksack / Tasche)."); CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack"); return; } } catch (Exception e) { Alt.Log($"{e}"); } }
public override int GetHashCode() { unchecked { var hashCode = Control.GetHashCode(); hashCode = (hashCode * 397) ^ Alt.GetHashCode(); hashCode = (hashCode * 397) ^ Shift.GetHashCode(); hashCode = (hashCode * 397) ^ (int)Type; hashCode = (hashCode * 397) ^ (int)Code; return(hashCode); } }
public static bool ExistTattooShop(int id) { try { return(ServerTattooShops_.ToList().Exists(x => x.id == id)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public override void OnStart() { Alt.On <IPlayer, string>("chatmessage", OnChatMessage, OnChatMessageParser); Alt.Export <string, Function.Func>("registerCmd", (commandName, handler) => { CommandHandlers.Add(commandName, (player, command, args) => { handler.Invoke(new object[] { player, command, args }); }); }); Alt.Export("broadcast", delegate(string message) { Alt.EmitAllClients("chatmessage", null, message); }); Alt.Export("send", delegate(IPlayer player, string message) { player.SendChatMessage(message); }); }
private StreetCrossingControl() { //Load the pre-calculated StreetCrossings List <StreetCrossing> streetCrossings = FileControl.LoadDataFromJsonFile <List <StreetCrossing> >("resources/pedSyncer/server/StreetCrossings.json"); Alt.Log("StreetCrossings Count: " + streetCrossings.Count); foreach (StreetCrossing streetCrossing in streetCrossings) { MappedStreetCrossings.Add(streetCrossing.Position.ToString(), streetCrossing); } }
public static bool ExistClothesShop(int shopId) { try { return(ServerClothesShops_.ToList().Exists(x => x.id == shopId)); } catch (Exception e) { Alt.Log($"{e}"); } return(false); }
public async Task RentHotel(IPlayer player, int hotelId, int apartmentId) { try { if (player == null || !player.Exists || hotelId <= 0 || apartmentId <= 0) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId)) { HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return; } if (ServerHotels.HasCharacterAnApartment(charId)) { HUDHandler.SendNotification(player, 3, 5000, $"Du besitzt bereits ein Hotelzimmer in dem Hotel '{ServerHotels.GetCharacterRentedHotelName(charId)}'."); return; } if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) > 0) { HUDHandler.SendNotification(player, 3, 5000, "Dieses Apartment ist bereits vermietet."); return; } if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, "Du hast noch kein Hauptkonto in der Bank festgelegt."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accNumber)) { HUDHandler.SendNotification(player, 3, 5000, "Dein Bankkonto ist gesperrt."); return; } if (CharactersBank.GetBankAccountMoney(accNumber) < ServerHotels.GetApartmentPrice(hotelId, apartmentId)) { HUDHandler.SendNotification(player, 3, 5000, $"Soviel Geld hast du auf deinem Konto nicht ({ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$) - du hast {CharactersBank.GetBankAccountMoney(accNumber)}$"); return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - ServerHotels.GetApartmentPrice(hotelId, apartmentId)); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Hotelzahlung", $"Zimmerbuchung: {apartmentId}", $"+{ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$", "Bankeinzug"); ServerHotels.SetApartmentOwner(hotelId, apartmentId, charId); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben sich das Zimmer mit der Zimmernummer '{apartmentId}' erfolgreich gemietet (Kosten: {ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$). Dieses Zimmer läuft automatisch nach {ServerHotels.GetApartmentRentHours(hotelId, apartmentId)} Stunden ab."); } catch (Exception e) { Alt.Log($"{e}"); } }
public void DrawNametags() { if (!drawNametags) { return; } foreach (var player in Alt.GetAllPlayers()) { if (!player.Exists) { continue; } if (!player.Spawned) { continue; } if (!Alt.Natives.HasEntityClearLosToEntity(player, Alt.LocalPlayer, 17)) { continue; } var distance = Distance2D(player.Position, Alt.LocalPlayer.Position); if (distance > 100) { continue; } var pos = Alt.Natives.GetPedBoneCoords(player, 12844, 0, 0, 0); pos.Z += 0.75f; var scale = 1 - (0.8 * distance) / 100; var fontSize = 0.6 * scale; var lineHeight = Alt.Natives.GetRenderedCharacterHeight((float)fontSize, 4); var entity = player.IsInVehicle ? player.Vehicle?.ScriptId : player.ScriptId; if (entity == null) { continue; } var vector = Alt.Natives.GetEntityVelocity((int)entity); var frameTime = Alt.Natives.GetFrameTime(); Alt.Natives.SetDrawOrigin(pos.X + vector.X * frameTime, pos.Y + vector.Y * frameTime, pos.Z, 0); Alt.Natives.BeginTextCommandDisplayText("STRING"); Alt.Natives.SetTextFont(4); Alt.Natives.SetTextScale((float)fontSize, (float)fontSize); Alt.Natives.SetTextProportional(true); Alt.Natives.SetTextCentre(true); Alt.Natives.SetTextColour(255, 255, 255, 255); Alt.Natives.SetTextOutline(); Alt.Natives.AddTextComponentSubstringPlayerName(player.Name); Alt.Natives.EndTextCommandDisplayText(0, 0, 0); } }
public async Task Spawn() => await AltAsync.Do(async() => { ColShape = Alt.CreateColShapeCylinder(new Position(DbModel.PosX, DbModel.PosY, DbModel.PosZ - 0.9f), 1f, 2f); MarkerModel = new MarkerModel() { Type = 27, Dimension = 0, PosX = DbModel.PosX, PosY = DbModel.PosY, PosZ = DbModel.PosZ - 0.9f, DirX = 0, DirY = 0, DirZ = 0, RotX = 0, RotY = 0, RotZ = 0, ScaleX = 1f, ScaleY = 1f, ScaleZ = 1f, Red = 0, Green = 153, Blue = 0, Alpha = 100, BobUpAndDown = false, FaceCamera = false, P19 = 2, Rotate = false, TextureDict = null, TextureName = null, DrawOnEnts = false, UniqueID = $"SHOP{DbModel.Id}" }; BlipModel = new BlipModel() { PosX = DbModel.PosX, PosY = DbModel.PosY, PosZ = DbModel.PosZ + 1, Blip = 52, Color = 38, Size = EBlipSize.Medium, Name = ShopEntityFactory.CreateShopName(DbModel.ShopEntityType), ShortRange = true, UniqueID = $"SHOP{DbModel.Id}" }; await MarkerHelper.CreateGlobalMarker(MarkerModel); await BlipHelper.CreateGlobalBlip(BlipModel); EntityHelper.Add(this); ColShape.SetData("shop:data", this); });
public override int GetHashCode() { unchecked { var hashCode = Alt != null?Alt.GetHashCode() : 0; hashCode = (hashCode * 397) ^ Id; hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Position; hashCode = (hashCode * 397) ^ (Source != null ? Source.GetHashCode() : 0); return(hashCode); } }
private bool CloseConnection() { try { connection.Close(); return(true); } catch (MySqlException ex) { Alt.Log("DATABASE-ERROR" + ex.Message); return(false); } }