Portal SAMP
[Ajuda] Como detectar se o player se moveu - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Como detectar se o player se moveu (/showthread.php?tid=1582)

Páginas: 1 2 3


Como detectar se o player se moveu - lilpretovisk - 30/08/2021

Boa noite a todos, gostaria de saber se existe essa funcao no samp em si, ou seria uma plugin/include, estou querendo adaptar a meu sistema de anti spawn kill, que, o player nascendo com protecao contra kill, se ele se mover, acabaria a protecao.


RE: Como detectar se o player se moveu - SrBlue - 30/08/2021

boa noite,
aqui no fórum já postaram um sistema ( tutorial ), dava para adaptar para
detectar se o jogador se MOVER dentro do tempo retirar a proteção.

para pegar as coordenadas do jogador, tenta utilizar essa função
GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z);

resumidamente, basta fazer uma verificação ( loop ) se as coordenadas mudarem,
retirar a proteção.
[url=https://portalsamp.com/showthread.php?tid=1389][/url]


RE: Como detectar se o player se moveu - lilpretovisk - 30/08/2021

(30/08/2021 22:14)SrBlue Escreveu: boa noite,
aqui no fórum já postaram um sistema ( tutorial ), dava para adaptar para
detectar se o jogador se MOVER dentro do tempo retirar a proteção.

para pegar as coordenadas do jogador, tenta utilizar essa função
GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z);

resumidamente, basta fazer uma verificação ( loop ) se as coordenadas mudarem,
retirar a proteção.
[url=https://portalsamp.com/showthread.php?tid=1389][/url]

Muito obrigado pelo apoio. Andei olhando mas nao sei criar o loop. Voce poderia criar um codigo de exemplo puxando a coordenada e uma verificao se ela mudou? pra mim isso e um bixo de 7 cabecas =(


RE: Como detectar se o player se moveu - xbruno1000x - 30/08/2021

Sistema aqui do fórum com as alterações necessárias para encerrar proteção do spawn ao mover-se:
Código:
new TimerSpawnKill[MAX_PLAYERS];
new Float:PosSpawn[MAX_PLAYERS][3];

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]);
    TimerSpawnKill[playerid] = SetTimerEx("EndAntiSpawnKill", 1000, true, "iiii", playerid, PosSpawn[playerid][0], PosSpawn[playerid][1], PosSpawn[playerid][2]);
    return 1;
}

forward EndAntiSpawnKill(playerid, X, Y, Z);
public EndAntiSpawnKill(playerid, X, Y, Z)
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
    {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, -1, "Você não está mais protegido contra Spawn Kill");
        KillTimer(TimerSpawnKill[playerid]);
    }
    return 1;
}



RE: Como detectar se o player se moveu - SrBlue - 30/08/2021

(30/08/2021 22:57)xbruno1000x Escreveu: Sistema aqui do fórum com as alterações necessárias para encerrar proteção do spawn ao mover-se:
Código:
new TimerSpawnKill[MAX_PLAYERS];
new Float:PosSpawn[MAX_PLAYERS][3];

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]);
    TimerSpawnKill[playerid] = SetTimerEx("EndAntiSpawnKill", 1000, true, "iiii", playerid, PosSpawn[playerid][0], PosSpawn[playerid][1], PosSpawn[playerid][2]);
    return 1;
}

forward EndAntiSpawnKill(playerid, X, Y, Z);
public EndAntiSpawnKill(playerid, X, Y, Z)
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
    {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, -1, "Você não está mais protegido contra Spawn Kill");
        KillTimer(TimerSpawnKill[playerid]);
    }
    return 1;
}

Engenhoso!, utilizou o
Código:
IsPlayerInRangeOfPoint
logo eu quebrando a cabeça comparando x y z anterior com o futuro hahaha, NICE!


RE: Como detectar se o player se moveu - lilpretovisk - 30/08/2021

(30/08/2021 22:57)xbruno1000x Escreveu: Sistema aqui do fórum com as alterações necessárias para encerrar proteção do spawn ao mover-se:
Código:
new TimerSpawnKill[MAX_PLAYERS];
new Float:PosSpawn[MAX_PLAYERS][3];

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]);
    TimerSpawnKill[playerid] = SetTimerEx("EndAntiSpawnKill", 1000, true, "iiii", playerid, PosSpawn[playerid][0], PosSpawn[playerid][1], PosSpawn[playerid][2]);
    return 1;
}

