05/09/2022 23:04
(Esta mensagem foi modificada pela última vez a: 05/09/2022 23:06 por White_Blue.)
Teste assim.
Código PHP:
// Global
new Float:posgps[3], Text3D:GPS[MAX_PLAYERS], timergps[MAX_PLAYERS];
CMD:marcargps(playerid, params[]) {
new Float:CorX, Float:CorY, Float:CorZ, str1[128], Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
if(sscanf(params, "p<,>fff", CorX, CorY, CorZ)) {
SendClientMessage(playerid, -1, "/marcargps [X, Y, Z]");
return 1;
}
posgps[0] = CorX;
posgps[1] = CorY;
posgps[2] = CorZ;
format(str1, sizeof(str1), "Você está a %0.1f metros de distância do seu destino!", GetDistanceBetweenPoints(posgps[0], posgps[1], posgps[2], pos[0], pos[1], pos[2]));
GPS[playerid] = CreateDynamic3DTextLabel(str1, -1, CorX, CorY, CorZ, 99999.0, .playerid = playerid, .streamdistance = 99999.0);
timergps[playerid] = SetTimerEx("AttGPS", 500, true, "d", playerid);
return 1;
}
forward AttGPS(playerid);
public AttGPS(playerid) {
new stratt[128], Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
if(IsValidDynamic3DTextLabel(GPS[playerid])) {
format(stratt, sizeof(stratt), "Você está a %0.1f metros de distância do seu destino!", GetDistanceBetweenPoints(posgps[0], posgps[1], posgps[2], pos[0], pos[1], pos[2]));
UpdateDynamic3DTextLabelText(GPS[playerid], -1, stratt);
if(GetDistanceBetweenPoints(posgps[0], posgps[1], posgps[2], pos[0], pos[1], pos[2]) < 5.0) {
DestroyDynamic3DTextLabel(GPS[playerid]);
SendClientMessage(playerid, Verde, "Você chegou ao seu destino!");
KillTimer(timergps[playerid]);
}
}
return 1;
}
Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ)
{
new Float:Distance; Distance = floatabs(floatsub(X, PointX))+floatabs(floatsub(Y, PointY))+floatabs(floatsub(Z, PointZ));
return Distance;
}
Não estou disponível para realizar serviços relacionados ao SA-MP e não costumo responder a mensagens privadas, a menos que estejam relacionadas à moderação do fórum.