Como cerrar este codigo?
#1

Bueno nunca me salen bien los login/register systems hasi que los copeo xD bueno encontre uno que me funciona solo que tiene 1 error que creo que es simple y lo quiero arreglas, aqui esta...
Код:
C:\Users\Anonymous\Desktop\GM.pwn(344) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
y el codigo es este...
Код:
WritePlayer(text[],playerid, bool:filestart)
{
 new string[256],name[MAX_PLAYER_NAME];
 new File:player;
 GetPlayerName(playerid,name,sizeof(name));
 format(string,256,"Players/%s.ini",name);
 player = fopen(string, io_append);
 if(filestart)
 {
  fwrite(player,text);
 }
 else
 {
  format(string,256,"\n%s",text);
  fwrite(player,string);
 }
 fclose(player);
  }
  return string;
}
la pregunta es їComo puedo cerrar este codigo correctamente?

Gracias!
Reply
#2

Pasa la Linea 344
Reply
#3

Quote:
Originally Posted by Dreyfuz
Посмотреть сообщение
Pasa la Linea 344
Код:
return string;
le puse ese "return" porque no se cual ahi que ponerle, y si lo quito sale esto...
Код:
C:\Users\Anonymous\Desktop\GM.pwn(344) : error 030: compound statement not closed at the end of file (started at line 328)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

pawn Код:
WritePlayer(text[],playerid, bool:filestart)
{
     new string[MAX_PLAYER_NAME+15];
     GetPlayerName(playerid,string,sizeof(string));
     format(string,sizeof(string),"Players/%s.ini",string);
     new File:player = fopen(string, io_append);
     if(!filestart) format(text,256,"\n%s",text);
     fclose((fwrite(player,text),player));
     //return text;
}
@Edit: Te modifique la funciуn un poco, no le veo posible utilidad a retornar la cadena de texto, sн lo necesitas para algo, desmarcalo del comentario.
Reply
#5

pawn Код:
WritePlayer(text[],playerid, bool:filestart)
{
 new string[256],name[MAX_PLAYER_NAME];
 new File:player;
 GetPlayerName(playerid,name,sizeof(name));
 format(string,256,"Players/%s.ini",name);
 player = fopen(string, io_append);
 if(filestart)
 {
  fwrite(player,text);
 }
 else
 {
  format(string,256,"\n%s",text);
  fwrite(player,string);
 }
 fclose(player);
  return string;
}
Te sobraba un '}'

Pruevalo Ahora y dime.
Reply
#6

pawn Код:
WritePlayer(const text[],playerid, bool:filestart)
{
  new string[256],name[MAX_PLAYER_NAME];
  new File:player;
  GetPlayerName(playerid,name,sizeof(name));
  format(string,256,"Players/%s.ini",name);
  player = fopen(string, io_append);
  if(filestart) fwrite(player,text);
  else format(string,256,"\n%s",text), fwrite(player,string);
  fclose(player);
  return string;
}
Reply
#7

Gracias a todos me funciono!
Reply
#8

EDIT: cuando me registro y entro, no lee la clave, y me hace crear una nueva cuenta denuevo. Me ayudan? este es el codigo que uso para leer las claves...
Quote:

ReadPlayer(line,playerid)
{
new string[256],name[MAX_PLAYER_NAME];
new Filelayer;
GetPlayerName(playerid,name,sizeof(name));
format(string,256,"Cuentas/%s.ini",name);
player = fopen(string, io_read);
for(new i=1; i<=line; i++)
{
fread(player,string);
if(line==i)
{fclose(player); return string;}
}
return string;
}

Gracias por todo.
Reply
#9

pawn Код:
ReadPlayer(line,playerid)
{
    new string[MAX_PLAYER_NAME<<4];
    GetPlayerName(playerid, string, sizeof(string));
    format(string,sizeof(string),"Cuentas/%s.ini",string);
    new File:player = fopen(string, io_read), iterator = 0;
    while(++iterator && fread(player, string))
    {
        if( iterator == line ) break;
        else continue;
    }
    return (fclose(player),string);
}
Reply
#10

Quote:
Originally Posted by WCrimson
Посмотреть сообщение
pawn Код:
ReadPlayer(line,playerid)
{
    new string[MAX_PLAYER_NAME<<4];
    GetPlayerName(playerid, string, sizeof(string));
    format(string,sizeof(string),"Cuentas/%s.ini",string);
    new File:player = fopen(string, io_read), iterator = 0;
    while(++iterator && fread(player, string))
    {
        if( iterator == line ) break;
        else continue;
    }
    return (fclose(player),string);
}
todavia no funciona, cuando me registro se guarda la clave, pero cuando entro denuevo me pide para registrarme de nuevo, y cuando la pongo denuevo, en el .ini se multiplica la clave.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)