04/11/2021 21:19
Código PHP:
#include <a_samp>
#include <streamer>
#include <zcmd>
#include <sscanf2>
new GPS_OBJ[MAX_PLAYERS];
new GPS_TIMER[MAX_PLAYERS];
stock Float:GetAbsoluteAngle(Float:angle)
{
while(angle < 0.0) {
angle += 360.0;
}
while(angle > 360.0) {
angle -= 360.0;
}
return angle-90;
}
stock Float:GetAngleToPoint(Float:fPointX, Float:fPointY, Float:fDestX, Float:fDestY)
{
return GetAbsoluteAngle(-(90.0-(atan2((fDestY - fPointY),(fDestX - fPointX)))));
}
forward ATTGPS(playerid);
public ATTGPS(playerid)
{
DestroyDynamicObject(GPS_OBJ[playerid]);
new Float:X = GetPVarFloat(playerid, "GPS:X");
new Float:Y = GetPVarFloat(playerid, "GPS:Y");
new Float:CurrentX, Float:CurrentY,Float:CurrentZ;
new Float:angle;
GetVehiclePos(GetPlayerVehicleID(playerid), CurrentX, CurrentY, CurrentZ);
angle = GetAngleToPoint(X, Y, CurrentX, CurrentY);
GPS_OBJ[playerid] = CreateDynamicObject(1318, CurrentX, CurrentY, CurrentZ, 0.0, 0.0, 0.0, 0, 0, playerid,-1.0);
MoveDynamicObject(GPS_OBJ[playerid], CurrentX, CurrentY,CurrentZ, 0.5, 1.0, -90.0, angle);
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsValidDynamicObject(GPS_OBJ[playerid]))
{
DestroyDynamicObject(GPS_OBJ[playerid]);
}
return 1;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
SetPVarInt(playerid, "OnClick", 1);
SetPVarFloat(playerid, "GPS:X", fX);
SetPVarFloat(playerid, "GPS:Y", fY);
return 1;
}
CMD:gps(playerid, params[])
{
if(GetPlayerVehicleSeat(playerid) == 0)
{
if(IsValidDynamicObject(GPS_OBJ[playerid]))
{
DestroyDynamicObject(GPS_OBJ[playerid]);
SendClientMessage(playerid, 0x00FF00FF, "| INFO | {FFFFFF}O GPS do seu veiculo foi desativado!");
KillTimer(GPS_TIMER[playerid]);
}
else
{
if(GetPVarInt(playerid, "OnClick") == 1)
{
GPS_TIMER[playerid] = SetTimerEx( "ATTGPS", 1000, true, "d", playerid);
SendClientMessage(playerid, 0x00FF00FF, "| INFO | {FFFFFF}O GPS do seu veiculo foi ativado!");
}
else SendClientMessage(playerid, 0xFF0000FF, "| GPS | {FFFFFF}Voce precisa marcar o local no GPS!");
}
}
else SendClientMessage(playerid, 0xFF0000FF, "| ERRO | {FFFFFF}Voce precisa estar dentro de um veiculo!");
return 1;
}