forward EndAntiSpawnKill(playerid, X, Y, Z);
public EndAntiSpawnKill(playerid, X, Y, Z)
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
    {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, -1, "Você não está mais protegido contra Spawn Kill");
        KillTimer(TimerSpawnKill[playerid]);
    }
    return 1;
}

voces sao brabos, tmj rapaziada !!


RE: Como detectar se o player se moveu - lilpretovisk - 31/08/2021

(30/08/2021 22:57)xbruno1000x Escreveu: Sistema aqui do fórum com as alterações necessárias para encerrar proteção do spawn ao mover-se:
Código:
new TimerSpawnKill[MAX_PLAYERS];
new Float:PosSpawn[MAX_PLAYERS][3];

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]);
    TimerSpawnKill[playerid] = SetTimerEx("EndAntiSpawnKill", 1000, true, "iiii", playerid, PosSpawn[playerid][0], PosSpawn[playerid][1], PosSpawn[playerid][2]);
    return 1;
}

forward EndAntiSpawnKill(playerid, X, Y, Z);
public EndAntiSpawnKill(playerid, X, Y, Z)
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
    {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, -1, "Você não está mais protegido contra Spawn Kill");
        KillTimer(TimerSpawnKill[playerid]);
    }
    return 1;
}
testei na pratica e nao funcionou, onde estaria o erro sera? estou analisando... me movi e nao esta contabilizando


RE: Como detectar se o player se moveu - xbruno1000x - 31/08/2021

O que aconteceu é que eu fiz o código enquanto estava em aula e não prestei atenção a todos os detalhes kkkkkkkkkkkkk

Código:
if(!IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))

Eu errei o operador da if, o código seria lido em caso do jogador estar dentro da posição do spawn, quando na verdade precisamos que o código seja lido quando ele não estiver. Basta mudar o operador como fiz acima e tudo funcionará corretamente.


RE: Como detectar se o player se moveu - lilpretovisk - 31/08/2021

(31/08/2021 01:21)xbruno1000x Escreveu: O que aconteceu é que eu fiz o código enquanto estava em aula e não prestei atenção a todos os detalhes kkkkkkkkkkkkk

Código:
if(!IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))

Eu errei o operador da if, o código seria lido em caso do jogador estar dentro da posição do spawn, quando na verdade precisamos que o código seja lido quando ele não estiver. Basta mudar o operador como fiz acima e tudo funcionará corretamente.

o problema agora que menos parado esta contabilizando que se mexeu, tentei mudar os valores das coordenadas e nao resolveu


RE: Como detectar se o player se moveu - Lightz/Conta nova - 31/08/2021

(31/08/2021 01:34)lilpretovisk Escreveu:
(31/08/2021 01:21)xbruno1000x Escreveu: O que aconteceu é que eu fiz o código enquanto estava em aula e não prestei atenção a todos os detalhes kkkkkkkkkkkkk

Código:
if(!IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))

Eu errei o operador da if, o código seria lido em caso do jogador estar dentro da posição do spawn, quando na verdade precisamos que o código seja lido quando ele não estiver. Basta mudar o operador como fiz acima e tudo funcionará corretamente.

o problema agora que menos parado esta contabilizando que se mexeu, tentei mudar os valores das coordenadas e nao resolveu

Irei mandar uma base ai você tenta adaptar, se não conseguir fala ai que nois da um jeito

Código PHP:
new Float:AFKPos[MAX_PLAYERS][6];

OnPlayerConnect(playerid)
{
    
SetTimerEx("VerificarAFK"10*60*10001"i"playerid); 
    return 
1;
}

forward VerificarAfk(playerid);
public 
VerificarAfk(playerid)
{
   
GetPlayerPos(playeridAFKPos[playerid][0], AFKPos[playerid][1], AFKPos[playerid][2]);
   if(
AFKPos[playerid][0] == AFKPos[playerid][3] && AFKPos[playerid][1] == AFKPos[playerid][4] && AFKPos[playerid][2] ==        AFKPos[playerid][5])
 {
     new 
PlayerName[MAX_PLAYER_NAME];
     new 
String[100];
     
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
     
format(Stringsizeof(String), "%s Ficou Ausente Automaticamente."PlayerName);
     
SendClientMessageToAll(-1String);
     
//Preguiça de colocar funções do comando afk
     
AFKPos[playerid][3] = AFKPos[playerid][0];
     
AFKPos[playerid][4] = AFKPos[playerid][1];
     
AFKPos[playerid][5] = AFKPos[playerid][2];
     return 
1;