Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SA-MP Cameramoving
- *
- * (c) Copyright 20011-2012, RealGamer
- *
- */
- #include <a_samp>
- enum PlayerDaten
- {
- Timer,
- bool:CameraMoving,
- Float:Currx,
- Float:Curry,
- Float:Currz,
- Float:Destx,
- Float:Desty,
- Float:Destz,
- Float:DestLookx,
- Float:DestLooky,
- Float:DestLookz,
- Float:Speed
- }
- new PlayerInformations[MAX_PLAYERS][PlayerDaten];
- forward MovePlayerCamera(playerid,Float:destx,Float:desty,Float:destz,Float:lookx,Float:looky,Float:lookz,Float:speed);
- forward MoveCam(playerid);
- forward PauseCameraMoving(playerid);
- forward ContinueCameraMoving(playerid);
- forward OnCameraMoveFinish(playerid);
- forward OnCameraMovePause(playerid);
- forward OnCameraMoveContinue(playerid);
- forward IsCameraMoving(playerid);
- public OnPlayerConnect(playerid)
- {
- PlayerInformations[playerid][Timer]=SetTimerEx("MoveCam",100,1,"d",playerid);
- SendClientMessage(playerid,ROT,"YAY");
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect Camera_OnPlayerConnect
- public OnPlayerDisconnect(playerid, reason)
- {
- KillTimer(PlayerInformations[playerid][Timer]);
- PlayerInformations[playerid][CameraMoving] = false;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect Camera_OnPlayerDisconnect
- public MovePlayerCamera(playerid,Float:destx,Float:desty,Float:destz,Float:lookx,Float:looky,Float:lookz,Float:speed)
- {
- PlayerInformations[playerid][CameraMoving] = true;
- GetPlayerPos(playerid,PlayerInformations[playerid][Currx],PlayerInformations[playerid][Curry],PlayerInformations[playerid][Currz]);
- SetPlayerCameraPos(playerid,PlayerInformations[playerid][Currx],PlayerInformations[playerid][Curry],PlayerInformations[playerid][Currz]);
- PlayerInformations[playerid][Destx]=destx;
- PlayerInformations[playerid][Desty]=desty;
- PlayerInformations[playerid][Destz]=destz;
- PlayerInformations[playerid][DestLookx]=lookx;
- PlayerInformations[playerid][DestLooky]=looky;
- PlayerInformations[playerid][DestLookz]=lookz;
- PlayerInformations[playerid][Speed]=speed;
- return 1;
- }
- public PauseCameraMoving(playerid)
- {
- if(PlayerInformations[playerid][CameraMoving] == false) return 0;
- else
- {
- PlayerInformations[playerid][CameraMoving] = false;
- CallRemoteFunction("OnCameraMovePause","d",playerid);
- return 1;
- }
- }
- public IsCameraMoving(playerid)
- {
- if(!IsPlayerConnected(playerid)) return false;
- return PlayerInformations[playerid][CameraMoving];
- }
- public ContinueCameraMoving(playerid)
- {
- if(PlayerInformations[playerid][CameraMoving] == true) return 0;
- else
- {
- PlayerInformations[playerid][CameraMoving] = true;
- CallRemoteFunction("OnCameraMoveContinue","d",playerid);
- return 1;
- }
- }
- public MoveCam(playerid)
- {
- if(!IsPlayerConnected(playerid)) return PlayerInformations[playerid][CameraMoving] = false;
- if(PlayerInformations[playerid][CameraMoving] == true)
- {
- if (PlayerInformations[playerid][Currx] < PlayerInformations[playerid][Destx])PlayerInformations[playerid][Currx] += PlayerInformations[playerid][Speed];
- if (PlayerInformations[playerid][Curry] < PlayerInformations[playerid][Desty])PlayerInformations[playerid][Curry] += PlayerInformations[playerid][Speed];
- if (PlayerInformations[playerid][Currz] < PlayerInformations[playerid][Destz])PlayerInformations[playerid][Currz] += PlayerInformations[playerid][Speed];
- if (PlayerInformations[playerid][Currx] > PlayerInformations[playerid][Destx])PlayerInformations[playerid][Currx] -= PlayerInformations[playerid][Speed];
- if (PlayerInformations[playerid][Curry] > PlayerInformations[playerid][Desty])PlayerInformations[playerid][Curry] -= PlayerInformations[playerid][Speed];
- if (PlayerInformations[playerid][Currz] > PlayerInformations[playerid][Destz])PlayerInformations[playerid][Currz] -= PlayerInformations[playerid][Speed];
- if (PlayerInformations[playerid][Currx] < PlayerInformations[playerid][Destx] && (PlayerInformations[playerid][Currx]-PlayerInformations[playerid][Destx]) < -15.0)
- PlayerInformations[playerid][Currx] += 1;
- if (PlayerInformations[playerid][Curry] < PlayerInformations[playerid][Desty] && (PlayerInformations[playerid][Curry]-PlayerInformations[playerid][Desty]) < -15.0)
- PlayerInformations[playerid][Curry] += 1;
- if (PlayerInformations[playerid][Currz] < PlayerInformations[playerid][Destz] && (PlayerInformations[playerid][Currz]-PlayerInformations[playerid][Destz]) < -15.0)
- PlayerInformations[playerid][Currz] += 1;
- if (PlayerInformations[playerid][Currx] > PlayerInformations[playerid][Destx] && (PlayerInformations[playerid][Currx]-PlayerInformations[playerid][Destx]) < 15.0)
- PlayerInformations[playerid][Currx] -= 1;
- if (PlayerInformations[playerid][Curry] > PlayerInformations[playerid][Desty] && (PlayerInformations[playerid][Curry]-PlayerInformations[playerid][Desty]) < 15.0)
- PlayerInformations[playerid][Curry] -= 1;
- if (PlayerInformations[playerid][Currz] > PlayerInformations[playerid][Destz] && (PlayerInformations[playerid][Currz]-PlayerInformations[playerid][Destz]) < 15.0)
- PlayerInformations[playerid][Currz] -= 1;
- SetPlayerCameraPos(playerid,PlayerInformations[playerid][Currx],PlayerInformations[playerid][Curry],PlayerInformations[playerid][Currz]);
- SetPlayerCameraLookAt(playerid,PlayerInformations[playerid][DestLookx],PlayerInformations[playerid][DestLooky],PlayerInformations[playerid][DestLookz]);
- if (((PlayerInformations[playerid][Curry] > PlayerInformations[playerid][Desty] && (PlayerInformations[playerid][Curry] - PlayerInformations[playerid][Desty]) < 1.0)
- && (PlayerInformations[playerid][Currx] > PlayerInformations[playerid][Destx] && (PlayerInformations[playerid][Currx] - PlayerInformations[playerid][Destx] < 1.0))
- && PlayerInformations[playerid][Currz] > PlayerInformations[playerid][Destz] && (PlayerInformations[playerid][Currz] - PlayerInformations[playerid][Destz])< 1.0)
- ||(PlayerInformations[playerid][Desty] > PlayerInformations[playerid][Curry] && (PlayerInformations[playerid][Desty] - PlayerInformations[playerid][Curry])< 1.0
- && PlayerInformations[playerid][Destx] > PlayerInformations[playerid][Currx] && (PlayerInformations[playerid][Destx] - PlayerInformations[playerid][Currx])< 1.0
- && PlayerInformations[playerid][Destz] > PlayerInformations[playerid][Currz] && (PlayerInformations[playerid][Destz] - PlayerInformations[playerid][Currz])< 1.0))
- {
- PlayerInformations[playerid][CameraMoving] = false;
- CallRemoteFunction("OnCameraMoveFinish","d",playerid);
- KillTimer(PlayerInformations[playerid][Timer]);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement