[help] i can't fix this so it also works for negative values
#7

Quote:
Originally Posted by Marcel
Straight from pawn-lang.pdf:
Quote:
Originally Posted by pawn-lang.pdf
function with tag result used before definition, forcing
User-defined oper-
ators: 86
Forward declara-
tion: 82
reparse
When a function is “used” (invoked) before being declared, and
that function returns a value with a tag name, the parser must
make an extra pass over the source code, because the presence
of the tag name may change the interpretation of operators (in
the presence of user-defined operators). You can speed up the
parsing/compilation process by declaring the relevant functions
before using them.
thanks

@ [LDT]LuxurY:

The code is ready now
Код:
stock SetPlayerLookAt(playerid, Float:x, Float:y)
{
	new Float:Px, Float:Py, Float: Pa;
	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);
	SetPlayerFacingAngle(playerid, Pa);
}
ps i had to do
Pa = floatadd(Pa, 90.0);
you forgot that
it's because the angles in gta are 90° less (it's 90° rotated)
and why did you do
if (Pa >= 360.0) Pa = 0.0;
?
wtf if the value is higher than 360 it'll become 0°



another thing:
wiki is a little wrong here https://sampwiki.blast.hk/wiki/SetPlayerFacingAngle
it says:
Quote:

north (0)
|
(270)west- -east (90) (Good way to remember: Never Eat Shredded Wheat)
|
south (180)

but it should be:
Quote:

north (0)
|
(90)west- -east (270) (Good way to remember: Never Eat Shredded Wheat)
|
south (180)

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)