02.03.2017, 17:43
Quote:
Boa ideia usar uma progress bar pra mostrar pros players, mas meu problema й com a forma de detectar se o player ta correndo...
Tentei seguir o que vc me falou: Код:
if(HOLDING(KEY_SPRINT) && HOLDING(KEY_UP) || HOLDING(KEY_SPRINT) && HOLDING(KEY_DOWN) || HOLDING(KEY_SPRINT) && HOLDING(KEY_LEFT) || HOLDING(KEY_SPRINT) && HOLDING(KEY_RIGHT)) { if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { Correndo[playerid] = true; } } else { Correndo[playerid] = false; } |
As Key DOWN, UP, LEFT, RIGHT sгo as setas e tem de ser detetadas no OnPlayerUpdate ou com um timer , exemplo:
https://sampwiki.blast.hk/wiki/GetPlayerKeys
PHP код:
public OnPlayerUpdate(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(ud == KEY_UP) SendClientMessage(playerid, -1, "UP");
else if(ud == KEY_DOWN) SendClientMessage(playerid, -1, "DOWN");
if(lr == KEY_LEFT) SendClientMessage(playerid, -1, "LEFT");
else if(lr == KEY_RIGHT) SendClientMessage(playerid, -1, "RIGHT");
return 1;
}
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
"Directional keys do not trigger OnPlayerKeyStateChange (up/down/left/right). They can only be detected with GetPlayerKeys (in OnPlayerUpdate or a timer)."
Um dica para a barra de espaзo (sprint):
PHP код:
if(HOLDING(KEY_SPRINT) || PRESSING(newkeys, KEY_SPRINT ))
{
//QUANDO PRESSIONA BARRA DE ESPAЗO PARA CORRER
}
if(RELEASED(KEY_SPRINT))
{
//QUANDO LIBERTA A BARRA DE ESPAЗO PARA PARAR DE CORRER
}
PHP код:
public OnPlayerUpdate(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(ud != 0 || ud != 0 || lr != 0 || lr != 0)
{
if(Correndo[playerid] == false)
{
if(!IsPlayerInAnyVehicle(playerid))
{
//QUANDO SE MOVE NAS SETAS
Andando[playerid] = true;
}
}
}
else
{
if(Correndo[playerid] == true)
{
if(!IsPlayerInAnyVehicle(playerid))
{
//QUANDO DEIXA DE PRESSIONAR AS SETAS
Andando[playerid] = false;
}
}
}
return 1;
}