Advertisement
Guest User

Untitled

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