Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////////////////////////
- /*
- YouViolateMe
- Improved Button Monitoring now supports getStance
- 7/25/2016
- */
- /////////////////////////////////////////////////////
- MonitorButtons()
- {
- self endon("disconnect");
- self notify("stop_listening");
- self notify("stop_notify");
- self thread notifyOnPlayerCommand("dpad_up", ::ActionSlotOneButtonPressed, "stopAS1Notify");
- self thread notifyOnPlayerCommand("dpad_down", ::ActionSlotTwoButtonPressed, "stopAS2Notify");
- self thread notifyOnPlayerCommand("dpad_left", ::ActionSlotThreeButtonPressed, "stopAS3Notify");
- self thread notifyOnPlayerCommand("dpad_right", ::ActionSlotFourButtonPressed, "stopAS4Notify");
- self thread notifyOnPlayerCommand("button_sprint", ::SprintButtonPressed, "stopSprintNotify");
- self thread notifyOnPlayerCommand("button_melee", ::MeleeButtonPressed, "stopMeleeNotify");
- self thread notifyOnPlayerCommand("button_jump", ::JumpButtonPressed, "stopJumpNotify");
- self thread notifyOnPlayerCommand("button_use", ::UseButtonPressed, "stopUseNotify");
- self thread notifyOnPlayerCommand("button_switchweapon", ::ChangeSeatButtonPressed, "stopSeatButtonNotify");
- self thread notifyOnPlayerCommand("button_stance", ::StanceButtonPressed, "stopStanceNotify");
- self thread notifyOnPlayerCommand("button_attack", ::AttackButtonPressed, "stopAttackNotify");
- self thread notifyOnPlayerCommand("button_aim", ::ADSButtonPressed, "stopADSNotify");
- self thread notifyOnPlayerCommand("button_secondaryoffhand", ::SecondaryOffHandButtonPressed, "stopSecondaryOffHandNotify");
- self thread notifyOnPlayerCommand("button_frag", ::FragButtonPressed, "stopFragNotify");
- self thread listen("stop_noclip_button_monitoring", ::ToggleNoclip, "dpad_left", undefined, "crouch"); //example for noclip
- //add custom button monitoring below if necessary
- }
- ActionSlotOneButtonPressed(){ return self ActionSlotOneButtonPressed(); }
- ActionSlotTwoButtonPressed(){ return self ActionSlotTwoButtonPressed(); }
- ActionSlotThreeButtonPressed(){ return self ActionSlotThreeButtonPressed(); }
- ActionSlotFourButtonPressed(){ return self ActionSlotFourButtonPressed(); }
- SprintButtonPressed(){ return self SprintButtonPressed(); }
- MeleeButtonPressed(){ return self MeleeButtonPressed(); }
- JumpButtonPressed(){ return self JumpButtonPressed(); }
- UseButtonPressed(){ return self UseButtonPressed(); }
- ChangeSeatButtonPressed(){ return self ChangeSeatButtonPressed(); }
- StanceButtonPressed(){ return self StanceButtonPressed(); }
- AttackButtonPressed(){ return self AttackButtonPressed(); }
- ADSButtonPressed(){ return self ADSButtonPressed(); }
- SecondaryOffHandButtonPressed(){ return self SecondaryOffHandButtonPressed(); }
- FragButtonPressed(){ return self FragButtonPressed(); }
- notifyOnPlayerCommand(ButtonNotify, isButtonPushed, stopNotify)
- {
- self endon("disconnect");
- self endon("stop_notify");
- self endon(stopNotify);
- for(;;)
- {
- if (self [[isButtonPushed]]())
- self notify(ButtonNotify);
- wait 0.05;
- }
- }
- listen(endon_event, function, event, event2, stance)
- {
- self endon("disconnect");
- self endon("stop_listening");
- self endon(endon_event);
- for(;;)
- {
- if (!isDefined(event2))
- {
- if (!isDefined(stance))
- self waittill(event);
- else
- self waittill_event_stance(.15, event, stance);
- if (self.AllowControls)
- self [[function]]();
- wait .18;
- }
- else
- {
- self waittill_both(.15, event, event2, isDefined(stance) ? stance : undefined);
- if (self.AllowControls)
- self [[function]]();
- wait .18;
- }
- }
- }
- waittill_event_stance(time, arg1, stance)
- {
- self endon("disconnect");
- threads = 0;
- while(threads < 2)
- {
- self waittill(arg1);
- threads++;
- if (self getStance() == stance)
- threads++;
- else
- threads = 0;
- }
- self notify(arg1 + "_" + stance);
- }
- waittill_both(time, arg1, arg2, stance)
- {
- self endon("disconnect");
- threads = 0;
- while(threads < 2)
- {
- firstarg = self waittill_any_return(arg1, arg2);
- threads++;
- self thread timeout(time);
- if (firstarg == arg1)
- self thread waitforstring(arg2);
- else if (firstarg == arg2)
- self thread waitforstring(arg1);
- msg = self waittill_any_return("button_pushed", "stop_waiting");
- if (msg == "stop_waiting")
- threads = 0;
- else if (msg == "button_pushed")
- {
- if (isDefined(stance))
- {
- if (self getStance() == stance)
- threads++;
- else
- threads = 0;
- }
- else
- threads++;
- }
- }
- self notify(arg1 + "_" + arg2);
- }
- timeout(time)
- {
- self endon("disconnect");
- self endon("button_pushed");
- wait(time);
- self notify("stop_waiting");
- return;
- }
- waitforstring(arg, threads)
- {
- self endon("disconnect");
- self endon("stop_waiting");
- self waittill(arg);
- self notify("button_pushed");
- return;
- }
- ToggleNoclip() //my example function
- {
- self.Noclip = !self.Noclip;
- if (self.Noclip)
- {
- self notify("stop_noclip");
- self thread Noclip();
- }
- else
- {
- self unlink();
- self enableweapons();
- self.originObj delete();
- self notify("stop_noclip");
- }
- }
- Noclip()
- {
- self endon("stop_noclip");
- self endon("disconnect");
- self.originObj = spawn( "script_origin", self.origin, 1 );
- self.originObj.angles = self.angles;
- self playerlinkto( self.originObj, undefined );
- self disableweapons();
- for(;;)
- {
- if(FragButtonPressed())
- {
- normalized = anglesToForward( self getPlayerAngles() );
- scaled = vectorScale( normalized, 40 );
- originpos = self.origin + scaled;
- self.originObj.origin = originpos;
- }
- else if(MeleeButtonPressed())
- {
- self unlink();
- self enableweapons();
- self.originObj delete();
- self.Noclip = false;
- self notify("stop_noclip");
- }
- wait 0.05;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment