10.02.2010, 12:09
Okay, so what i got so far kinda works it's not saving the stuff below. I tried changing the register system from a standard dcmd /login /register system to use Dialogs.
Anyways, here's my code.
- Money
- Interior
- Job
- Admin
Anyways, here's my code.
pawn Код:
Entry(playerid)
{
if (!udb_Exists(PlayerName(playerid)))
{
new kayitmsg[256];
new name[MAX_PLAYER_NAME];
format(kayitmsg,256,"Welcome to the server\n\n%s please open a new account\n\nEnter the new password:",name);
ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",kayitmsg,"Register","Quit");
register[playerid] = 1;
login[playerid] = 0;
}
else if (udb_Exists(PlayerName(playerid)))
{
new girismsg[256];
new name[MAX_PLAYER_NAME];
format(girismsg,256,"Welcome to Esperanza Roleplay\n\n\nEnter your password:",name);
ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
register[playerid] = 0;
login[playerid] = 1;
}
return 1;
}
// The code above is my dialog.
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (response == 1)
{
if(dialogid == 12345)
{
if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists.");
if (strlen(inputtext)==0) return Entry(playerid);
if (udb_Create(PlayerName(playerid),inputtext)) return SystemMsg(playerid,"Account successfully created.") && SetPlayerJob(playerid, 1);
}
}
if(dialogid == 12346)
{
Encrypt(inputtext);
if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"[ ! ] Account doesn't exist, please use '/register password'.");
if (udb_CheckLogin(PlayerName(playerid),inputtext)) {
GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("Money")-GetPlayerMoney(playerid));
GivePlayerAdminz(playerid,dUserINT(PlayerName(playerid)).("Admin")-GetPlayerAdminz(playerid));
SetPlayerInterior(playerid,dUserINT(PlayerName(playerid)).("Interior")-GetPlayerInterior(playerid));
SetPlayerJob(playerid,dUserINT(PlayerName(playerid)).("Job")-IsPlayerJob(playerid));
Logged[playerid]=true;
return SendClientMessage(playerid,ADMIN_MSG,"[ ! ] Access granted ! You're now logged in !");
}
if(!strlen(inputtext))
{
Entry(playerid);
return 1;
}
}
return 1;
}