Coordintaes - 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: Coordintaes (
/showthread.php?tid=627525)
Coordintaes -
SamJust - 29.01.2017
So, the idea is to make and object appear right in front of a player's character, in the derection it is lokking. I've found a couple of mathematic formulas on the Net but the don't seem to work properly. So, how can I solve this problem?
Re: Coordintaes -
Hansrutger - 29.01.2017
Код:
getCoordsInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:Distance)
{
new
Float:r;
if(!IsPlayerInAnyVehicle(playerid)) {
GetPlayerFacingAngle(playerid,r);
}
else {
GetVehicleZAngle(GetPlayerVehicleID(playerid),r);
}
x += (Distance * floatsin(-r, degrees));
y += (Distance * floatcos(-r, degrees));
return 1;
}
Taken from literally the only result I got from ****** lmao xD
Anyhow use this to get coordinations in front of the player and then use CreateDynamicObject (highly suggeting you use this instead of CreateObject) and poof.
Re: Coordintaes -
SamJust - 29.01.2017
The formula I was using is pretty similar to this one. Apperetnly I messed it up somewhere.
Anyway, thanks for your help, it does work.