Guest User

PosGuardada

a guest
Apr 10th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.54 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3. #include <dini>
  4.  
  5. #define COLOR_ROJO 0xFF0000FF
  6. #define COLOR_VERDE_CLARO 0x00FF00FF
  7.  
  8. public OnPlayerCommandText(playerid, cmdtext[])
  9. {
  10.     new cmd[256], idx;
  11.     cmd = strtok(cmdtext, idx);
  12.    
  13.     if (strcmp("/guardarpos", cmd, true) == 0)
  14.     {
  15.         new usuario[MAX_PLAYER_NAME], archivo[256], Float:x, Float:y, Float:z, Float:angulo;
  16.         GetPlayerName(playerid, usuario, sizeof(usuario));
  17.         GetPlayerPos(playerid, Float:x, Float:y, Float:z);
  18.         GetPlayerFacingAngle(playerid, Float:angulo);
  19.         format(archivo, sizeof(archivo), "Pos/Usuarios/%s.ini", usuario);
  20.         dini_FloatSet(archivo, "PosGuardada(X)", Float:x);
  21.         dini_FloatSet(archivo, "PosGuardada(Y)", Float:y);
  22.         dini_FloatSet(archivo, "PosGuardada(Z)", Float:z);
  23.         dini_FloatSet(archivo, "PosGuardada(Angulo)", Float:angulo);
  24.         SendClientMessage(playerid, COLOR_VERDE_CLARO, "Posicion guardada exitosamente!");
  25.         PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
  26.         return 1;
  27.     }
  28.     if (strcmp("/cargarpos", cmd, true) == 0)
  29.     {
  30.         new vehiculo, usuario[MAX_PLAYER_NAME], archivo[256];
  31.         vehiculo = GetPlayerVehicleID(playerid);
  32.         GetPlayerName(playerid, usuario, sizeof(usuario));
  33.         format(archivo, sizeof(archivo), "Pos/Usuarios/%s.ini", usuario);
  34.         if (dini_Int(archivo, "PosGuardada(X)") == 0 || dini_Int(archivo, "PosGuardada(Y)") == 0 || dini_Int(archivo, "PosGuardada(Z)") == 0 || dini_Int(archivo, "PosGuardada(Angulo)") == 0) return SendClientMessage(playerid, COLOR_ROJO, "No has guardado ninguna posicion aun. Para guardar una, usa /guardarpos");
  35.         SetPlayerPos(playerid, dini_Int(archivo, "PosGuardada(X)"), dini_Int(archivo, "PosGuardada(Y)"), dini_Int(archivo, "PosGuardada(Z)")+1);
  36.         if(IsPlayerInAnyVehicle(playerid))
  37.         {
  38.             SetVehiclePos(vehiculo, dini_Int(archivo, "PosGuardada(X)"), dini_Int(archivo, "PosGuardada(Y)"), dini_Int(archivo, "PosGuardada(Z)")+1);
  39.             PutPlayerInVehicle(playerid, vehiculo, 0);
  40.         }
  41.         SetPlayerFacingAngle(playerid, dini_Int(archivo, "PosGuardada(Angulo)"));
  42.         SetCameraBehindPlayer(playerid);
  43.         SendClientMessage(playerid, COLOR_VERDE_CLARO, "Posicion cargada exitosamente!");
  44.         PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
  45.         return 1;
  46.     }
  47.     return 0;
  48. }
  49.  
  50. strtok(const string[], &index)
  51. {
  52.     new length = strlen(string);
  53.     while ((index < length) && (string[index] <= ' '))
  54.     {
  55.         index++;
  56.     }
  57.     new offset = index;
  58.     new result[20];
  59.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  60.     {
  61.         result[index - offset] = string[index];
  62.         index++;
  63.     }
  64.     result[index - offset] = EOS;
  65.     return result;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment