22.11.2013, 06:08
Hello, I need your help. With help of this forum I created register and saving script, but it doesn't work properly. Register, login, saving works, everything works, but the problem is when I change money or score in player files and try to connect to the server my password is not correct, I didn't change that though. I don't know if I need to add sometging, delete something or just edit something. Here's my script:
On top of the gamemode:
OnPlayerConnect:
OnPlayerDisconnect:
OnDialogResponse:
On top of the gamemode:
Код:
#include <a_samp>
#include <dini>
#include <dudb>
#pragma unused ret_memcpy
#define PLAYERS "Ћaidėjai/%s.ini"
enum pInfo
{
pMoney,
pExperiencePoints,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new PlayerLogged[MAX_PLAYERS];
Код:
public OnPlayerConnect(playerid)
{
PlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), PLAYERS, name);
if(!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{ffffff}Registracija", "{ffffff}Prisiregistruokite, įvesdami slaptaћodį.", "Registruotis", "Iљeiti");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{ffffff}Prisijungimas", "{ffffff}Prisijunkite, įvesdami slaptaћodį.", "Prisijungti", "Iљeiti");
}
return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), PLAYERS, name);
if(PlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Patirties taљkai", PlayerInformation[playerid][ExperiencePoints]);
dini_IntSet(file, "Pinigai", PlayerInformation[playerid][Money]);
}
PlayerLogged[playerid] = 0;
return 1;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), PLAYERS, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{ffffff}Registracija", "{ffffff}Prisiregistruokite, įvesdami slaptaћodį.", "Registruotis", "Iљeiti");
dini_Create(file);
dini_IntSet(file, "Slaptaћodis", udb_hash(inputtext));
dini_IntSet(file, "Pinigai", PlayerInformation[playerid][Money] = 0);
dini_IntSet(file, "Patirties taљkai", PlayerInformation[playerid][ExperiencePoints] = 0);
format(string, 128, "Sėkmingai uћsiregistravote. Jūsų slaptaћodis: {ffff33}%s{ffffff}.", inputtext);
SendClientMessage(playerid, 0xFFFFFFFF, string);
SendClientMessage(playerid, 0xFFFFFFFF, "Informaciją apie serverį rasite, paraљę {ffff33}/informacija{ffffff}.");
PlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), PLAYERS, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{ffffff}Prisijungimas", "{ffffff}Prisijunkite, įvesdami slaptaћodį.", "Prisijungti", "Iљeiti");
new tmp;
tmp = dini_Int(file, "Slaptaћodis");
if(udb_hash(inputtext) != tmp)
{
SendClientMessage(playerid, 0xFFFFFFFF, "{ff0033}Neteisingas {ffffff}slaptaћodis.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{ffffff}Prisijungimas", "{ffffff}Prisijunkite, įvesdami slaptaћodį.", "Prisijungti", "Iљeiti");
}
else
{
PlayerLogged[playerid] = 1;
SetPlayerScore(playerid, PlayerInformation[playerid][ExperiencePoints]);
GivePlayerMoney(playerid, dini_Int(file, "Pinigai") - GetPlayerMoney(playerid));
SendClientMessage(playerid, 0xFFFFFFFF, "{99ff33}Teisingas {ffffff}slaptaћodis. Sėkmingai prisijungėte.");
}
}
return 1;
}


