#define FILTERSCRIPT #include #include #include #define COLOR_RED 0xAA3333AA #define COLOR_BLUE 0x0000BBAA #pragma tabsize 0 public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Heading Calculator Loaded"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/cmds", cmdtext, true, 10) == 0) { SendClientMessage(playerid, -1, "Commands: /heading [ID]"); // Do something here return 1; } return 0; } CMD:heading(playerid, params[]) { new id; if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "Usage: /heading [id]"); if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "The player you are trying to locate is not connected"); new float:pos1x; new float:pos1y; new float:pos2x; new float:pos2y; GetPlayerPos(id,pos2x,pos2y); GetPlayerPos(playerid,pos1x,pos1y); new x1; new y1; x1 = float(pos1x); y1 = float(pos1y); new x2; new y2; x2 = float(pos2x); y2 = float(pos2y); new heading; new alpha; new bravo; new charlie; new delta; bravo = y2 - y1; charlie = x2 - x1; delta = bravo / charlie; alpha = floattan(delta, degrees); new zulu[50]; if (x2 > x1) { if (y2 > y1) { heading = 90-alpha; format(zulu, sizeof(zulu), "Heading: ", float(heading)); return SendClientMessage(playerid, COLOR_BLUE, zulu); } if (y2 < y1) { new echo; echo = alpha*2; echo = alpha-echo; heading = 90+echo; format(zulu, sizeof(zulu), "Heading: ", float(heading)); return SendClientMessage(playerid, COLOR_BLUE, zulu); } return SendClientMessage(playerid, COLOR_RED, "Error 691"); } if (x2 < x1) { if (y2 < y1) { heading = 90-alpha; heading = 180+heading; format(zulu, sizeof(zulu), "Heading: ", float(heading)); return SendClientMessage(playerid, COLOR_BLUE, zulu); } if (y2 > y1) { new echo; echo = alpha*2; echo = alpha-echo; heading = 270+echo; format(zulu, sizeof(zulu), "Heading: ", float(heading)); return SendClientMessage(playerid, COLOR_BLUE, zulu); } return SendClientMessage(playerid, COLOR_RED, "Error 692"); } return SendClientMessage(playerid, COLOR_RED, "Error 690"); }