Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ScrollWheelHijackEventHandler : EventHandler {
- static const String KeyBindsCCMDs [] = { "weapnext", "weapprev" };
- static const String KeyBindsNetEvents [] = { "next", "prev" };
- override bool InputProcess (InputEvent e) {
- if (e.Type != InputEvent.Type_KeyDown)
- return false;
- int bind1, bind2;
- for (int i = 0; i < 12; i++) {
- [bind1, bind2] = Bindings.GetKeysForCommand (KeyBindsCCMDs [i]);
- if (e.KeyScan == bind1 || e.KeyScan == bind2) {
- EventHandler.SendNetworkEvent (String.Format ("ScrollWheelHijack:%s", KeyBindsNetEvents [i]));
- return true;
- }
- }
- return false;
- }
- override void NetworkProcess (ConsoleEvent e) {
- if (e.Player < 0) // Don't execute this if the player isn't given/valid
- return;
- if (!playeringame [e.Player] || !players [e.Player].mo) // Don't execute if the player isn't ingame, the player is null or the player's PlayerPawn is null
- return;
- Array<String> strings;
- e.Name.Split (strings, ":");
- if (strings.Size () < 2) // Return if the array has less than two strings
- return;
- if (strings [0] == "ScrollWheelHijack")
- WeapBindsSystem (e);
- }
- void WeapBindsSystem (ConsoleEvent e) {
- PlayerInfo player = players [e.Player];
- if (!player) // Return if the player is null
- return;
- Array<String> commandStrings;
- e.Name.Split (commandStrings, ":");
- if (commandStrings.Size () < 2) // Return if the array contains less than two strings
- return;
- if (commandStrings [1] == "next") {
- S7_BaseWeapon weapon = weapBinds.CycleWeapons (false, false);
- if (player.ReadyWeapon != weapon) {
- player.PendingWeapon = weapon;
- weapBinds.LastWeapon = weapon;
- }
- } else if (commandStrings [1] == "prev") {
- S7_BaseWeapon weapon = weapBinds.CycleWeapons (true, false);
- if (player.ReadyWeapon != weapon) {
- player.PendingWeapon = weapon;
- weapBinds.LastWeapon = weapon;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement