Button Monitoring - 505e06b2/MW2-GSC-Documentation GitHub Wiki
Useful links:
Create an event for when the player sends the specified command
onPlayerConnect() {
while(true) {
level waittill("connected", player);
player notifyOnPlayerCommand("menu_open", "+actionslot 1"); //N / D-pad Up
player notifyOnPlayerCommand("menu_up", "+actionslot 1"); //N / D-pad Up - these 2 won't interfere, and can make things easier
player thread onPlayerSpawned();
}
}
onPlayerSpawned() {
self endon("disconnect");
while(true) {
self waittill("spawned_player");
self thread menu_think();
}
}
_think() {
self endon("disconnect");
self endon("death");
while(true) {
self waittill("menu_open");
self iPrintLn("Pressed Dpad-Up!");
}
}
Returns a boolean that's true if the button is pressed - a rather limiting choice, but can still be occasionally useful
onPlayerConnect() {
while(true) {
level waittill("connected", player);
player thread onPlayerSpawn();
}
}
onPlayerSpawn() {
self endon("disconnect");
while(true) {
self waittill("spawned");
self thread _think();
}
}
_think() {
self endon("disconnect");
self endon("death");
while(true) {
if(self attackButtonPressed()) self iPrintLn("[{+attack}]");
if(self adsButtonPressed()) self iPrintLn("[{+toggleads_throw}] or [{+speed_throw}]");
if(self useButtonPressed()) self iPrintLn("[{+usereload}] or [{+activate}]");
if(self meleeButtonPressed()) self iPrintLn("[{+melee}]");
if(self fragButtonPressed()) self iPrintLn("[{+frag}]");
if(self secondaryOffHandButtonPressed()) self iPrintLn("[{+smoke}]");
wait 1/30; //30fps
}
}