Force player to.. - 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: Force player to.. (
/showthread.php?tid=543301)
Force player to.. -
[rG]Cold - 25.10.2014
Hey!
I'm building a system and i need to force the player to face an object,in order for the system
to be 100% usable.
That is the only thing i need to do,force the player face the object that he's doing something to it.
Re: Force player to.. -
Steel_ - 25.10.2014
pawn Код:
SetPlayerPos and SetPlayerAngle
I did not fully understand the question, please explain more.
Re: Force player to.. -
[rG]Cold - 25.10.2014
So i have an object already created.
When i'm pressing a key,the system starts to work,something happens,a robbery.
I need the player to be facing the object while that happens.
Re: Force player to.. -
DerickClark - 25.10.2014
Show us the code.
Re: Force player to.. -
[rG]Cold - 25.10.2014
I don't know why i have to post my code since i only need to know how can i force the player to face an object
Re: Force player to.. -
Quickie - 26.10.2014
use trigonometry
pawn Код:
new Float:Ox,Float:Oy,Float:Oz,//objects coords
Float:Px,Float:Py,Float:Pz,Float:Pangle;
GetPlayerPos(playerid,Px,Py,Pz);
new Float:Hypotenuse=GetPlayerDistanceFromPoint(playerid,Ox,Oy,Oz);
new Float:Adjacent=floatadd(floatabs(Ox),(float(Px)*(-1)));
Pangle=acos(Adjacent/Hypotenuse)*(-1);
SetPlayerFacingAngle(playerid,Pangle);
SetPlayerControllable(playerid,1);
i didnt test the code but somehow atleast should give u an idea
Re: Force player to.. -
Abagail - 26.10.2014
Well, I've seen something like this. Maybe this could help you?
pawn Код:
stock SetPlayerFacingPlayer(playerid, facingid)
{
new Float:Px, Float:Py, Float: Pa;
new Float:x,Float:y,Float:z;
GetPlayerPos(facingid,x,y,z);
#pragma unused z
GetPlayerPos(playerid, Px, Py, Pa);
Pa = floatabs(atan((y-Py)/(x-Px)));
if (x <= Px && y >= Py) Pa = floatsub(180, Pa);
else if (x < Px && y < Py) Pa = floatadd(Pa, 180);
else if (x >= Px && y <= Py) Pa = floatsub(360.0, Pa);
Pa = floatsub(Pa, 90.0);
if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
return SetPlayerFacingAngle(playerid, Pa);
}
Source:
https://sampforum.blast.hk/showthread.php?tid=69892