Advertisement
whiplk

[CODE] - Save Player Pos [spp]

Apr 19th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.57 KB | None | 0 0
  1. // Salvar posição do player, by Willian_Luigi idealizado por Inflamate.
  2.  
  3. //Inicializadores:
  4. new Float:wii_X[MAX_PLAYERS],
  5.     Float:wii_Y[MAX_PLAYERS],
  6.     Float:wii_Z[MAX_PLAYERS],
  7.     Float:wii_A[MAX_PLAYERS],
  8.     wii_Interior[MAX_PLAYERS],
  9.     wii_VW[MAX_PLAYERS];
  10.  
  11. // func_verify - Verifica se o arquivo do playerid 'k_' existe...
  12. stock func_verify(k_)
  13. {
  14.     new str[30];
  15.     format(str, 30, "%s", func_name(k_));
  16.  
  17.     if(INI_Exist(str))
  18.         return 1;
  19.  
  20.     return 0;
  21. }
  22. // func_salvar - Salva a posição do playerid 'k_' num arquivo com seu nome...
  23. stock func_salvar(k_)
  24. {
  25.     GetPlayerPos(k_, wii_X[k_], wii_Y[k_], wii_Z[k_]);
  26.     GetPlayerFacingAngle(k_, wii_A[k_]);
  27.     wii_Interior[k_] = GetPlayerInterior(k_);
  28.     wii_VW[k_] = GetPlayerVirtualWorld(k_);
  29.    
  30.     new str[30];
  31.     format(str, 30, "%s", func_name(k_));
  32.     INI_Open(str);
  33.     INI_WriteFloat("Pos x", wii_X[k_]);
  34.     INI_WriteFloat("Pos y", wii_Y[k_]);
  35.     INI_WriteFloat("Pos z", wii_Z[k_]);
  36.     INI_WriteFloat("Pos angle", wii_A[k_]);
  37.     INI_WriteInt("Interior", wii_Interior[k_]);
  38.     INI_WriteInt("Virtual World", wii_VW[k_]);
  39.     INI_Save();
  40.     INI_Close();
  41.     printf("Acc name: %s saved with success", str, k_);
  42.     return 1;
  43. }
  44. // func_carregar - Carrega a posição do playerid 'k_' para que possa re-utilizar tal pos...
  45. stock func_carregar(k_)
  46. {
  47.     new str[30]; //Float:x, Float:y, Float:z, Float:a, interior, virtualworld;
  48.     format(str, 30, "%s", func_name(k_));
  49.     INI_Open(str);
  50.     wii_X[k_] = INI_ReadFloat("Pos x");
  51.     wii_Y[k_] = INI_ReadFloat("Pos y");
  52.     wii_Z[k_] = INI_ReadFloat("Pos z");
  53.     wii_A[k_] = INI_ReadFloat("Pos angle");
  54.     wii_Interior[k_] = INI_ReadInt("Interior");
  55.     wii_VW[k_] = INI_ReadInt("Virtual World");
  56.     INI_Save();
  57.     INI_Close();
  58.  
  59.     if(wii_Interior[k_] > 0)
  60.         return SetPlayerInterior(k_, wii_Interior[k_]);
  61.     if(wii_VW[k_] > 0)
  62.         return SetPlayerVirtualWorld(k_, wii_VW[k_]);
  63.  
  64.     SetPlayerPos(k_, wii_X[k_], wii_Y[k_], wii_Z[k_]);
  65.     SetPlayerFacingAngle(k_, wii_A[k_]);
  66.     printf("Acc name: %s loaded with success id: %d", str, k_);
  67.     return 1;
  68. }
  69. // func_name - Pega o nome do playerid 'k_'
  70. stock func_name(k_)
  71. {
  72.     new str[30];
  73.     GetPlayerName(k_, str, MAX_PLAYER_NAME);
  74.     return str;
  75. }
  76.  
  77. //Exemplo de uso com script do zero by Willian_Luigi,
  78.  
  79. #include <a_samp>
  80. #include <SII>
  81. #include <savePos>
  82.  
  83. main() {}
  84.  
  85. public OnGameModeInit()
  86. {
  87.     AddPlayerClass(0,2033.9203,1343.9254,10.8203,269.2704,0,0,0,0,0,0); //
  88.  
  89.     print("It's successful running !");
  90.     return 1;
  91. }
  92. public OnPlayerSpawn(playerid)
  93. {
  94.     func_carregar(playerid);
  95.     return 1;
  96. }
  97.  
  98. public OnPlayerDisconnect(playerid)
  99. {
  100.     func_salvar(playerid);
  101.     return 1;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement