public override void OnDeath(DeathEventArgs e) { base.OnDeath(e); nameLabel.Dispose(); nameLabel = null; }
public static DynamicTextLabel CreateTmeTimer(String message, Vector3 position, float drawdistance, int time, Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLOS = false, int worldid = -1, int interiorid = -1, Player player = null, float streamdistance = 100, DynamicArea area = null, int priority = 0) { DynamicTextLabel dynamicTextLabel = new DynamicTextLabel(message, Constants.Chat.ME, position, drawdistance, attachedPlayer, attachedVehicle, testLOS, worldid, interiorid, player, streamdistance, area, priority); var timerKick = new Timer(time, false); timerKick.Tick += (senderPlayer, e) => { dynamicTextLabel.Dispose(); }; return(dynamicTextLabel); }
public override void OnDisconnected(DisconnectEventArgs e) { base.OnDisconnected(e); if (nameLabel != null) { nameLabel.Dispose(); nameLabel = null; } try { GunHelper.SaveGunInHand(this); } catch (Exception exception) { } }
private T GetItem <T>(int id) where T : IDynamicWorldObject { if (typeof(DynamicTextLabel).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicTextLabel.Find(id)); } if (typeof(DynamicPickup).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicPickup.Find(id)); } if (typeof(DynamicRaceCheckpoint).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicRaceCheckpoint.Find(id)); } if (typeof(DynamicObject).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicObject.Find(id)); } if (typeof(DynamicMapIcon).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicMapIcon.Find(id)); } if (typeof(DynamicCheckpoint).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicCheckpoint.Find(id)); } if (typeof(DynamicArea).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicArea.Find(id)); } if (typeof(DynamicActor).IsAssignableFrom(typeof(T))) { return((T)(IDynamicWorldObject)DynamicActor.Find(id)); } throw new Exception("Unknown dynamic world object type."); }
public override void OnSpawned(SpawnEventArgs e) { base.OnSpawned(e); this.Skin = (int)this.ActiveCharacter.Skin; this.Interior = this.ActiveCharacter.SpawnLocation.Interior; this.VirtualWorld = this.ActiveCharacter.SpawnLocation.VirtualWorld; if (this.ActiveCharacter.ItemInHand != null && this.ActiveCharacter.ItemInHand is Gun) { this.GiveWeapon(((Gun)this.ActiveCharacter.ItemInHand).idWeapon, this.ActiveCharacter.ItemInHand.Quantity); } nameLabel = new DynamicTextLabel(this.Name + " (( " + this.Id + " ))" + "\r\n" + Constants.Chat.ME + Utils.PlayerUtils.PlayerHelper.HealthToDescription(this), Color.White, new Vector3(0, 0, 0.3), Constants.PLAYER_LABEL_DIST, attachedPlayer: this, testLOS: true); nameLabel.Interior = this.Interior; nameLabel.World = this.VirtualWorld; nameLabel.HideForPlayer(this); }
private void Object3DText(int modelid, Vector3 position) { _dynamicTextLabel = new DynamicTextLabel($"{this}\nAPI ID: {ApiId} | ID: {Id} | Model: {modelid}", Color.Chocolate, position, 25.0f); }
/// <summary> /// Registers types this <see cref="T:SampSharp.GameMode.Controllers.ITypeProvider" /> requires the system to use. /// </summary> public virtual void RegisterTypes() { DynamicTextLabel.Register <DynamicTextLabel>(); }
public static void Call(Player sender, string number) { Phone phoneReceiver = PhoneHelper.GetPhoneByNumber(number); Object dynamicTextLabelPhone = null; if (phoneReceiver is null) { throw new Exception("le numéro " + number + " n'est pas attribué."); } if (phoneReceiver.IsRinging || phoneReceiver.IsCalling) { throw new Exception("le numéro " + number + " est déjà en cours d'appel."); } Character character = PhoneHelper.GetPhoneOwner(phoneReceiver); Player receiver = PlayerHelper.SearchCharacter(character); Phone phoneSender = GetDefaultPhone(sender.ActiveCharacter); if (phoneSender == null) { throw new Exception("Vous n'avez pas de téléphone par défaut sur vous."); } if (phoneReceiver == phoneSender) { throw new Exception("Vous ne pouvez pas vous appeler vous même."); } if (phoneReceiver.Silent) { throw new Exception("le téléphone du joueur est en silencieux, impossible de l'appeler."); } Chat.CallChat(sender, "Appel en cours..."); if (receiver != null && !phoneSender.Anonym) // If a player has the phone { Chat.CallChat(receiver, "Quelqu'un essaie de vous appeler (" + phoneSender.Number + ") ! /t dec pour décrocher."); } else if (receiver != null && phoneSender.Anonym) { Chat.CallChat(receiver, "Quelqu'un essaie de vous appeler (Anonyme)! /t dec pour décrocher."); } else // If the phone is not in a player inventory { if (phoneReceiver.CurrentContainer == null && phoneReceiver.SpawnLocation != null) { Vector3 phoneLabelPosition = new Vector3(phoneReceiver.SpawnLocation.X, phoneReceiver.SpawnLocation.Y, phoneReceiver.SpawnLocation.Z + Constants.Item.PHONE_LABEL_DISTANCE_FROM_PHONE); dynamicTextLabelPhone = Chat.CreateTme("Le téléphone sonne !", phoneLabelPosition, Constants.Item.PHONE_LABEL_DISTANCE); } } phoneSender.IsRinging = true; phoneSender.PhoneNumberCaller = phoneReceiver.Number; phoneReceiver.IsRinging = true; phoneReceiver.PhoneNumberCaller = phoneSender.Number; var timer = new Timer(5000, true); int nbr = 0; timer.Tick += (senderPlayer, e) => { if (phoneSender.IsCalling && phoneReceiver.IsCalling) // If the players are now in a call { timer.Dispose(); nbr = 0; try { if (dynamicTextLabelPhone != null) { DynamicTextLabel textLabel = (DynamicTextLabel)dynamicTextLabelPhone; textLabel.Dispose(); textLabel = null; } } catch (Exception exception) { } } else { if (phoneSender.IsRinging == false || phoneReceiver.IsRinging == false) { timer.Dispose(); try { if (dynamicTextLabelPhone != null) { DynamicTextLabel textLabel = (DynamicTextLabel)dynamicTextLabelPhone; textLabel.Dispose(); textLabel = null; } return; } catch (Exception exception) { } } if (nbr < 3) { if (receiver != null && !phoneSender.Anonym) // If a player has the phone { Chat.CallChat(receiver, "Quelqu'un essaie de vous appeler (" + phoneSender.Number + ") ! /t dec pour décrocher."); } else if (receiver != null && phoneSender.Anonym) { Chat.CallChat(receiver, "Quelqu'un essaie de vous appeler (Anonyme)! /t dec pour décrocher."); } else // If the phone is not in a player inventory { } nbr++; } else { timer.Dispose(); nbr = 0; Chat.CallChat(sender, "La personne n'a pas décroché."); try { if (dynamicTextLabelPhone != null) { DynamicTextLabel textLabel = (DynamicTextLabel)dynamicTextLabelPhone; textLabel.Dispose(); textLabel = null; } } catch (Exception exception) { } phoneSender.IsRinging = false; phoneSender.PhoneNumberCaller = null; phoneReceiver.IsRinging = false; phoneReceiver.PhoneNumberCaller = null; } } }; }