Advertisement
Swit_Cj

SaveAt.inc

Aug 16th, 2014
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.88 KB | None | 0 0
  1. /*     SA-MP [SaveAt.inc]
  2.  *     pawn(Marlon307)
  3.  *     Aproveite a include.
  4.  *     Duvidas opiniões palpites criticas para melhorar a include e só posta no forum
  5.  *     LINK:   forum.sa-mp.com/showthread.php?p=3163589#post3163589
  6.  */
  7.  
  8. #define PASTA_ACESSORIOS                          "/Acessorios/Acessorio_%s.ini"
  9. #define MAX_ATTCHP                                                             4
  10.  
  11. #if defined _SaveAt_included
  12.     #endinput
  13. #endif
  14. #define _SaveAt_included
  15. #pragma library SaveAt
  16.  
  17. /*native SaveAttacheplayer(playerid, varVip = 1, index,modelid, boneid,Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,Float:fRotX, Float:fRotY, Float:fRotZ,Float:fScaleX, Float:fScaleY, Float:fScaleZ);
  18. native LoadAttacheplayer(playerid, varVip = 1);
  19. native RemoveSlotAttached(playerid,index);*/
  20.  
  21. enum AtachhP
  22. {
  23.     bool:Used,
  24.     ModeloID,
  25.     BoneID,
  26.     Float:ApX,
  27.     Float:ApY,
  28.     Float:ApZ,
  29.     Float:ArX,
  30.     Float:ArY,
  31.     Float:ArZ,
  32.     Float:AeX,
  33.     Float:AeY,
  34.     Float:AeZ
  35. };
  36. new AttaCheP[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][AtachhP];
  37.  
  38. stock SaveAttacheplayer(playerid, varVip = 1, index,modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,Float:fRotX, Float:fRotY, Float:fRotZ,Float:fScaleX, Float:fScaleY, Float:fScaleZ)
  39. {
  40.     new aname[MAX_PLAYER_NAME], file[100], strText[15], slots;
  41.     GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
  42.     format(file, sizeof(file), PASTA_ACESSORIOS, aname);
  43.  
  44.     AttaCheP[playerid][index][Used] = true;
  45.     AttaCheP[playerid][index][ModeloID] = modelid;
  46.     AttaCheP[playerid][index][BoneID] = boneid;
  47.     AttaCheP[playerid][index][ApX] = fOffsetX;
  48.     AttaCheP[playerid][index][ApY] = fOffsetY;
  49.     AttaCheP[playerid][index][ApZ] = fOffsetZ;
  50.     AttaCheP[playerid][index][ArX] = fRotX;
  51.     AttaCheP[playerid][index][ArY] = fRotY;
  52.     AttaCheP[playerid][index][ArZ] = fRotZ;
  53.     AttaCheP[playerid][index][AeX] = fScaleX;
  54.     AttaCheP[playerid][index][AeY] = fScaleY;
  55.     AttaCheP[playerid][index][AeZ] = fScaleZ;
  56.  
  57.     SetPlayerAttachedObject(playerid,index,AttaCheP[playerid][index][ModeloID],
  58.     AttaCheP[playerid][index][BoneID], AttaCheP[playerid][index][ApX],
  59.     AttaCheP[playerid][index][ApY], AttaCheP[playerid][index][ApZ],
  60.     AttaCheP[playerid][index][ArX], AttaCheP[playerid][index][ArY],
  61.     AttaCheP[playerid][index][ArZ], AttaCheP[playerid][index][AeX],
  62.     AttaCheP[playerid][index][AeY], AttaCheP[playerid][index][AeZ]);
  63.  
  64.     if(!DOF2::FileExists(file)) DOF2::CreateFile(file);
  65.     {
  66.         if(varVip == 1)
  67.         slots = MAX_PLAYER_ATTACHED_OBJECTS;
  68.         else slots = MAX_ATTCHP;
  69.         for(new i; i < slots; i ++)
  70.         {
  71.             format(strText, 15, "%d_Used", i);
  72.             DOF2::SetInt(file, strText, _:AttaCheP[playerid][i][Used]);
  73.             format(strText, 15, "%d_Modelo", i);
  74.             DOF2::SetInt(file, strText, AttaCheP[playerid][i][ModeloID]);
  75.             format(strText, 15, "%d_Bone", i);
  76.             DOF2::SetInt(file, strText, AttaCheP[playerid][i][BoneID]);
  77.             format(strText, 15, "%d_ApX", i);
  78.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][ApX]);
  79.             format(strText, 15, "%d_ApY", i);
  80.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][ApY]);
  81.             format(strText, 15, "%d_ApZ", i);
  82.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][ApZ]);
  83.             format(strText, 15, "%d_ArX", i);
  84.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][ArX]);
  85.             format(strText, 15, "%d_ArY", i);
  86.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][ArY]);
  87.             format(strText, 15, "%d_ArZ", i);
  88.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][ArZ]);
  89.             format(strText, 15, "%d_AeX", i);
  90.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][AeX]);
  91.             format(strText, 15, "%d_AeY", i);
  92.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][AeY]);
  93.             format(strText, 15, "%d_AeZ", i);
  94.             DOF2::SetFloat(file, strText, AttaCheP[playerid][i][AeZ]);
  95.             DOF2::SaveFile();
  96.         }
  97.     }
  98.     return 1;
  99. }
  100.  
  101. stock LoadAttacheplayer(playerid, varVip = 1)
  102. {
  103.     new aname[MAX_PLAYER_NAME], file[100], strText[15], slots;
  104.     GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
  105.     format(file, sizeof(file), PASTA_ACESSORIOS, aname);
  106.     if(DOF2::FileExists(file))
  107.     {
  108.         if(varVip == 1)
  109.         slots = MAX_PLAYER_ATTACHED_OBJECTS;
  110.         else slots = MAX_ATTCHP;
  111.         for(new i; i < slots; i++)
  112.         {
  113.             format(strText, 15, "%d_Used", i);
  114.             AttaCheP[playerid][i][Used] = bool:DOF2::GetInt(file,strText);
  115.  
  116.             if(AttaCheP[playerid][i][Used] == true)
  117.             {
  118.                 format(strText, 15, "%d_Modelo", i);
  119.                 AttaCheP[playerid][i][ModeloID] = DOF2::GetInt(file,strText);
  120.                 format(strText, 15, "%d_Bone", i);
  121.                 AttaCheP[playerid][i][BoneID] = DOF2::GetInt(file,strText);
  122.                 format(strText, 15, "%d_ApX", i);
  123.                 AttaCheP[playerid][i][ApX] = DOF2::GetFloat(file,strText);
  124.                 format(strText, 15, "%d_ApY", i);
  125.                 AttaCheP[playerid][i][ApY] = DOF2::GetFloat(file,strText);
  126.                 format(strText, 15, "%d_ApZ", i);
  127.                 AttaCheP[playerid][i][ApZ] = DOF2::GetFloat(file,strText);
  128.                 format(strText, 15, "%d_ArX", i);
  129.                 AttaCheP[playerid][i][ArX] = DOF2::GetFloat(file,strText);
  130.                 format(strText, 15, "%d_ArY", i);
  131.                 AttaCheP[playerid][i][ArY] = DOF2::GetFloat(file,strText);
  132.                 format(strText, 15, "%d_ArZ", i);
  133.                 AttaCheP[playerid][i][ArZ] = DOF2::GetFloat(file,strText);
  134.                 format(strText, 15, "%d_AeX", i);
  135.                 AttaCheP[playerid][i][AeX] = DOF2::GetFloat(file,strText);
  136.                 format(strText, 15, "%d_AeY", i);
  137.                 AttaCheP[playerid][i][AeY] = DOF2::GetFloat(file,strText);
  138.                 format(strText, 15, "%d_AeZ", i);
  139.                 AttaCheP[playerid][i][AeZ] = DOF2::GetFloat(file,strText);
  140.  
  141.                 SetPlayerAttachedObject(playerid,i,AttaCheP[playerid][i][ModeloID],
  142.                 AttaCheP[playerid][i][BoneID], AttaCheP[playerid][i][ApX],
  143.                 AttaCheP[playerid][i][ApY], AttaCheP[playerid][i][ApZ],
  144.                 AttaCheP[playerid][i][ArX], AttaCheP[playerid][i][ArY],
  145.                 AttaCheP[playerid][i][ArZ], AttaCheP[playerid][i][AeX],
  146.                 AttaCheP[playerid][i][AeY], AttaCheP[playerid][i][AeZ]);
  147.             }
  148.         }
  149.     }else{
  150.         for(new i; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  151.         {
  152.             AttaCheP[playerid][i][Used] = false;
  153.             AttaCheP[playerid][i][ModeloID] = 0;
  154.             AttaCheP[playerid][i][BoneID] = 0;
  155.             AttaCheP[playerid][i][ApX] = 0;
  156.             AttaCheP[playerid][i][ApY] = 0;
  157.             AttaCheP[playerid][i][ApZ] = 0;
  158.             AttaCheP[playerid][i][ArX] = 0;
  159.             AttaCheP[playerid][i][ArY] = 0;
  160.             AttaCheP[playerid][i][ArZ] = 0;
  161.             AttaCheP[playerid][i][AeX] = 0;
  162.             AttaCheP[playerid][i][AeY] = 0;
  163.             AttaCheP[playerid][i][AeZ] = 0;
  164.         }
  165.     }
  166.     return 1;
  167. }
  168.  
  169. stock RemoveSlotAttached(playerid, index)
  170. {
  171.     new aname[MAX_PLAYER_NAME],file[40],strText[15];
  172.     GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
  173.     format(file, sizeof(file), PASTA_ACESSORIOS, aname);
  174.     if(DOF2::FileExists(file))
  175.     {
  176.         format(strText, 15, "%d_Used", index);
  177.         DOF2::SetInt(file, strText, false);
  178.         RemovePlayerAttachedObject(playerid, index);
  179.         DOF2::SaveFile();
  180.     }
  181.     return 1;
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement