internal bool OnVehicleRespray(int playerid, int vehicleid, int color1, int color2) { OnVehicleResprayed(GtaVehicle.FindOrCreate(vehicleid), new VehicleResprayedEventArgs(GtaPlayer.FindOrCreate(playerid), color1, color2)); return(true); }
/// <summary> /// Check if the parameter is well-formatted and return the output. /// </summary> /// <param name="command">The command text.</param> /// <param name="output">The output of this parameter.</param> /// <returns>True if the parameter is well-formatted, False otherwise.</returns> public override bool Check(ref string command, out object output) { if (!base.Check(ref command, out output)) return false; int id; GtaPlayer player = null; string word = (output as string).ToLower(); /* * Check whether the word is not a number. * If it is, find the player with this id. */ if (!int.TryParse(word, out id)) { IEnumerable<GtaPlayer> players = GtaPlayer.All.Where(p => p.Name.ToLower().Contains(word.ToLower())); if (players.Count() == 1) { player = players.First(); } } else { player = GtaPlayer.Find(id); } if (player == null || !player.IsConnected) { output = null; return false; } output = player; return true; }
internal bool OnVehicleDamageStatusUpdate(int vehicleid, int playerid) { OnVehicleDamageStatusUpdated(GtaVehicle.FindOrCreate(vehicleid), new PlayerEventArgs(GtaPlayer.FindOrCreate(playerid))); return(true); }
/// <summary> /// Initializes a new instance of the DamageEventArgs class. /// </summary> /// <param name="otherPlayer">The other player.</param> /// <param name="amount">Amount of damage done.</param> /// <param name="weapon">Weapon used to damage another.</param> /// <param name="bodypart">BodyPart shot at.</param> public DamageEventArgs(GtaPlayer otherPlayer, float amount, Weapon weapon, BodyPart bodypart) { OtherPlayer = otherPlayer; Amount = amount; Weapon = weapon; BodyPart = bodypart; }
/// <summary> /// Initializes a new instance of the <see cref="SelectGlobalObjectEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="object">The global object.</param> /// <param name="modelid">The modelid.</param> /// <param name="position">The position.</param> public SelectGlobalObjectEventArgs(GtaPlayer player, GlobalObject @object, int modelid, Vector3 position) : base(position) { Player = player; Object = @object; ModelId = modelid; }
internal bool OnPlayerInteriorChange(int playerid, int newinteriorid, int oldinteriorid) { OnPlayerInteriorChanged(GtaPlayer.FindOrCreate(playerid), new InteriorChangedEventArgs(newinteriorid, oldinteriorid)); return(true); }
/// <summary> /// Raises the <see cref="IMenu.Exit" /> event. /// </summary> /// <param name="player">The player.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> public void OnExit(GtaPlayer player, EventArgs e) { if (Exit != null) { Exit(player, e); } }
/// <summary> /// Raises the <see cref="IMenu.Response" /> event. /// </summary> /// <param name="player">The player.</param> /// <param name="e">The <see cref="MenuRowEventArgs" /> instance containing the event data.</param> public void OnResponse(GtaPlayer player, MenuRowEventArgs e) { if (Response != null) { Response(player, e); } }
internal bool OnPlayerGiveDamageActor(int playerid, int damagedActorid, float amount, int weaponid, int bodypart) { OnPlayerGiveDamageActor(Actor.FindOrCreate(damagedActorid), new DamageEventArgs(GtaPlayer.FindOrCreate(playerid), amount, (Weapon)weaponid, (BodyPart)bodypart)); return(true); }
public static bool MenuCommand(GtaPlayer player) { var m = new Menu("Test menu", Vector2.Zero); m.Columns.Add(new MenuColumn(100)); m.Rows.Add(new MenuRow("Active")); m.Rows.Add(new MenuRow("Disabled", true)); m.Rows.Add(new MenuRow("Active2")); m.Show(player); m.Exit += (o, eventArgs) => { player.SendClientMessage(Color.Red, "MENU CLOSED"); m.Dispose(); }; m.Response += (o, eventArgs) => { player.SendClientMessage(Color.Green, "SELECTED ROW " + eventArgs.Row); m.Dispose(); }; return(true); }
public void Start(GameMode gameMode) { int playercount = GtaPlayer.All.Count; bool success = true; GtaPlayer player = GtaPlayer.Create(499); if (GtaPlayer.All.Count - 1 != playercount) { Console.WriteLine("DisposureTest: Adding didn't add player to pool."); success = false; } player.Dispose(); if (GtaPlayer.All.Count != playercount) { Console.WriteLine("DisposureTest: Disposing didn't remove player from pool."); success = false; } try { player.SetChatBubble("Test!", Color.Yellow, 100, 10); Console.WriteLine("DisposureTest: Passed SetChatBubble."); success = false; } catch (ObjectDisposedException) { Console.WriteLine("DisposureTest: Exception thrown."); } Console.WriteLine("DisposureTest successful: {0}", success); }
internal bool OnDialogResponse(int playerid, int dialogid, int response, int listitem, string inputtext) { OnDialogResponse(GtaPlayer.FindOrCreate(playerid), new DialogResponseEventArgs(GtaPlayer.FindOrCreate(playerid), dialogid, response, listitem, inputtext)); return(true); }
internal bool OnVehicleStreamOut(int vehicleid, int forplayerid) { OnVehicleStreamOut(GtaVehicle.FindOrCreate(vehicleid), new PlayerEventArgs(GtaPlayer.FindOrCreate(forplayerid))); return(true); }
internal bool OnPlayerKeyStateChange(int playerid, int newkeys, int oldkeys) { OnPlayerKeyStateChanged(GtaPlayer.FindOrCreate(playerid), new KeyStateChangedEventArgs((Keys)newkeys, (Keys)oldkeys)); return(true); }
public static bool MenuCommand(GtaPlayer player) { var m = new Menu("Test menu", Vector2.Zero); m.Columns.Add(new MenuColumn(100)); m.Rows.Add(new MenuRow("Active")); m.Rows.Add(new MenuRow("Disabled", true)); m.Rows.Add(new MenuRow("Active2")); m.Show(player); m.Exit += (o, eventArgs) => { player.SendClientMessage(Color.Red, "MENU CLOSED"); m.Dispose(); }; m.Response += (o, eventArgs) => { player.SendClientMessage(Color.Green, "SELECTED ROW " + eventArgs.Row); m.Dispose(); }; return true; }
internal bool OnEnterExitModShop(int playerid, int enterexit, int interiorid) { OnPlayerEnterExitModShop(GtaPlayer.FindOrCreate(playerid), new EnterModShopEventArgs((EnterExit)enterexit, interiorid)); return(true); }
internal bool OnPlayerStateChange(int playerid, int newstate, int oldstate) { OnPlayerStateChanged(GtaPlayer.FindOrCreate(playerid), new StateEventArgs((PlayerState)newstate, (PlayerState)oldstate)); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="SelectPlayerObjectEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="object">The player object.</param> /// <param name="modelid">The modelid.</param> /// <param name="position">The position.</param> public SelectPlayerObjectEventArgs(GtaPlayer player, PlayerObject @object, int modelid, Vector3 position) : base(position) { Player = player; Object = @object; ModelId = modelid; }
internal bool OnTrailerUpdate(int playerId, int vehicleId) { var args = new TrailerEventArgs(GtaPlayer.FindOrCreate(playerId)); OnTrailerUpdate(GtaVehicle.FindOrCreate(vehicleId), args); return(!args.PreventPropagation); }
internal bool OnPlayerUpdate(int playerid) { var args = new PlayerUpdateEventArgs(); OnPlayerUpdate(GtaPlayer.FindOrCreate(playerid), args); return(!args.PreventPropagation); }
internal bool OnPlayerRequestClass(int playerid, int classid) { var args = new RequestClassEventArgs(classid); OnPlayerRequestClass(GtaPlayer.FindOrCreate(playerid), args); return(!args.PreventSpawning); }
internal bool OnPlayerSpawn(int playerid) { var args = new SpawnEventArgs(); OnPlayerSpawned(GtaPlayer.FindOrCreate(playerid), args); return(!args.ReturnToClassSelection); }
internal bool OnVehicleMod(int playerid, int vehicleid, int componentid) { var args = new VehicleModEventArgs(GtaPlayer.FindOrCreate(playerid), componentid); OnVehicleMod(GtaVehicle.FindOrCreate(vehicleid), args); return(!args.PreventPropagation); }
internal bool OnPlayerRequestSpawn(int playerid) { var args = new RequestSpawnEventArgs(); OnPlayerRequestSpawn(GtaPlayer.FindOrCreate(playerid), args); return(!args.PreventSpawning); }
internal bool OnPlayerGiveDamage(int playerid, int damagedid, float amount, int weaponid, int bodypart) { OnPlayerGiveDamage(GtaPlayer.FindOrCreate(playerid), new DamageEventArgs(damagedid == GtaPlayer.InvalidId ? null : GtaPlayer.FindOrCreate(damagedid), amount, (Weapon)weaponid, (BodyPart)bodypart)); return(true); }
internal bool OnVehiclePaintjob(int playerid, int vehicleid, int paintjobid) { OnVehiclePaintjobApplied(GtaVehicle.FindOrCreate(vehicleid), new VehiclePaintjobEventArgs(GtaPlayer.FindOrCreate(playerid), paintjobid)); return(true); }
internal bool OnPlayerCommandText(int playerid, string cmdtext) { var args = new CommandTextEventArgs(cmdtext); OnPlayerCommandText(GtaPlayer.FindOrCreate(playerid), args); return(args.Success); }
internal bool OnPlayerDeath(int playerid, int killerid, int reason) { OnPlayerDied(GtaPlayer.FindOrCreate(playerid), new DeathEventArgs(killerid == GtaPlayer.InvalidId ? null : GtaPlayer.FindOrCreate(killerid), (Weapon)reason)); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="UnoccupiedVehicleEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="passengerSeat">The passenger seat.</param> /// <param name="newPosition">The new position.</param> /// <param name="newVelocity">The new velocity.</param> public UnoccupiedVehicleEventArgs(GtaPlayer player, int passengerSeat, Vector3 newPosition, Vector3 newVelocity) : base(player) { PassengerSeat = passengerSeat; NewPosition = newPosition; NewVelocity = newVelocity; }
public static async void DialogASyncCommand(GtaPlayer player) { var dialog = new Dialog(DialogStyle.Input, "Hello", "Insert something", "Confirm", "NO"); var response = await dialog.ShowAsync(player); Console.WriteLine(Sync.IsRequired); Sync.Run(() => { player.SendClientMessage("Response: " + response.InputText); }); }
/// <summary> /// Initializes a new instance of the <see cref="EditGlobalObjectEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="object">The global object.</param> /// <param name="response">The response.</param> /// <param name="position">The position.</param> /// <param name="rotation">The rotation.</param> public EditGlobalObjectEventArgs(GtaPlayer player, GlobalObject @object, EditObjectResponse response, Vector3 position, Vector3 rotation) : base(position) { Player = player; Object = @object; EditObjectResponse = response; Rotation = rotation; }
public async void ASyncPlayerConnectedDelayed(GtaPlayer player) { await Task.Delay(2000); Console.WriteLine("in ASyncPlayerConnectedDelayed"); player.SendClientMessage("ASync message! !{0}!", Native.IsMainThread()); Sync.Run(() => player.SendClientMessage("Sync message! !{0}!", Native.IsMainThread())); }
/// <summary> /// Initializes a new instance of the DialogResponseEventArgs class. /// </summary> /// <param name="player">The player.</param> /// <param name="dialogid">Id of the dialog.</param> /// <param name="response">Response of the dialog response.</param> /// <param name="listitem">List item of the dialog response.</param> /// <param name="inputtext">Input text of the dialog response.</param> public DialogResponseEventArgs(GtaPlayer player, int dialogid, int response, int listitem, string inputtext) { Player = player; DialogId = dialogid; DialogButton = (DialogButton)response; ListItem = listitem; InputText = inputtext; }
/// <summary> /// Initializes a new instance of the <see cref="EditPlayerObjectEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="object">The global object.</param> /// <param name="response">The response.</param> /// <param name="position">The position.</param> /// <param name="rotation">The rotation.</param> public EditPlayerObjectEventArgs(GtaPlayer player, PlayerObject @object, EditObjectResponse response, Vector3 position, Vector3 rotation) : base(position) { Player = player; Object = @object; EditObjectResponse = response; Rotation = rotation; }
public static void PutCommand(GtaPlayer player, int vehicleid, int seat = 0) { GtaVehicle v = GtaVehicle.Find(vehicleid); if (v == null) { player.SendClientMessage(Color.Red, "This vehicle does not exist!"); return; } player.PutInVehicle(v, seat); }
public static void DialogCommand(GtaPlayer player) { var dialog = new MessageDialog("Captions", "abc", "OK!", "Cancel"); dialog.Show(player); dialog.Response += (sender, args) => { player.SendClientMessage("Response: " + args.DialogButton); }; }
public static bool CharsetCommand(GtaPlayer player) { GtaPlayer.SendClientMessageToAll(Color.Teal, "this is a test: \u00D6"); GtaPlayer.SendClientMessageToAll(Color.Teal, "this is a test: Ä ä Ö ö Ü ü ß ..."); GtaPlayer.SendClientMessageToAll("Cyrillic characters:"); GtaPlayer.SendClientMessageToAll("А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ь Ы Ъ Э Ю Я"); GtaPlayer.SendClientMessageToAll("Czech characters:"); GtaPlayer.SendClientMessageToAll("ú ů ý ž ’ „ “ ” – — á č ď é ě í ň ó ř š ť Ú Ů Ý Ž Á Č Ď É Ě Í Ň Ó Ř Š Ť"); return true; }
public static void CommandsCommand(GtaPlayer player) { player.SendClientMessage(Color.Green, "Commands:"); foreach ( DetectedCommand cmd in Command.GetAll<DetectedCommand>() .Where(c => c.HasPlayerPermissionForCommand(player)) .OrderBy( /* category??? */c => c.CommandPath)) { player.SendClientMessage(Color.White, "/{0}: I could add an Attribute in my gamemode with an help message and/or color", cmd.CommandPath); } }
public static void DialogListCommand(GtaPlayer player, string items) { var dialog = new ListDialog("Captions", "OK!"); foreach (var i in items.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s))) dialog.Items.Add(i); dialog.Show(player); dialog.Response += (sender, args) => { player.SendClientMessage("Response: " + args.ListItem); }; }
/// <summary> /// Hides all dialogs for the specified <paramref name="player" />. /// </summary> /// <param name="player">The Player to hide all dialogs from.</param> public static void Hide(GtaPlayer player) { if (player == null) throw new ArgumentNullException("player"); var openDialog = GetOpenDialog(player); if (openDialog == null) return; OpenDialogs.Remove(player.Id); openDialog._aSyncWaiter.Cancel(player); Native.ShowPlayerDialog(player.Id, DialogHideId, (int) DialogStyle.MessageBox, string.Empty, string.Empty, string.Empty, string.Empty); }
public static async void DialogASyncCommandLogintest(GtaPlayer player) { var dialog = new InputDialog("Hello", "Login please!", true, "Login", "Cancel"); var timerToShowThingsWork = new Timer(1000, true); timerToShowThingsWork.Tick += (sender, args) => { player.SendClientMessage("Things still work in the background!"); }; var response = await dialog.ShowAsync(player); player.SendClientMessage("Your input was {1}... Do we require a sync? {0}. So thats awesome! Lets move you up a lill. ", Sync.IsRequired, response.InputText); player.Position += new Vector3(0,1,0); timerToShowThingsWork.Dispose(); }
/// <summary> /// Raises the <see cref="PlayerSelectPlayerObject" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="SelectPlayerObjectEventArgs" /> that contains the event data.</param> protected virtual void OnPlayerSelectPlayerObject(GtaPlayer player, SelectPlayerObjectEventArgs e) { if (PlayerSelectPlayerObject != null) PlayerSelectPlayerObject(player, e); }
/// <summary> /// Raises the <see cref="PlayerUpdate" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="PlayerEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerUpdate(GtaPlayer player, PlayerUpdateEventArgs e) { if (PlayerUpdate != null) PlayerUpdate(player, e); }
/// <summary> /// Raises the <see cref="PlayerText" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="TextEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerText(GtaPlayer player, TextEventArgs e) { if (PlayerText != null) PlayerText(player, e); }
/// <summary> /// Raises the <see cref="PlayerRequestClass" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="RequestClassEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerRequestClass(GtaPlayer player, RequestClassEventArgs e) { if (PlayerRequestClass != null) PlayerRequestClass(player, e); }
/// <summary> /// Raises the <see cref="PlayerWeaponShot" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="WeaponShotEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerWeaponShot(GtaPlayer player, WeaponShotEventArgs e) { if (PlayerWeaponShot != null) PlayerWeaponShot(player, e); }
/// <summary> /// Raises the <see cref="PlayerTakeDamage" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="DamageEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerTakeDamage(GtaPlayer player, DamageEventArgs e) { if (PlayerTakeDamage != null) PlayerTakeDamage(player, e); }
/// <summary> /// Initializes a new instance of the <see cref="VehiclePaintjobEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="paintjobId">The paintjob identifier.</param> public VehiclePaintjobEventArgs(GtaPlayer player, int paintjobId) : base(player) { PaintjobId = paintjobId; }
/// <summary> /// Raises the <see cref="PlayerStateChanged" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="StateEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerStateChanged(GtaPlayer player, StateEventArgs e) { if (PlayerStateChanged != null) PlayerStateChanged(player, e); }
/// <summary> /// Initializes a new instance of the <see cref="VehicleResprayedEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="color1">The color1.</param> /// <param name="color2">The color2.</param> public VehicleResprayedEventArgs(GtaPlayer player, int color1, int color2) : base(player) { Color1 = color1; Color2 = color2; }
/// <summary> /// Raises the <see cref="PlayerSpawned" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="PlayerEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerSpawned(GtaPlayer player, SpawnEventArgs e) { if (PlayerSpawned != null) PlayerSpawned(player, e); }
/// <summary> /// Initializes a new instance of the ClickPlayerEventArgs class. /// </summary> /// <param name="clickedPlayer">Id of the clicked player.</param> /// <param name="source">PlayerClickSource of the event.</param> public ClickPlayerEventArgs(GtaPlayer clickedPlayer, PlayerClickSource source) { ClickedPlayer = clickedPlayer; PlayerClickSource = source; }
/// <summary> /// Raises the <see cref="PlayerSelectedMenuRow" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="MenuRowEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerSelectedMenuRow(GtaPlayer player, MenuRowEventArgs e) { if (PlayerSelectedMenuRow != null) PlayerSelectedMenuRow(player, e); }
public bool Check(GtaPlayer player) { return player.IsAdmin; }
/// <summary> /// Raises the <see cref="PlayerRequestSpawn" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="PlayerEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerRequestSpawn(GtaPlayer player, RequestSpawnEventArgs e) { if (PlayerRequestSpawn != null) PlayerRequestSpawn(player, e); }
/// <summary> /// Initializes a new instance of the <see cref="PlayerVehicleEventArgs" /> class. /// </summary> /// <param name="player">The player.</param> /// <param name="vehicle">The vehicle.</param> public PlayerVehicleEventArgs(GtaPlayer player, GtaVehicle vehicle) : base(player) { Vehicle = vehicle; }
/// <summary> /// Raises the <see cref="PlayerStreamOut" /> event. /// </summary> /// <param name="player">The player triggering the event.</param> /// <param name="e">An <see cref="PlayerEventArgs" /> that contains the event data. </param> protected virtual void OnPlayerStreamOut(GtaPlayer player, PlayerEventArgs e) { if (PlayerStreamOut != null) PlayerStreamOut(player, e); }