/// <summary> Applies this weapon to the given player, and sets up necessary state. </summary> public virtual void Enable(Player p) { if (!hookedEvents) { OnPlayerClickEvent.Register(PlayerClickCallback, Priority.Low); OnBlockChangingEvent.Register(BlockChangingCallback, Priority.Low); hookedEvents = true; } this.p = p; p.ClearBlockchange(); p.weapon = this; if (p.Supports(CpeExt.PlayerClick)) { p.Message(Name + " engaged, click to fire at will"); } else { p.Message(Name + " engaged, fire at will"); p.aiming = true; aimer = new AimBox(); aimer.Hook(p); } }
public static void InitHandlers() { OnPlayerConnectEvent.Register(OnConnect, Priority.High); OnPlayerDisconnectEvent.Register(OnLeave, Priority.High); OnPlayerMoveEvent.Register(OnMovement, Priority.High); OnPlayerClickEvent.Register(OnClick, Priority.High); OnPlayerChatEvent.Register(OnChat, Priority.High); OnTabListEntryAddedEvent.Register(HUD.GetTabName, Priority.High); OnPlayerActionEvent.Register(OnAFK, Priority.Normal); }
public override void Use(Player p, string message, CommandData data) { if (!p.level.Config.Guns) { p.Message(Weapon + "s cannot be used on this map!"); return; } if (p.aiming && message.Length == 0) { Disable(p); return; } WeaponType weaponType = GetWeaponType(p, message); if (weaponType == WeaponType.Invalid) { return; } p.blockchangeObject = weaponType; p.ClearBlockchange(); bool hasPlayerClick = p.Supports(CpeExt.PlayerClick); if (hasPlayerClick) { if (!hookedPlayerClick) { OnPlayerClickEvent.Register(PlayerClickCallback, Priority.Low); hookedPlayerClick = true; } p.Message(Weapon + " engaged, click to fire at will"); } else { p.Blockchange += BlockClickCallback; p.Message(Weapon + " engaged, fire at will"); } if (p.aiming) { return; } p.aiming = true; if (hasPlayerClick) { return; } AimState state = new AimState(); state.player = p; SchedulerTask task = new SchedulerTask(AimCallback, state, TimeSpan.Zero, true); p.CriticalTasks.Add(task); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleOnMapSent, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); clearTask = Server.Background.QueueRepeat(IPThrottler.CleanupTask, null, TimeSpan.FromMinutes(10)); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleSentMap, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnChangedZoneEvent.Register(MiscHandlers.HandleChangedZone, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); }
public override void Load(bool startup) { OnPlayerClickEvent.Register(HandlePlayerClick, Priority.High); }