Advertisement
Guest User

/heading

a guest
Aug 30th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.44 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf2>
  6. #define COLOR_RED 0xAA3333AA
  7. #define COLOR_BLUE 0x0000BBAA
  8. #pragma tabsize 0
  9. public OnFilterScriptInit()
  10. {
  11.     print("\n--------------------------------------");
  12.     print(" Heading Calculator Loaded");
  13.     print("--------------------------------------\n");
  14.     return 1;
  15. }
  16.  
  17. public OnFilterScriptExit()
  18. {
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerCommandText(playerid, cmdtext[])
  23. {
  24.     if (strcmp("/cmds", cmdtext, true, 10) == 0)
  25.     {
  26.         SendClientMessage(playerid, -1, "Commands: /heading [ID]");
  27.         // Do something here
  28.         return 1;
  29.     }
  30.     return 0;
  31. }
  32.  
  33. CMD:heading(playerid, params[])
  34. {
  35.     new id;
  36.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "Usage: /heading [id]");
  37.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "The player you are trying to locate is not connected");
  38.     new float:pos1x;
  39.     new float:pos1y;
  40.     new float:pos2x;
  41.     new float:pos2y;
  42.     GetPlayerPos(id,pos2x,pos2y);
  43.     GetPlayerPos(playerid,pos1x,pos1y);
  44.     new x1;
  45.     new y1;
  46.     x1 = float(pos1x);
  47.     y1 = float(pos1y);
  48.     new x2;
  49.     new y2;
  50.     x2 = float(pos2x);
  51.     y2 = float(pos2y);
  52.     new heading;
  53.     new alpha;
  54.     new bravo;
  55.     new charlie;
  56.     new delta;
  57.     bravo = y2 - y1;
  58.     charlie = x2 - x1;
  59.     delta = bravo / charlie;
  60.     alpha = floattan(delta, degrees);
  61.     new zulu[50];
  62.     if (x2 > x1) {
  63.         if (y2 > y1) {
  64.             heading = 90-alpha;
  65.             format(zulu, sizeof(zulu), "Heading: ", float(heading));
  66.                 return SendClientMessage(playerid, COLOR_BLUE, zulu);
  67.         }
  68.         if (y2 < y1) {
  69.             new echo;
  70.             echo = alpha*2;
  71.             echo = alpha-echo;
  72.             heading = 90+echo;
  73.             format(zulu, sizeof(zulu), "Heading: ", float(heading));
  74.                 return SendClientMessage(playerid, COLOR_BLUE, zulu);
  75.         }
  76.             return SendClientMessage(playerid, COLOR_RED, "Error 691");
  77.     }
  78.     if (x2 < x1) {
  79.         if (y2 < y1) {
  80.             heading = 90-alpha;
  81.             heading = 180+heading;
  82.                 format(zulu, sizeof(zulu), "Heading: ", float(heading));
  83.                 return SendClientMessage(playerid, COLOR_BLUE, zulu);
  84.         }
  85.         if (y2 > y1) {
  86.             new echo;
  87.             echo = alpha*2;
  88.             echo = alpha-echo;
  89.             heading = 270+echo;
  90.             format(zulu, sizeof(zulu), "Heading: ", float(heading));
  91.                 return SendClientMessage(playerid, COLOR_BLUE, zulu);
  92.         }
  93.             return SendClientMessage(playerid, COLOR_RED, "Error 692");
  94.     }
  95.  
  96.     return SendClientMessage(playerid, COLOR_RED, "Error 690");
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement