Badyx

My Save(Guardar posiciones)

Feb 1st, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.62 KB | None | 0 0
  1. /*  Sistema para guardar las posiciones     */      /*      BadyX       */
  2.  
  3. /*
  4. [img]http://imageshack.us/a/img210/5773/posij.jpg[/img]
  5. [IMG]http://imageshack.us/a/img252/7053/posi2.jpg[/IMG]
  6. */
  7.  
  8. #include <a_samp>
  9.  
  10. new Float:CoordenadasX[MAX_PLAYERS];
  11. new Float:CoordenadasY[MAX_PLAYERS];
  12. new Float:CoordenadasZ[MAX_PLAYERS];
  13.  
  14. #if defined FILTERSCRIPT
  15.  
  16. #else
  17.  
  18. main(){}
  19. #endif
  20.  
  21. public OnPlayerCommandText(playerid, cmdtext[])
  22. {
  23.     new cmd[128];
  24.     new string[120];
  25.     new idx;
  26.     cmd = strtokex(cmdtext, idx);
  27.     if(strcmp(cmd, "/mysave", true) == 0)      /*      BadyX       */
  28.     {
  29.         if(IsPlayerConnected(playerid))
  30.         {
  31.             new length = strlen(cmdtext);
  32.             while ((idx < length) && (cmdtext[idx] <= ' '))
  33.             {
  34.                 idx++;
  35.             }
  36.             new offset = idx;
  37.             new result[128];
  38.             while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  39.             {
  40.                 result[idx - offset] = cmdtext[idx];
  41.                 idx++;
  42.             }
  43.             result[idx - offset] = EOS;
  44.             if(!strlen(result)) return  SendClientMessage(playerid, -1, "USO: /mysave [Nombre]");
  45.             GetPlayerPos(playerid, CoordenadasX[playerid],CoordenadasY[playerid],CoordenadasZ[playerid]);
  46.             format(string, sizeof(string), "(( %s ))    SetPlayerPos(playerid,%f,%f,%f);",result, CoordenadasX, CoordenadasY, CoordenadasZ);
  47.             PosicionesLog(string);
  48.             SendClientMessage(playerid, -1, # Posicion guardada);
  49.         }
  50.         return 1;
  51.     }
  52.    
  53.  
  54.     return 0;
  55. }
  56. forward  PosicionesLog(stringe[]);      /*      BadyX       */
  57. public PosicionesLog(stringe[])
  58. {
  59.     new entry[256];
  60.     format(entry, sizeof(entry), "%s\r\n",stringe);
  61.     new File:hFile;
  62.     hFile = fopen("Posiciones.ini", io_append);
  63.     fwrite(hFile, entry);
  64.     fclose(hFile);
  65. }
  66.  
  67. stock strtokex(const stringe[], &index)     /*      ¿?     */
  68. {
  69.     new length = strlen(stringe);
  70.     while ((index < length) && (stringe[index] <= ' '))
  71.     {
  72.         index++;
  73.     }
  74.  
  75.     new offset = index;
  76.     new result[20];
  77.     while ((index < length) && (stringe[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  78.     {
  79.         result[index - offset] = stringe[index];
  80.         index++;
  81.     }
  82.     result[index - offset] = EOS;
  83.     return result;
  84. }
  85.  
  86. //============================================================================//
  87. //                                                                            //
  88. //                           SI TE SIRVIO                                     //
  89. //                                                                            //
  90. //                     RESPETA EL TRABAJO DEL CREADOR                         //
  91. //                                                                            //
  92. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment