Chaoz

Object Face Player

Dec 19th, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.68 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new Info[MAX_PLAYERS][2];
  4. new Text:tInfo[MAX_PLAYERS];
  5.  
  6. public OnFilterScriptExit()
  7. {
  8.     for(new i, j=GetMaxPlayers(); i<j; i++)if(IsPlayerConnected(i)){
  9.          if(IsValidObject(Info[i][0]))DestroyObject(Info[i][0]);
  10.          TextDrawDestroy(tInfo[i]);
  11.     }
  12.     return 1;
  13. }
  14.  
  15. public OnPlayerCommandText(playerid, cmdtext[])
  16. {
  17.     if(!strcmp(cmdtext, "/start", true)){
  18.         new Float:P[3];
  19.         GetPlayerPos(playerid, P[0], P[1], P[2]);
  20.         Info[playerid][0] = CreateObject(18749, P[0]+5, P[1]+5, P[2], 0.0, 0.0, 0.0);
  21.         Info[playerid][1] = SetTimerEx("MovingObject", 10, true, "i", playerid);
  22.         tInfo[playerid] = TextDrawCreate(50.0, 430.0, "_");
  23.         TextDrawShowForPlayer(playerid, tInfo[playerid]);
  24.         return SendClientMessage(playerid, -1, "Start OK");
  25.     }
  26.     else if(!strcmp(cmdtext, "/stop", true)){
  27.         KillTimer(Info[playerid][1]);
  28.         DestroyObject(Info[playerid][0]);
  29.         TextDrawDestroy(tInfo[playerid]);
  30.         return SendClientMessage(playerid, -1, "Stop OK");
  31.     }
  32.     return 0;
  33. }
  34.  
  35. forward MovingObject(playerid);
  36. public MovingObject(playerid)
  37. {
  38.     new Float:pP[3];
  39.     GetPlayerPos(playerid, pP[0], pP[1], pP[2]);
  40.     if(!floatcmp(pP[0], 0.0) && !floatcmp(pP[1], 0.0))return 0;
  41.     new Float:oP[3], Float:result[2], str[128];
  42.     GetObjectPos(Info[playerid][0], oP[0], oP[1], oP[2]);
  43.     result[0] = atan2((pP[1]-oP[1]), (pP[0]-oP[0])) + 270;
  44.     result[1] = (result[0]>360) ? (result[0]-360) : (result[0]);
  45.     GetObjectRot(Info[playerid][0], oP[0], oP[1], oP[2]);
  46.     format(str, 128, "Angulo: %.4f  -  X: %.2f  -  Y: %.2f  -  resultO: %.4f", result[1], pP[0], pP[1], result[0]);
  47.     TextDrawSetString(tInfo[playerid], str);
  48.     return SetObjectRot(Info[playerid][0], oP[0], oP[1], result[1]);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment