22.04.2013, 21:21
I use dudb
and this for register and login
And this command for example to set player admin's level
But nothing are saved in the folder of players file
and this for register and login
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if (response == 0)
{
SetTimer("Kickplayer",700,0);
Kick(playerid);
return 1;
}
if (response == 1)
{
if (strlen(inputtext) == 0)
{
SendClientMessage(playerid,COLOR_ERROR,"Please enter your password for your account in the box below.");
ShowLoginScreen(playerid);
return 1;
}
if (udb_CheckLogin(PlayerName(playerid),inputtext))
{
AdminLevel[playerid] =dUserINT(PlayerName(playerid)).("Adminlevel");
Coins[playerid] =dUserINT(PlayerName(playerid)).("Coins");
SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("Score")-GetPlayerScore(playerid));
NameBanned[playerid] =dUserINT(PlayerName(playerid)).("Nameban");
new pIp[16];
GetPlayerIp(playerid, pIp, sizeof(pIp));
dUserSet(PlayerName(playerid)).("IP", pIp);
PLAYERLIST_authed[playerid]=true;
return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have successfully logged in! Your previous stats have been restored.");
}
ShowLoginScreen(playerid);
CheckPasswordAttempts(playerid);
}
return 1;
}
if(dialogid == DIALOG_REGISTER)
{
if (response == 0)
{
Kick(playerid);
return 1;
}
if (response == 1)
{
if (udb_Exists(PlayerName(playerid)))
{
SendClientMessage(playerid,COLOR_ERROR,"This account already exists, please choose a different player name.");
return 1;
}
if (strlen(inputtext)==0)
{
SendClientMessage(playerid,COLOR_ERROR,"Please enter your password in the box to register in this server.");
ShowRegisterScreen(playerid);
return 1;
}
if (udb_Create(PlayerName(playerid),inputtext))
{
SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have registered, now please enter your password in the box to login.");
ShowLoginScreen(playerid);
PLAYERLIST_authed[playerid]=true;
dUserSetINT(PlayerName(playerid)).("Coins",0);
dUserSetINT(PlayerName(playerid)).("Score",0);
dUserSetINT(PlayerName(playerid)).("Adminlevel",0);
dUserSetINT(PlayerName(playerid)).("Nameban",0);
new pIp[16];
GetPlayerIp(playerid, pIp, sizeof(pIp));
dUserSet(PlayerName(playerid)).("IP", pIp);
}
return true;
}
return 1;
}
return 0;
}
PHP код:
dcmd_setadmin(playerid,params[])
{
new ID;
new cmdreason;
if(sscanf(params,"ui",ID,cmdreason))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /setadmin (ID) (Level)");
SendClientMessage(playerid,COLOR_LIME,"It will set admin level");
return 1;
}
AdminLevel[ID] =cmdreason;
SendClientMessage(playerid,COLOR_SEXYGREEN,"An Admin has set your level bla bla bla");
return 1;
}