private void OnSessionLoad([FromSource] CitizenFX.Core.Player player) { try { var session = FromIdentifiers(player.Identifiers); if (session == null) { Log.Warn($"Could not find pre-existing session from {player.Name} (net:{player.Handle}, {string.Join( ", ", player.Identifiers )}). Creating new."); session = new Session(player); _sessions.Add(session); } else { session.Player = player; } foreach (var p in new PlayerList()) { var data = new SessionDataModel { Name = session.Name, NetId = session.NetId, SharedData = session.SharedData }; if (p.Handle == player.Handle) { data.ProtectedData = session.ProtectedData; } p.TriggerEvent("Session.Join", session.NetId, JsonConvert.SerializeObject(data)); } player.TriggerEvent("Session.Populate", JsonConvert.SerializeObject(_sessions.Where(s => s.NetId != session.NetId).Select(s => new SessionDataModel { Name = s.Name, NetId = s.NetId, SharedData = s.SharedData }).ToList())); player.TriggerEvent("Session.Loaded"); BaseScript.TriggerEvent("Session.Loaded", session.NetId); Log.Verbose($"Player {session.Name} (net:{session.NetId}) has loaded into the server."); } catch (Exception ex) { Log.Error(ex); } }
private void AddLootableItems([FromSource] CitizenFX.Core.Player Source, string Name, string ID) { if (Player.GetCurrentWeight(Source) < Config.MaxPlayerWeight) { if (Player.CanCarryItem(Source, Name, 1)) { Player.AddItem(Source, Name, 1); Source.TriggerEvent("Inventory:UpdateItemLootablee", ID); } else { UI.ShowNotification(Source, "~y~[Warning]~s~ Item limit reached"); } } else { UI.ShowNotification(Source, "~y~[Warning]~s~ Maximum weight reached, you cannot carry more things."); } }
private void AddLootableWeapons([FromSource] CitizenFX.Core.Player Source, string Name, int Ammo, string ID) { if (Player.GetCurrentWeight(Source) < Config.MaxPlayerWeight) { if (!Player.HasWeapon(Source, Name)) { Player.AddWeapon(Source, Name, Ammo); Source.TriggerEvent("Inventory:UpdateItemLootablee", ID, true); } else { UI.ShowNotification(Source, "~y~[Warning]~s~ You already have this weapon in your inventory"); } } else { UI.ShowNotification(Source, "~y~[Warning]~s~ Maximum weight reached, you cannot carry more things."); } }
public static void TriggerClientEvent(Player player, string eventName, params object[] args) { player.TriggerEvent(eventName, args); }
internal void RequestBlips([FromSource] CitizenFX.Core.Player source) { source.TriggerEvent("TempBlipModule.receiveInitialBlips", Helpers.MsgPack.Serialize(fileContents)); }
public static void Info([FromSource] CitizenFX.Core.Player Source, string Message) { Source.TriggerEvent("chat:addMessage", new { template = "<b style=\"color: #4F5FE6;\">{0}</b> {1}", multiline = true, args = new[] { "[Info]", Message } }); }