#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
new tempo[3];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new str[100];
if(PRESSED(KEY_YES))
{
tempo[0]++;
format(str,100,"PRESSED KEY_YES a %d",tempo[0]);
SendClientMessage(playerid, -1, str);
}
if(HOLDING(KEY_YES))
{
tempo[1]++;
format(str,100,"HOLDING KEY_YES a %d",tempo[1]);
SendClientMessage(playerid, -1, str);
}
if(RELEASED(KEY_YES))
{
tempo[2]++;
format(str,100,"RELEASED KEY_YES a %d",tempo[2]);
SendClientMessage(playerid, -1, str);
}
return 1;
}
if ((newkeys & KEY_YES) && !(oldkeys & KEY_YES))
{
tempo[0]++;
format(str,100,"PRESSED KEY_YES a %d",tempo[0]);
SendClientMessage(playerid, -1, str);
}
tenta ai :
PHP код:
|
public OnGameModeInit()
{
SetTimer("Opa", 1000, 1);
return 1;
}
new var;
forward Opa();
public Opa()
{
new Key[3];
GetPlayerKeys(0, Key[0], Key[1], Key[2]);
if(Key[0] == KEY_FIRE)
{
var ++;
new str[120];
format(str,120,"KEY_FIRE %d",var);
SendClientMessage(0, -1, str);
}
}
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(RELEASED(KEY_FIRE))
{
if(var)
{
new str[120];
format(str,120,"KEY_FIRE parou de apertar %d",var);
SendClientMessage(0, -1, str);
var = 0;
}
}
return 1;
}