RE: Como detectar se o player se moveu - Lightz/Conta nova - 01/09/2021
(01/09/2021 01:55)xbruno1000x Escreveu: (31/08/2021 17:53)Lightz/Conta nova Escreveu: (31/08/2021 17:21)Um cara ai Escreveu: Na verdade... Basta verificar se alguma das keys (KEY_UP / KEY_DOWN / KEY_RIGHT / KEY_LEFT) foi pressionada, seja usando GetPlayerKeys ou OnPlayerChangeKeyState
Ahh! kkkkkk lembrei kkkk, vo fazer e mandar pra ele aqui
(31/08/2021 17:53)Lightz/Conta nova Escreveu: (31/08/2021 17:21)Um cara ai Escreveu: Na verdade... Basta verificar se alguma das keys (KEY_UP / KEY_DOWN / KEY_RIGHT / KEY_LEFT) foi pressionada, seja usando GetPlayerKeys ou OnPlayerChangeKeyState
Ahh! kkkkkk lembrei kkkk, vo fazer e mandar pra ele aqui
Ai meu mano LilPreto tá funcionando de boa agora:
EDIT: Agora sim comando tá funcionando 100%.
Código PHP: new Float:PosSpawn[MAX_PLAYERS][3]; new bool: TimerSpawnKill; new SpawnKillTimer[MAX_PLAYERS];
public OnPlayerSpawn(playerid) { SetPlayerHealth(playerid, 999999); SendClientMessage(playerid, -1, "Você está protegido contra Spawn Kill até se mover."); GetPlayerPos(playerid, PosSpawn[playerid][0], PosSpawn[playerid][1], PosSpawn[playerid][2]); SpawnKillTimer[playerid] = SetTimerEx("EndAntiSpawnKill", 8000, true, "iiii", playerid, PosSpawn[playerid][0], PosSpawn[playerid][1], PosSpawn[playerid][2]); TimerSpawnKill = true; return 1; }
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if (newkeys == KEY_JUMP) { if(TimerSpawnKill == true) { SetPlayerHealth(playerid, 100); SendClientMessage(playerid, -1, "Você se movimentou e o Spawn Kill acabou."); KillTimer(SpawnKillTimer[playerid]); } } return 1; }
forward EndAntiSpawnKill(playerid, X, Y, Z); public EndAntiSpawnKill(playerid, X, Y, Z) { SetPlayerHealth(playerid, 100); SendClientMessage(playerid, -1, "Você não está mais protegido contra Spawn Kill"); KillTimer(SpawnKillTimer[playerid]); return 1; }
esse código vai parar em 8 segundos, não ao mover-se. Além disso, a tecla KEY_JUMP é o shift, e sendo assim o spawn protect irá ser encerrada somente ao pular.
"Esse código vai parar em 8 segundos, não ao mover-se." Ué aqui funcionou muito bem, timer começou apertei a tecla W (UP) e o timer finalizou, eu botei um tempo de 8 segundos porque é tipo o ideal tipo, 1 segundo não faz sentido.
"Além disso, a tecla KEY_JUMP é o shift, e sendo assim o spawn protect irá ser encerrada somente ao pular." Corrigido!
RE: Como detectar se o player se moveu - ProKillerPa - 03/09/2021
Cara, é bem simples.
Quando o player spawna, voce armazena em uma variavel global com MAX_PLAYERS, as posicoes X Y Z do jogador.
Aí voce pode utilizar um TimerEx de 1seg, ou até mesmo na onplayerupdate, se o player não está na mesma posicao, e aí acabar a proteção, assim:
![[Imagem: kkk.png]](https://i.ibb.co/nMZRhwY/kkk.png)
OBS: Faltou setar a vida e etc, é só pra você ter a ideia geral, não é o codigo pronto.
RE: Como detectar se o player se moveu - Um cara ai - 04/09/2021
Fiz um aqui bem funcional:
Citar:new bool:SafeSpawn[MAX_PLAYERS] = false;
public OnPlayerSpawn(playerid)
{
SafeSpawn[playerid] = true;
SetPlayerHealth(playerid, 999999);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(SafeSpawn[playerid] && IntCmp(newkeys, -128, 32, 128))
{
SafeSpawn[playerid] = false;
SetPlayerHealth(playerid, 100.0);
GivePlayerWeapon(playerid, 30, 30);
}
return 1;
}
stock IntCmp(value, ...)
{
new args = numargs();
for(new i; i < args; i++)
{
if(key == getarg(i)) return 1;
}
return 0;
}
|