White Dragon
New member
This is my library for keyall.c
With this script you can use multiple buttons for Keys/combo like:
"attack+attack2"
"attack+jump+special"
"down, down+forward+attack"
"attack+attack2, attack+jump+special"
etc..
DOWNLOAD:
http://www.mediafire.com/download/mmv7qb8zpmsl7jv/key_lib.zip
USAGE:
int combo(int p, char combo_id, int ETA, int hold_btn_combo_flag, char btn1, char btn2, char btn3, ...)
- Use it for combo like down, forward, attack+jump or down, forward+attack+jump
- returns 1 is the combo is completed, else returns 0
PARAMS:
int p: Player Index
char combo_id: Combo ID (string)
int ETA: time between two buttons pression (buffer window): 0 or NULL() is default. default is 0.5
int hold_btn_combo_flag: hold button flag (the same of playerkeys())
char btn1, char btn2, char btn3, ...: buttons
ACCEPTED BUTTONS:
forward, backward, up, down, attack,
attack2, attack3, attack4, jump,
special, start, esc, screenshot
and the function accepts multiple buttons like
"attack+attack2" or "attack+jump+special"
Example:
other functions:
int playerkeys_multi(int p, int hold_flag, char key_string)
- return 1 if all buttons are pressed, 2 if button are partially pressed and 0 if buttons aren't pressed. it works like playerkeys()
ex. playerkeys_multi(0, 0, "attack+jump") returns 1 if player 1 hold
attack+jump+special together
and it returns 2 is player 1 hold only attack or jump. It accepts also more
then two buttons like: "attack+jump+special"
int get_hold_time(int p, char key)
- returns the hold button time.
ex. get_hold_time(0, "attack") returns the hold button time for player 1.
int is_multi_hold_pressed(int p, char btn1, char btn2, char btn3, ...)
- returns 1 if more than one button is pressed, it returns 0 else.
ex. is_multi_hold_pressed(0,"attack","jump") returns 1 if the player 1 holds attack and jump button togheter
...and a function to retrieve an impulse every a CUSTOM ETA while you hold a button (use it in a script or ondrawscript event and not keyall.c):
example:
if ( hold_key_press(player_index,"moveright",0.08,1,0.2) == openborconstant("FLAG_MOVERIGHT") ) {
...
}
With this script you can use multiple buttons for Keys/combo like:
"attack+attack2"
"attack+jump+special"
"down, down+forward+attack"
"attack+attack2, attack+jump+special"
etc..
DOWNLOAD:
http://www.mediafire.com/download/mmv7qb8zpmsl7jv/key_lib.zip
USAGE:
int combo(int p, char combo_id, int ETA, int hold_btn_combo_flag, char btn1, char btn2, char btn3, ...)
- Use it for combo like down, forward, attack+jump or down, forward+attack+jump
- returns 1 is the combo is completed, else returns 0
PARAMS:
int p: Player Index
char combo_id: Combo ID (string)
int ETA: time between two buttons pression (buffer window): 0 or NULL() is default. default is 0.5
int hold_btn_combo_flag: hold button flag (the same of playerkeys())
char btn1, char btn2, char btn3, ...: buttons
ACCEPTED BUTTONS:
forward, backward, up, down, attack,
attack2, attack3, attack4, jump,
special, start, esc, screenshot
and the function accepts multiple buttons like
"attack+attack2" or "attack+jump+special"
Example:
Code:
if ( getentityproperty(getplayerproperty(p,"entity"),"exists") ) {
void player = getplayerproperty(p,"entity");
if( combo(p,"combo01",0,1,"forward","up","attack+attack2") ) {
char anim = "ANI_FOLLOW42";
if ( ready_to_attack(player,1,0,NULL()) ) {
changeentityproperty(player,"velocity",0,0,0);
performattack(player,openborconstant(anim),1);
}
}
}
other functions:
int playerkeys_multi(int p, int hold_flag, char key_string)
- return 1 if all buttons are pressed, 2 if button are partially pressed and 0 if buttons aren't pressed. it works like playerkeys()
ex. playerkeys_multi(0, 0, "attack+jump") returns 1 if player 1 hold
attack+jump+special together
and it returns 2 is player 1 hold only attack or jump. It accepts also more
then two buttons like: "attack+jump+special"
int get_hold_time(int p, char key)
- returns the hold button time.
ex. get_hold_time(0, "attack") returns the hold button time for player 1.
int is_multi_hold_pressed(int p, char btn1, char btn2, char btn3, ...)
- returns 1 if more than one button is pressed, it returns 0 else.
ex. is_multi_hold_pressed(0,"attack","jump") returns 1 if the player 1 holds attack and jump button togheter
...and a function to retrieve an impulse every a CUSTOM ETA while you hold a button (use it in a script or ondrawscript event and not keyall.c):
Code:
/* PARAMS:
* player_index: player index (ex 0,1,2,3)
* key: pressed key string (ex. "moveleft", "move right", etc..)
* time_range: time between 2 key impulses
* start_press_flag: 1 == press the first time too, 0 == no first time key press
* start_time_eta: wait time after the first key press (time between 1st and 2nd impulse)
*/
int hold_key_press(int player_index, char key, float time_range, int start_press_flag, float start_time_eta) {
if ( playerkeys(player_index,0,key) ) {
int time = openborvariant("elapsed_time");
int game_speed = openborvariant("game_speed");
//drawstring(0,20,0,"TEST KEY: "+playerkeys(player_index,0,key));
if ( time_range == NULL() ) time_range = 0;
if ( start_time_eta == NULL() ) start_time_eta = 0;
time_range *= game_speed;
start_time_eta *= game_speed;
if ( getlocalvar("hold_time"+key+player_index) == NULL() ) {
setlocalvar("hold_time"+key+player_index,time);
if ( start_press_flag > 0 && getlocalvar("first_keypress"+key+player_index) == NULL() ) {
setlocalvar("first_keypress"+key+player_index,1);
return playerkeys(player_index,0,key);
}
} else if ( time-getlocalvar("hold_time"+key+player_index) >= time_range ) {
//drawstring(0,30,0,"OK!");
if ( start_time_eta > 0 && getlocalvar("second_keypress"+key+player_index) == NULL() ) {
if ( time-getlocalvar("hold_time"+key+player_index) < start_time_eta ) return 0;
}
// simulate hold press
if ( getlocalvar("second_keypress"+key+player_index) == NULL() ) setlocalvar("second_keypress"+key+player_index,1);
setlocalvar("hold_time"+key+player_index,NULL());
return playerkeys(player_index,0,key);
}
} else {
if ( getlocalvar("hold_time"+key+player_index) ) setlocalvar("hold_time"+key+player_index,NULL());
if ( getlocalvar("first_keypress"+key+player_index) ) setlocalvar("first_keypress"+key+player_index,NULL());
if ( getlocalvar("second_keypress"+key+player_index) ) setlocalvar("second_keypress"+key+player_index,NULL());
}
return 0;
}
example:
if ( hold_key_press(player_index,"moveright",0.08,1,0.2) == openborconstant("FLAG_MOVERIGHT") ) {
...
}