Advertisement
Nyft_

Salvar veículo na última posição ~Nyft

May 12th, 2021 (edited)
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.79 KB | None | 0 0
  1. #include a_samp
  2. #include dof2
  3. #include pawn.cmd
  4.  
  5. new pVehicleID[MAX_PLAYERS] = {INVALID_VEHICLE_ID, ...};
  6. new Float:pVehiclePos[MAX_PLAYERS][4];
  7.  
  8. main(){}
  9.  
  10. public OnGameModeExit()
  11. {
  12.     DOF2::Exit();
  13.     return 1;
  14. }
  15.  
  16. public OnPlayerStateChange(playerid, newstate, oldstate)
  17. {
  18.     switch(oldstate)
  19.     {
  20.         case PLAYER_STATE_DRIVER:
  21.         {
  22.             if(pVehicleID[playerid] != INVALID_VEHICLE_ID)
  23.             {
  24.                 new file[16 + MAX_PLAYER_NAME];
  25.                 format(file, sizeof(file), "Veículos/%s.ini", GetPlayerNameEx(playerid));
  26.  
  27.                 if(!DOF2::FileExists(file))
  28.                     DOF2::CreateFile(file);
  29.  
  30.                 GetVehiclePos(pVehicleID[playerid], pVehiclePos[playerid][0], pVehiclePos[playerid][1], pVehiclePos[playerid][2]);
  31.                 GetVehicleZAngle(pVehicleID[playerid], pVehiclePos[playerid][3]);
  32.                
  33.                 DestroyVehicle(pVehicleID[playerid]);
  34.                 pVehicleID[playerid] = CreateVehicle(560, pVehiclePos[playerid][0], pVehiclePos[playerid][1], pVehiclePos[playerid][2], pVehiclePos[playerid][3], -1, -1, -1);
  35.  
  36.                 DOF2::SetFloat(file, "X", pVehiclePos[playerid][0]);
  37.                 DOF2::SetFloat(file, "Y", pVehiclePos[playerid][1]);
  38.                 DOF2::SetFloat(file, "Z", pVehiclePos[playerid][2]);
  39.                 DOF2::SetFloat(file, "A", pVehiclePos[playerid][3]);
  40.                 DOF2::SaveFile();
  41.             }
  42.         }
  43.     }
  44.     return 1;
  45. }
  46.  
  47. GetPlayerNameEx(playerid)
  48. {
  49.     new name[MAX_PLAYER_NAME];
  50.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  51.     return name;
  52. }
  53.  
  54. CMD:v(playerid)
  55. {
  56.     GetPlayerPos(playerid, pVehiclePos[playerid][0], pVehiclePos[playerid][1], pVehiclePos[playerid][2]);
  57.     GetPlayerFacingAngle(playerid, pVehiclePos[playerid][3]);
  58.    
  59.     pVehicleID[playerid] = CreateVehicle(560, pVehiclePos[playerid][0], pVehiclePos[playerid][1], pVehiclePos[playerid][2], pVehiclePos[playerid][3], -1, -1, -1);
  60.     PutPlayerInVehicle(playerid, pVehicleID[playerid], 0);
  61.     return 1;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement