Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.57 KB | None | 0 0
  1. /*  SA-MP Cameramoving
  2.  *
  3.  *  (c) Copyright 20011-2012, RealGamer
  4.  *
  5.  */
  6. #include <a_samp>
  7. enum PlayerDaten
  8. {
  9.     Timer,
  10.     bool:CameraMoving,
  11.     Float:Currx,
  12.     Float:Curry,
  13.     Float:Currz,
  14.     Float:Destx,
  15.     Float:Desty,
  16.     Float:Destz,
  17.     Float:DestLookx,
  18.     Float:DestLooky,
  19.     Float:DestLookz,
  20.     Float:Speed
  21. }
  22. new PlayerInformations[MAX_PLAYERS][PlayerDaten];
  23. forward MovePlayerCamera(playerid,Float:destx,Float:desty,Float:destz,Float:lookx,Float:looky,Float:lookz,Float:speed);
  24. forward MoveCam(playerid);
  25. forward PauseCameraMoving(playerid);
  26. forward ContinueCameraMoving(playerid);
  27. forward OnCameraMoveFinish(playerid);
  28. forward OnCameraMovePause(playerid);
  29. forward OnCameraMoveContinue(playerid);
  30. forward IsCameraMoving(playerid);
  31.  
  32.  
  33. public OnPlayerConnect(playerid)
  34. {
  35.     PlayerInformations[playerid][Timer]=SetTimerEx("MoveCam",100,1,"d",playerid);
  36.     SendClientMessage(playerid,ROT,"YAY");
  37. }
  38. #if defined _ALS_OnPlayerConnect
  39.     #undef OnPlayerConnect
  40. #else
  41.     #define _ALS_OnPlayerConnect
  42. #endif
  43. #define OnPlayerConnect Camera_OnPlayerConnect
  44. public OnPlayerDisconnect(playerid, reason)
  45. {
  46.     KillTimer(PlayerInformations[playerid][Timer]);
  47.     PlayerInformations[playerid][CameraMoving] = false;
  48. }
  49. #if defined _ALS_OnPlayerDisconnect
  50.     #undef OnPlayerDisconnect
  51. #else
  52.     #define _ALS_OnPlayerDisconnect
  53. #endif
  54. #define OnPlayerDisconnect Camera_OnPlayerDisconnect
  55. public MovePlayerCamera(playerid,Float:destx,Float:desty,Float:destz,Float:lookx,Float:looky,Float:lookz,Float:speed)
  56. {
  57.     PlayerInformations[playerid][CameraMoving] = true;
  58.     GetPlayerPos(playerid,PlayerInformations[playerid][Currx],PlayerInformations[playerid][Curry],PlayerInformations[playerid][Currz]);
  59.     SetPlayerCameraPos(playerid,PlayerInformations[playerid][Currx],PlayerInformations[playerid][Curry],PlayerInformations[playerid][Currz]);
  60.     PlayerInformations[playerid][Destx]=destx;
  61.     PlayerInformations[playerid][Desty]=desty;
  62.     PlayerInformations[playerid][Destz]=destz; 
  63.     PlayerInformations[playerid][DestLookx]=lookx;
  64.     PlayerInformations[playerid][DestLooky]=looky;
  65.     PlayerInformations[playerid][DestLookz]=lookz; 
  66.     PlayerInformations[playerid][Speed]=speed; 
  67.     return 1;
  68. }
  69. public PauseCameraMoving(playerid)
  70. {
  71.     if(PlayerInformations[playerid][CameraMoving] == false) return 0;
  72.     else
  73.     {
  74.         PlayerInformations[playerid][CameraMoving] = false;
  75.         CallRemoteFunction("OnCameraMovePause","d",playerid);
  76.         return 1;
  77.     }
  78. }
  79. public IsCameraMoving(playerid)
  80. {
  81.     if(!IsPlayerConnected(playerid)) return false;
  82.     return PlayerInformations[playerid][CameraMoving];
  83. }
  84. public ContinueCameraMoving(playerid)
  85. {
  86.     if(PlayerInformations[playerid][CameraMoving] == true) return 0;
  87.     else
  88.     {
  89.         PlayerInformations[playerid][CameraMoving] = true;
  90.         CallRemoteFunction("OnCameraMoveContinue","d",playerid);
  91.         return 1;
  92.     }
  93. }
  94. public MoveCam(playerid)
  95. {
  96.     if(!IsPlayerConnected(playerid)) return PlayerInformations[playerid][CameraMoving] = false;
  97.     if(PlayerInformations[playerid][CameraMoving] == true)
  98.     {
  99.         if (PlayerInformations[playerid][Currx] < PlayerInformations[playerid][Destx])PlayerInformations[playerid][Currx] += PlayerInformations[playerid][Speed];
  100.         if (PlayerInformations[playerid][Curry] < PlayerInformations[playerid][Desty])PlayerInformations[playerid][Curry] += PlayerInformations[playerid][Speed];
  101.         if (PlayerInformations[playerid][Currz] < PlayerInformations[playerid][Destz])PlayerInformations[playerid][Currz] += PlayerInformations[playerid][Speed];
  102.         if (PlayerInformations[playerid][Currx] > PlayerInformations[playerid][Destx])PlayerInformations[playerid][Currx] -= PlayerInformations[playerid][Speed];
  103.         if (PlayerInformations[playerid][Curry] > PlayerInformations[playerid][Desty])PlayerInformations[playerid][Curry] -= PlayerInformations[playerid][Speed];
  104.         if (PlayerInformations[playerid][Currz] > PlayerInformations[playerid][Destz])PlayerInformations[playerid][Currz] -= PlayerInformations[playerid][Speed];
  105.         if (PlayerInformations[playerid][Currx] < PlayerInformations[playerid][Destx] && (PlayerInformations[playerid][Currx]-PlayerInformations[playerid][Destx]) < -15.0)
  106.             PlayerInformations[playerid][Currx] += 1;
  107.         if (PlayerInformations[playerid][Curry] < PlayerInformations[playerid][Desty] && (PlayerInformations[playerid][Curry]-PlayerInformations[playerid][Desty]) < -15.0)
  108.             PlayerInformations[playerid][Curry] += 1;
  109.         if (PlayerInformations[playerid][Currz] < PlayerInformations[playerid][Destz] && (PlayerInformations[playerid][Currz]-PlayerInformations[playerid][Destz]) < -15.0)
  110.             PlayerInformations[playerid][Currz] += 1;
  111.         if (PlayerInformations[playerid][Currx] > PlayerInformations[playerid][Destx] && (PlayerInformations[playerid][Currx]-PlayerInformations[playerid][Destx]) < 15.0)
  112.             PlayerInformations[playerid][Currx] -= 1;
  113.         if (PlayerInformations[playerid][Curry] > PlayerInformations[playerid][Desty] && (PlayerInformations[playerid][Curry]-PlayerInformations[playerid][Desty]) < 15.0)
  114.             PlayerInformations[playerid][Curry] -= 1;
  115.         if (PlayerInformations[playerid][Currz] > PlayerInformations[playerid][Destz] && (PlayerInformations[playerid][Currz]-PlayerInformations[playerid][Destz]) < 15.0)
  116.             PlayerInformations[playerid][Currz] -= 1;
  117.         SetPlayerCameraPos(playerid,PlayerInformations[playerid][Currx],PlayerInformations[playerid][Curry],PlayerInformations[playerid][Currz]);
  118.         SetPlayerCameraLookAt(playerid,PlayerInformations[playerid][DestLookx],PlayerInformations[playerid][DestLooky],PlayerInformations[playerid][DestLookz]);
  119.         if (((PlayerInformations[playerid][Curry] > PlayerInformations[playerid][Desty] && (PlayerInformations[playerid][Curry] - PlayerInformations[playerid][Desty]) < 1.0)
  120.         && (PlayerInformations[playerid][Currx] > PlayerInformations[playerid][Destx] && (PlayerInformations[playerid][Currx] - PlayerInformations[playerid][Destx] < 1.0))
  121.         && PlayerInformations[playerid][Currz] > PlayerInformations[playerid][Destz] && (PlayerInformations[playerid][Currz] - PlayerInformations[playerid][Destz])< 1.0)
  122.         ||(PlayerInformations[playerid][Desty] > PlayerInformations[playerid][Curry] && (PlayerInformations[playerid][Desty] - PlayerInformations[playerid][Curry])< 1.0
  123.         && PlayerInformations[playerid][Destx] > PlayerInformations[playerid][Currx] && (PlayerInformations[playerid][Destx] - PlayerInformations[playerid][Currx])< 1.0
  124.         && PlayerInformations[playerid][Destz] > PlayerInformations[playerid][Currz] && (PlayerInformations[playerid][Destz] - PlayerInformations[playerid][Currz])< 1.0))
  125.         {
  126.             PlayerInformations[playerid][CameraMoving] = false;
  127.             CallRemoteFunction("OnCameraMoveFinish","d",playerid);
  128.             KillTimer(PlayerInformations[playerid][Timer]);
  129.         }
  130.     }
  131.     return 1;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement