int HandlePlayerClicked(byte[] buffer, int offset, int left) { const int size = 1 + 1 + 1 + 2 + 2 + 1 + 2 + 2 + 2 + 1; if (left < size) { return(0); } MouseButton Button = (MouseButton)buffer[offset + 1]; MouseAction Action = (MouseAction)buffer[offset + 2]; ushort yaw = NetUtils.ReadU16(buffer, offset + 3); ushort pitch = NetUtils.ReadU16(buffer, offset + 5); byte entityID = buffer[offset + 7]; ushort x = NetUtils.ReadU16(buffer, offset + 8); ushort y = NetUtils.ReadU16(buffer, offset + 10); ushort z = NetUtils.ReadU16(buffer, offset + 12); TargetBlockFace face = (TargetBlockFace)buffer[offset + 14]; if (face > TargetBlockFace.None) { face = TargetBlockFace.None; } OnPlayerClickEvent.Call(player, Button, Action, yaw, pitch, entityID, x, y, z, face); return(size); }
/// <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 Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleOnMapSent); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); Server.Background.Cancel(clearTask); }
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 Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleSentMap); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnChangedZoneEvent.Unregister(MiscHandlers.HandleChangedZone); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); }
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 Unload(bool shutdown) { OnPlayerClickEvent.Unregister(HandlePlayerClick); }
public override void Load(bool startup) { OnPlayerClickEvent.Register(HandlePlayerClick, Priority.High); }