need help with this script
3 posts
• Page 1 of 1
need help with this script
Hello so what I have been trying to create a code that when I press x button on xbox and hold it, would do this: every second that I hold the button down the rapid x will speed up or increase. So base starting from 1 click per second and increasing by 100 millisecond each second I hold the x button. how would that code look like
-
alencroat - Lieutenant
- Posts: 320
- Joined: Sun Oct 15, 2017 5:58 pm
Re: need help with this script
Example:
Example output:
GVM Output: rfirespeed: 1000
GVM Output: rfirespeed: 900
GVM Output: rfirespeed: 800
- Code: Select all
#define rfireDef 1000 // default rapid fire wait time
#define rfireMax 100 // max speed (minimum wait time)
uint32 rfireMod; // modification time based on xbox X button hold time / 1000
uint16 rfireSpeed; // the resulting rapid fire wait time
main {
// reset on new press of X
if (event_active(BUTTON_17)) rfireMod = 0;
// speed increase while hold every 1 second
if (elapsed_time() && get_actual(BUTTON_17)) {
rfireMod = time_active(BUTTON_17) / 1000; // current press time / 1000
rfireSpeed = rfireDef - (rfireMod * 100); // def speed - mod * 100
rfireSpeed = clamp(rfireSpeed, rfireMax, rfireDef); // limit to max, def
if (mod((fix32)time_active(BUTTON_17), 1000f) == 0.0) printf("rfirespeed: %d", rfireSpeed); // print out every 1sec
}
}
Example output:
GVM Output: rfirespeed: 1000
GVM Output: rfirespeed: 900
GVM Output: rfirespeed: 800
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: need help with this script
thank you Scachi
-
alencroat - Lieutenant
- Posts: 320
- Joined: Sun Oct 15, 2017 5:58 pm
3 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: midg3t2 and 216 guests