public void PickUpItem(Client user, bool forcePickup = false) { Player player = Player.PlayerData[user]; foreach (Weapon w in Weapon.DroppedWeapons) { if (w.CurrentOwnerId != -1) { continue; } if (!(w.DroppedPos.DistanceTo(user.position) < 1.5f)) { continue; } API.deleteEntity(w.DroppedObj); if (player.Weapons.Any(we => we.Model == w.Model)) { if (!forcePickup) { API.ShowPopupPrompt(user, "playerPickupWeaponExists", "Existing weapon in inventory", "By picking up this weapon, the ammunition in the weapon will be added to your current weapon but this weapon will be destroyed."); return; } else { int index = player.Weapons.IndexOf(player.Weapons.First(we => we.Model == w.Model)); player.Weapons[index].Ammo += w.Ammo; WeaponRepository.UpdateAsync(player.Weapons[index]); WeaponRepository.RemoveAsync(w); } } else { w.CurrentOwnerId = player.Id; player.Weapons.Add(w); WeaponRepository.UpdateAsync(w); } WeaponLogRepository.AddNew(new WeaponLog(-1, w.Id, w.Type, player.Id)); API.givePlayerWeapon(user, w.Model, w.Ammo, true, true); API.setPlayerWeaponAmmo(user, w.Model, w.Ammo); Weapon.DroppedWeapons.Remove(w); return; } }
public async void PlayerInit(Player player) { API.setPlayerNametag(player.Client, player.Username.Roleplay()); API.setPlayerName(player.Client, player.Username.Roleplay()); API.setPlayerHealth(player.Client, (int)player.Health); API.setPlayerArmor(player.Client, (int)player.Armour); API.setEntityDimension(player.Client, player.Dimension); player.IsInInterior = (player.Dimension > 0); if (player.IsInInterior) { player.PropertyIn = PropertyManager.Properties.FirstOrDefault(p => p.Dimension == player.Dimension); } Skin playerSkin = await SkinRepository.GetSkinById(player.Skin); API.setPlayerSkin(player.Client, (PedHash)playerSkin.Model); List <SkinVariations> skinVars = playerSkin.Variations(); player.ChatIndicatorLabel = API.createTextLabel("typing...", player.Client.position, 50, 0.35f, false, player.Dimension); player.ChatIndicatorLabel.color = new Color(0, 0, 0, 0); player.ChatIndicatorLabel.attachTo(player.Client, null, new Vector3(0, 0, 0.9f), new Vector3()); for (int i = 0; i < 12; i++) { API.setPlayerClothes(player.Client, i, skinVars[i].Drawable, skinVars[i].Texture); } player.IsLogged = true; player.MasterAccount.ActiveConnectionLog.PlayerId = player.Id; ConnectionLogRepository.UpdateAsync(player.MasterAccount.ActiveConnectionLog); if (player.FactionId > 0) { player.Faction = Faction.FactionData.Single(f => f.Id == player.FactionId); } player.Weapons = await WeaponRepository.GetAllWeaponsByPlayerIdAsync(player.Id); foreach (Weapon w in player.Weapons) { API.givePlayerWeapon(player.Client, w.Model, w.Ammo, false, false); } player.Inventory = await InventoryRepository.GetInventoryByOwnerIdAsync(player.Id); player.PopulateWeaponSkills(); await player.LoadPlayerVehicles(); foreach (Inventory i in player.Inventory) { if (i.IsPhone()) { Phone p = PhoneRepository.GetPhoneByIMEI(long.Parse(i.Value)); if (p.IsPrimary) { player.PrimaryPhone = p; if (p.PoweredOn) { if (p.BatteryLevel > 3) { p.TurnOn(player.Client); } else { p.TurnOff(player.Client); } } else { p.TurnOff(player.Client); } break; } } } player.InEvent = PlayerEvent.None; player.Client.freeze(false); player.Client.ToggleCursorLock(false); player.Client.transparency = 255; API.sendNativeToAllPlayers(Hash.SET_CURRENT_PED_WEAPON, player.Client, (int)WeaponHash.Unarmed, true); Player.PlayerData.Add(player.Client, player); if (player.LastPosition != new Vector3(0, 0, 0)) { player.Client.position = player.LastPosition; } API.triggerClientEvent(player.Client, "hasLoggedIn", ((char)player.MasterAccount.KeyCursor).ToString(), ((char)player.MasterAccount.KeyInventory).ToString(), ((char)player.MasterAccount.KeyInteract).ToString()); API.triggerClientEvent(player.Client, "executeSkillTimer"); API.triggerClientEvent(player.Client, "loadScoreboard"); API.triggerClientEvent(player.Client, "initInteractionMenu"); API.sendNativeToPlayer(player.Client, Hash.SET_CAM_AFFECTS_AIMING, player.Client, true); //API.sendNativeToPlayer(player.Client, Hash.SET_PED_CAN_BE_SHOT_IN_VEHICLE, player.Client, true); player.Client.invincible = true; for (int i = 0; i < 12; i++) { API.exported.doormanager.refreshDoorState(i); } UpdateNatives(player); PrisonManager.LoadPrisonSentenceForPlayer(player); OnPlayerLoggedIn(player); }
private async void OnResourceStart() { API.setGamemodeName("pbrp"); Server serverData = ServerRepository.LoadServerData(); Server.Date = serverData.DateTime; Globals.MAX_PLAYERS = API.getMaxPlayers(); LoadWeatherData(); Player.IDs = new Client[Globals.MAX_PLAYERS]; Player.IDs.Initialize(); Vehicle.IDs = new GrandTheftMultiplayer.Server.Elements.Vehicle[2000]; Vehicle.IDs.Initialize(); // -- Dropped Weapons Weapon.DroppedWeapons = WeaponRepository.GetAllDroppedWeapons(); foreach (Weapon w in Weapon.DroppedWeapons) { string weaponName = NameToHash.Weapons.Keys.Where(k => NameToHash.Weapons[k] == (WeaponHash)w.Model).First(); w.DroppedObj = API.createObject(NameToHash.WeaponObjects[weaponName], w.DroppedPos, w.DroppedRot, w.DroppedDimension); } // --- Dropped Items Inventory.DroppedItems = await InventoryRepository.GetAllDroppedInventoryItems(); foreach (Inventory i in Inventory.DroppedItems) { i.DroppedObj = API.createObject(Inventory.GetObjectForItem[i.Type], i.DroppedPos, i.DroppedRot, i.DroppedDimension); } SkinImagePed = API.createPed(PedHash.Barry, new Vector3(-697.0174, 5803.262, 17.33096), 90, 0); System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-US"); API.removeIpl("bnkheist_apt_dest"); API.removeIpl("bnkheist_apt_dest_vfx"); API.removeIpl("bnkheist_apt_dest_lod"); API.requestIpl("bnkheist_apt_norm"); API.requestIpl("bnkheist_apt_norm_lod"); API.removeIpl("CS1_02_cf_offmission"); API.requestIpl("CS1_02_cf_onmission1"); API.requestIpl("CS1_02_cf_onmission2"); API.requestIpl("CS1_02_cf_onmission3"); API.requestIpl("CS1_02_cf_onmission4"); API.removeIpl("fakeint"); API.requestIpl("shr_int"); API.createObject(1539730305, new Vector3(-810.866821, -210.795883, 340.32489), new Vector3(0, 0, 14.6697245)); API.createObject(1539730305, new Vector3(-809.520752, -210.520264, 341.861816), new Vector3(89.0096512, -2.6680425e-08, -163.269455)); API.createObject(1539730305, new Vector3(-810.520752, -208.520264, 341.861816), new Vector3(89.0096512, 4.00206375e-08, -78.2687149)); API.createObject(1539730305, new Vector3(-810.520752, -212.520264, 341.861816), new Vector3(89.0096512, -2.134434e-07, 101.731239)); //API.requestIpl("shr_int_lod"); var doorManager = API.exported.doormanager; // -- Base Doors doorManager.setDoorState(doorManager.registerDoor(-1666470363, new Vector3(-109.65, 6462.11, 31.98499)), false, 0); // PB Bank Right Door 1(1) doorManager.setDoorState(doorManager.registerDoor(-353187150, new Vector3(-111.48, 6463.94, 31.98499)), false, 0); // PB Bank Left Door 2 (2) doorManager.setDoorState(doorManager.registerDoor(-1501157055, new Vector3(-442.66, 6015.222, 31.86633)), true, 0); // PB PD Left Door (3) doorManager.setDoorState(doorManager.registerDoor(-1501157055, new Vector3(-444.66, 6017.060, 31.86633)), true, 0); // PB PD Right Door (3) doorManager.setDoorState(doorManager.registerDoor(1417577297, new Vector3(-37.33113, -1108.873, 26.7198)), true, 0); // Simeon Garage Door 1 (5) doorManager.setDoorState(doorManager.registerDoor(2059227086, new Vector3(-39.13366, -1108.218, 26.7198)), true, 0); // Simeon Garage Door 2 (6) doorManager.setDoorState(doorManager.registerDoor(2059227086, new Vector3(-59.89302, -1092.952, 26.88362)), true, 0); // Simeon Garage Door 3 (7) doorManager.setDoorState(doorManager.registerDoor(1417577297, new Vector3(-60.54582, -1094.749, 26.88872)), true, 0); // Simeone Garage Door 4 (8) doorManager.setDoorState(doorManager.registerDoor(-116041313, new Vector3(127.9552, -1298.503, 29.41962)), true, 0); // LS Strip Club Door 1 (9) doorManager.setDoorState(doorManager.registerDoor(668467214, new Vector3(96.09197, -1284.854, 29.43878)), true, 0); // LS Strip Club Door 2 (10) // --- PD INTERIOR DOORS doorManager.setDoorState(doorManager.registerDoor(-1033001619, new Vector3(463.4782, -1003.538, 25.00599)), true, 0); // LS PD Door 1 (11) doorManager.setDoorState(doorManager.registerDoor(749848321, new Vector3(461.2865, -985.3206, 30.83926)), true, 0); // LS PD Door 2 (12) doorManager.setDoorState(doorManager.registerDoor(749848321, new Vector3(453.0793, -983.1895, 30.83926)), true, 0); // LS PD Door 3 (Armoury) (13) PDManager.AddCell(631614199, new Vector3(464.5601, -992.6381, 25.0649), true); // LS PD Cell 1 PDManager.AddCell(631614199, new Vector3(461.8293, -994.4047, 25.0649), true); // LS PD Cell 2 PDManager.AddCell(631614199, new Vector3(461.8293, -998.6381, 25.0649), true); // LS PD Cell 3 PDManager.AddCell(631614199, new Vector3(461.8293, -1002.6381, 25.0649), true); // LS PD Cell 4 // -- Property Doors are handled in Property Manager ServerDay = Server.Date.Day; ServerMonth = Server.Date.Month; ServerYear = Server.Date.Year; ServerHour = Server.Date.Hour; ServerMinute = Server.Date.Minute; API.delay(1200, true, OnServerTick); }
public void DisconnectPlayer(Client player) { Player user = null; try { user = Player.PlayerData[player]; } catch { user = Player.PlayerData.Values.FirstOrDefault(i => i.Username.Roleplay() == player.name); } if (user != null) { if (user.IsLogged) { user.IsLogged = false; user.LastPosition = player.position; user.LastRotation = player.rotation; user.Health = player.health; user.Armour = player.armor; user.Dimension = player.dimension; user.ChatIndicatorLabel.text = ""; API.deleteEntity(user.ChatIndicatorLabel); user.WeaponSkillData = string.Join(",", user.WeaponSkill.Values); user.SavePlayerVehicles(); if (user.InEvent == PlayerEvent.VehicleDealership) { user.LastPosition = new Vector3(-257.5197 + (new Random().Next(-50, 50) / 20), 6211.149 + (new Random().Next(-50, 50) / 20), z: 31.48923); user.LastRotZ = 121.6988; } Vehicle ve = Vehicle.VehicleData.Values.FirstOrDefault(v => v.IsDealerVehicle && v.OwnerId == user.Id); if (ve != null) { API.deleteEntity(ve.DealershipEmployee); ve.Entity.Delete(); } if (user.SelectedCash != null) { InventoryRepository.UpdateAsync(user.SelectedCash); } if (user.SelectedCardAccount != null) { BankRepository.UpdateAsync(user.SelectedCardAccount); } user.MasterAccount.ActiveConnectionLog.DisconnectTime = Server.Date; ConnectionLogRepository.UpdateAsync(user.MasterAccount.ActiveConnectionLog); WeaponRepository.UpdateAllAsync(user.Weapons); PlayerRepository.UpdateAsync(user); Player.PlayerData.Remove(user.Client); } else { Player.PlayerData.Remove(user.Client); } Master.MasterData.Remove(user.MasterAccount); } player.FadeIn(0); API.triggerClientEvent(player, "onPlayerDisconnect"); }