16.06.2014, 22:09
The title is not self explanatory, but I didn't know what to say.
Well basically I'm trying to do a system that will show on the screen a red ball the direction of the guy that hit you. Though since I've had the idea I've been having problems with it, first at understanding how to do it and then in making it work, but let's cut the bullshit and go straight to the point.
I've made in the script to show the player info's about the shot and the coordinates on the screen to understand better what was going on and I got into some weird conclusions, the py and px does not follow some "rules" I've added:
As you can see in picture the angles in that box are always >180 && <=270 so supposedly the py should be negative and the px positive (because I set the angle from 0 to 90 so the floatcos and floatsin would return positive values). But as you can see only 1 follow that rule...
How come that these values seem random? They look random when moving (increasing/decreasing distance) and shooting but when standing and shooting you notice that all the variables stay the same, so this proves they're not random, but simply they're not right... I would love if someone could explain me what I've done wrong... I've tried so many different ways. If anyone knows a easier way please tell me.
Well basically I'm trying to do a system that will show on the screen a red ball the direction of the guy that hit you. Though since I've had the idea I've been having problems with it, first at understanding how to do it and then in making it work, but let's cut the bullshit and go straight to the point.
I've made in the script to show the player info's about the shot and the coordinates on the screen to understand better what was going on and I got into some weird conclusions, the py and px does not follow some "rules" I've added:
pawn Код:
new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, Float:AD, Float:angle, Float:px, Float:py, mess[280];
GetPlayerPos(playerid, x, y, z);
GetPlayerPos(damagedid, x2, y2, z2);
angle = atan2(x2-x,y2-y);
GetPlayerFacingAngle(damagedid, AD);
angle += AD;
if(angle >= 360)
angle -= 360.0;
if(angle >= 90.0 && angle < 180.0)
{
angle -= 90.0;
py = -(floatcos(angle)*200);
px = -(floatsin(angle)*200);
angle += 90.0;
}
else if(angle >= 180.0 && angle < 270.0)
{
angle -= 180.0;
py = -(floatcos(angle)*200);
px = (floatsin(angle)*200);
angle += 180.0;
}
else if(angle >= 270.0 && angle < 360.0)
{
angle -= 270.0;
py = (floatcos(angle)*200);
px = (floatsin(angle)*200);
angle += 270.0;
}
else
{
py = (floatcos(angle)*200);
px = -(floatsin(angle)*200);
}
format(mess, sizeof(mess), "Original Angle: %f AD: %f Angle:%f py:%f px:%f",atan2(x2-x,y2-y),AD,angle,py,px);
SendClientMessage(damagedid,White,mess);
How come that these values seem random? They look random when moving (increasing/decreasing distance) and shooting but when standing and shooting you notice that all the variables stay the same, so this proves they're not random, but simply they're not right... I would love if someone could explain me what I've done wrong... I've tried so many different ways. If anyone knows a easier way please tell me.