11.12.2010, 06:43
(
Последний раз редактировалось Miguel; 11.12.2010 в 23:30.
)
Si solo fuera esa variable, lo guardarнa en simple archivo de texto, asн:
Cuando el jugador se desconecta se guardan los datos, y cuando se conecta se cargan.
pawn Код:
public OnPlayerConnect(playerid)
{
new
File:input, // Variable como referencia al archivo abierto.
string[MAX_PLAYER_NAME + 4]; // Matriz para el nombre del jugador y el nombre del archivo.
GetPlayerName(playerid, string, sizeof(string)); // Obtenemos el nombre del jugador.
format(string, sizeof(string), "%s.txt", string); // Ponemos en una cadena de texto el nombre del jugador con la extenciуn del archivo.
input = fopen(string, io_read); // Abrimos y a la vez asignamos a la variable el archivo.
if(input != 0) // Si el archivo fuй abierto correctamente:
{
fread(input, string); // Leer el archivo y su contenido ponerlo en la cadena de texto "string".
Puntos[playerid] = strval(fread); // Convertimos el contenido de "string" en un valor numйrico.
fclose(input); // Cerramos el archivo.
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new
File:output,
string[MAX_PLAYER_NAME + 4];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "%s.txt", string);
output = fopen(string, io_write);
if(output != 0)
{
format(string, sizeof(string), "%i", Puntos[playerid]);
fwrite(output, string);
fclose(output);
}
return 1;
}