[AYUDA]Leer archivo[Solucionado] -
Jovanny - 04.07.2011
Bueno estoy haciendo un registro donde se guarden todos los nombres que entran al servidor
con esto guardo en el archivo cada nombre
pawn Код:
forward GuardarEnArchivo(filename[],text[]);
public GuardarEnArchivo(filename[],text[])
{
new File:archivo, filepath[256], string[256];
format(filepath,sizeof(filepath),"%s",filename);
archivo = fopen(filepath,io_append);
format(string,sizeof(string),"%s\r\n",text);
fwrite(archivo,string);
fclose(archivo);
return 1;
}
Como haria para saber si el nombre esta en el archivo?
NOTA:
Код:
No quiero usar ningun sistema de manejar archivos
Respuesta: [AYUDA]Leer archivo -
TheChaoz - 04.07.2011
no creo q sea lo mas efectivo pero es lo 1є q se me ocurrio
lee el archivo linea x linea hasta el final
mientras lees cada linea, chequeas si esta el nombre ahi con strfind
tambien podes cargar todo el archivo y chequear si esta o no el nomnre (si haces esto va a ser mejor no usar una linea x nick, si no separarlos x espacios o similar.
las dos son poco eficientes, realmente muy poco eficientes, asi q voy a pensar en otra cosa...
Respuesta: [AYUDA]Leer archivo -
Jovanny - 05.07.2011
encontre un ejemplo en la wiki
pawn Код:
public OnPlayerConnect(playerid)
{
new string[64]; // Create the string to store the read text in
new File:example = fopen("Startup.txt", io_read); // Open the file
while(fread(example, string)) //reads the file line-by-line
{
if(strcmp(string, "Ban", true) == 0) //if any of the lines in the file say "Ban" the system will ban the player
{
Ban(playerid); //bans the player
}
}
fclose(example);
return 1;
}
creo que servira
Respuesta: [AYUDA]Leer archivo -
K9- - 05.07.2011
https://sampwiki.blast.hk/wiki/File_Functions
https://sampwiki.blast.hk/wiki/Scripting...ons_Old#fmatch
Respuesta: [AYUDA]Leer archivo -
Jovanny - 05.07.2011
fmatch es antigua, fue removida
y el ejemplo no sirvio
Respuesta: [AYUDA]Leer archivo -
Jovanny - 05.07.2011
Cierren post, fue mas sencillo usar DjSon