Skip to content

Instantly share code, notes, and snippets.

@ziggi
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziggi/c38eac3837de1b203743 to your computer and use it in GitHub Desktop.
Save ziggi/c38eac3837de1b203743 to your computer and use it in GitHub Desktop.
GetCoordsBefore functions collection
stock GetCoordsBefore(Float:x, Float:y, Float:a, Float:distance, &Float:res_x, &Float:res_y)
{
res_x = x + (distance * floatsin(-a, degrees));
res_y = y + (distance * floatcos(-a, degrees));
}
stock GetCoordsBeforeNPC(npcid, Float:distance, &Float:x, &Float:y)
{
new Float:pos[4];
FCNPC_GetPosition(npcid, pos[0], pos[1], pos[2]);
pos[3] = FCNPC_GetAngle(npcid);
GetCoordsBefore(pos[0], pos[1], pos[3], distance, x, y);
}
stock GetCoordsBeforePlayer(playerid, Float:distance, &Float:x, &Float:y)
{
new Float:pos[4];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
GetCoordsBefore(pos[0], pos[1], pos[3], distance, x, y);
}
stock GetVehicleCoordsBeforePlayer(&Float:x, &Float:y, &Float:z, &Float:a, playerid, modelid = -1)
{
new Float:size[3];
if (modelid != -1) {
GetVehicleModelInfo(modelid, VEHICLE_MODEL_INFO_SIZE, size[0], size[1], size[2]);
} else {
size[0] = 1.5;
size[2] = 1.0;
}
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
GetCoordsBefore(x, y, a, size[0] + 0.5, x, y);
z -= size[2] * 0.25;
a += 90.0;
if (a > 360.0) {
a -= 360.0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment