17.11.2012, 09:59
(
Последний раз редактировалось RACGaming; 17.11.2012 в 10:34.
)
Hello.
i have problem with Register system, it makes server to crash, when I type my password.
My code:
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
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;
}
Kasutajad/parool means users/password
Sorry for my bad English