Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2012
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. MP2's camera system (hud-less)
  3. © MP2 2012
  4. */
  5.  
  6. /*
  7. native SetPlayerCamera(playerid, Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, sets=5);
  8. */
  9.  
  10. enum E_OPU_CAM_DATA
  11. {
  12.     Float:opu_cam_pos[3],
  13.     Float:opu_cam_look[3],
  14.     opu_cam_updates
  15. }
  16.  
  17. new OPU_CAM_DATA[MAX_PLAYERS][E_OPU_CAM_DATA];
  18.  
  19. public OnPlayerUpdate(playerid)
  20. {  
  21.     // OPU Cameras
  22.     if(OPU_CAM_DATA[playerid][opu_cam_updates] != 0) // Still updates to process
  23.     {
  24.         // Set the camera's position
  25.         SetPlayerCameraPos(playerid,
  26.         OPU_CAM_DATA[playerid][opu_cam_pos][0],
  27.         OPU_CAM_DATA[playerid][opu_cam_pos][1],
  28.         OPU_CAM_DATA[playerid][opu_cam_pos][2]);
  29.        
  30.         // Set the camera's 'lookat' point
  31.         SetPlayerCameraLookAt(playerid,
  32.         OPU_CAM_DATA[playerid][opu_cam_look][0],
  33.         OPU_CAM_DATA[playerid][opu_cam_look][1],
  34.         OPU_CAM_DATA[playerid][opu_cam_look][2]);
  35.  
  36.         OPU_CAM_DATA[playerid][opu_cam_updates]--; // We've processed one update
  37.     }
  38.     return CallLocalFunction("cam_OnPlayerUpdate", "i", playerid); // Hooking method
  39. }
  40. #if defined _ALS_OnPlayerUpdate
  41.     #undef OnPlayerUpdate
  42. #else
  43.     #define _ALS_OnPlayerUpdate
  44. #endif
  45. #define OnPlayerUpdate cam_OnPlayerUpdate
  46. forward cam_OnPlayerUpdate(playerid);
  47.  
  48. stock SetPlayerCamera(playerid, Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, sets=5)
  49. {
  50.     OPU_CAM_DATA[playerid][opu_cam_updates] = sets;
  51.     TogglePlayerSpectating(playerid, true);
  52.     OPU_CAM_DATA[playerid][opu_cam_pos][0] = x;
  53.     OPU_CAM_DATA[playerid][opu_cam_pos][1] = y;
  54.     OPU_CAM_DATA[playerid][opu_cam_pos][2] = z;
  55.     OPU_CAM_DATA[playerid][opu_cam_look][0] = x2;
  56.     OPU_CAM_DATA[playerid][opu_cam_look][1] = y2;
  57.     OPU_CAM_DATA[playerid][opu_cam_look][2] = z2;
  58.     return 1;
  59. }
  60.  
  61. stock x_SetCameraBehindPlayer(playerid)
  62. {
  63.     OPU_CAM_DATA[playerid][opu_cam_updates] = 0;
  64.     SetCameraBehindPlayer(playerid);
  65.     return 1;
  66. }
  67.  
  68. #if defined _ALS_SetCameraBehindPlayer
  69.     #undef SetCameraBehindPlayer
  70. #else
  71.     #define _ALS_SetCameraBehindPlayer
  72. #endif
  73. #define SetCameraBehindPlayer x_SetCameraBehindPlayer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement