How to get offset from vehicle? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to get offset from vehicle? (
/showthread.php?tid=657206)
How to get offset from vehicle? -
R3SpaWn0 - 03.08.2018
Hi..the problem is that when i join in server, me and the car are in the same coords, how can i get the player or car little offset at the X or Y? Thanks..
This is the problem
https://imgur.com/a/0QJfJGU
Re: How to get offset from vehicle? -
GRiMMREAPER - 03.08.2018
You don't need to create another thread as I would've replied
here.
If you want to add an offset, get the
x coordinate of the player's spawn point and add/subtract a number to it (like +3 or -3).
Re: How to get offset from vehicle? -
Lokii - 03.08.2018
You can use this function from vspawner:
PHP код:
SpawnVehicle_InfrontOfPlayer(playerid, vehiclemodel, color1, color2)
{
new Float:x,Float:y,Float:z;
new Float:facing;
new Float:distance;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, facing);
new Float:size_x,Float:size_y,Float:size_z;
GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
distance = size_x + 0.5;
x += (distance * floatsin(-facing, degrees));
y += (distance * floatcos(-facing, degrees));
facing += 90.0;
if(facing > 360.0) facing -= 360.0;
return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
}
example:
PHP код:
CMD:v(playerid, params[])
{
SpawnVehicle_InfrontOfPlayer(playerid, strval(params), -1, -1);
return 1;
}
Re: How to get offset from vehicle? -
R3SpaWn0 - 03.08.2018
Thank you all, i will try it now ґ!!