Server crash on Register -
RACGaming - 17.11.2012
Hello.
i have problem with Register system, it makes server to crash, when I type my password.
My code:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Please Register", "Register", "Leave");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Enter you password to login", "Login", "Leave");
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if(!response)
{
SendClientMessage(playerid, COLOR_RED, "You need to login, to play here.");
Kick(playerid);
}
else
{
new name[MAX_PLAYER_NAME];
new file[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
new string[64];
new File:password = fopen(file, io_read);
while(fread(password, string))
{
if(strcmp(string, inputtext, true) == 0)
{
Login(playerid);
}
else{
SendClientMessage(playerid, COLOR_WHITE, "Wrong password!");
Kick(playerid);
}
}
fclose(password);
}
return 1;
}
else if(dialogid == DIALOG_REGISTER)
{
if(!response)
{
SendClientMessage(playerid, COLOR_RED, "You need to login to play here.");
SendClientMessage(playerid, COLOR_WHITE, "You don't have account jet, so make one first!");
Kick(playerid);
}
else
{
new name[MAX_PLAYER_NAME];
new file[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
new File:password = fopen(file, io_write);
if(password)
{
fwrite(password, inputtext);
fclose(password);
}
Register(playerid);
}
return 1;
}
return 0;
}
For me this code should take the dialog input and insert the text into /scriptfiles/kasutajad/parool/PlayerNameHere.ini file, but pressing the Register in dialog, crashes the server, Please help
Kasutajad/parool means users/password
Sorry for my bad English
AW: Server crash on Register -
Skimmer - 17.11.2012
Try change
to
Re: Server crash on Register -
RACGaming - 17.11.2012
Still, Crashes
Re: Server crash on Register -
Konstantinos - 17.11.2012
It depends. Use at the end of the callback
pawn Код:
return 0;
// if it's filterscript
pawn Код:
return 1;
// if it's gamemode
Comment this line
pawn Код:
Login(playerid);
// Like this, down
// Login(playerid);
and debug it.
Re: Server crash on Register -
RACGaming - 17.11.2012
Sends the player to Login step, so player can get the money and score, and return 1 still won't work
Re: Server crash on Register -
Konstantinos - 17.11.2012
When I said "debug it", I meant to use print & printf functions to see what it causes the crash.
Re: Server crash on Register -
RACGaming - 17.11.2012
Aam, my bad
Re: Server crash on Register -
RACGaming - 17.11.2012
It closes the server Window, and if I press Leave, then it crashes too
Re: Server crash on Register -
Konstantinos - 17.11.2012
Closing server window = crash.
Replace the callback with this one, change your samp name and register a new account. Then come here and post the server_log.txt (last part of the loaded file).
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if(!response)
{
SendClientMessage(playerid, COLOR_RED, "You need to login, to play here.");
Kick(playerid);
}
else
{
new name[MAX_PLAYER_NAME];
new file[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
new string[64];
new File:password = fopen(file, io_read);
while(fread(password, string))
{
if(strcmp(string, inputtext, true) == 0)
{
Login(playerid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Wrong password!");
Kick(playerid);
}
}
fclose(password);
}
return 1;
}
else if(dialogid == DIALOG_REGISTER)
{
if(!response)
{
SendClientMessage(playerid, COLOR_RED, "You need to login to play here.");
SendClientMessage(playerid, COLOR_WHITE, "You don't have account jet, so make one first!");
//Kick(playerid);
print( "DEBUG: Register - Kick(playerid);" );
}
else
{
new name[MAX_PLAYER_NAME];
new file[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "kasutajad/parool/%s.ini", name);
new File:password = fopen(file, io_write);
if(password)
{
fwrite(password, inputtext);
fclose(password);
}
//Register(playerid);
print( "DEBUG: Register(playerid);" );
}
return 1;
}
return 0;
}
Re: Server crash on Register -
Smally - 17.11.2012
Try running the server.exe as Admin, see if that helps more than likely a permissions error.