Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock Float:GetPlayerTheoreticAngle(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:sin, Float:dis;
- new Float:x, Float:y, Float:z, Float:angle;
- new Float:xoffset, Float:yoffset, Float:aoffset;
- GetPlayerPos(playerid, x, y, z);
- dis += (x - ppos[playerid][0]) * (x - ppos[playerid][0]);
- dis += (y - ppos[playerid][1]) * (y - ppos[playerid][1]);
- dis = floatsqroot(dis);
- angle = ReturnPlayerAngle(playerid);
- xoffset = x > ppos[playerid][0] ? x - ppos[playerid][0] : ppos[playerid][0] - x;
- yoffset = y > ppos[playerid][1] ? y - ppos[playerid][1] : ppos[playerid][1] - y;
- if(ppos[playerid][1] > y && ppos[playerid][0] > x)
- {
- sin = asin(xoffset / dis);
- aoffset = ((sin + 90) - (sin * 2)) - (-90);
- }
- if(ppos[playerid][1] < y && ppos[playerid][0] > x)
- {
- sin = asin(xoffset / dis);
- aoffset = (sin + 180) - 180;
- }
- if(ppos[playerid][1] < y && ppos[playerid][0] < x)
- {
- sin = acos(yoffset / dis);
- aoffset = (sin + 360) - (sin * 2);
- }
- if(ppos[playerid][1] > y && ppos[playerid][0] < x)
- {
- sin = asin(xoffset / dis);
- aoffset = sin + 180;
- }
- return aoffset == 0 ? angle : aoffset;
- }
- return 0.0;
- }
Add Comment
Please, Sign In to add comment