02.03.2011, 17:34
where can i go to make a user system with dialog register except for that wiki adminstrator thing because it a cmd thing i want dialog register
encrypt(pass[])
{
static charset[] = "qwertyaQWERTYUIOPZXCVBNMLKJHGFDSAsdfghzxcvbnuiopjklm1324657809_";
static css = 63;
new target[MAX_PASS_SIZE + 1];
new j = strlen(pass);
new sum = j;
new tmpp = 0;
new i;
new mod;
for (i = 0; i < MAX_PASS_SIZE || i < j; i++)
{
mod = i % MAX_PASS_SIZE;
tmpp = (i >= j) ? charset[(7 * i) % css] : pass[i];
sum = (sum + chrfind(tmpp, charset) + 1) % css;
target[mod] = charset[(sum + target[mod]) % css];
}
target[MAX_PASS_SIZE] = '\0';
return target;
}
#define DIALOG_REGISTER 150
#define DIALOG_LOGIN 151
case DIALOG_REGISTER:
{
new file[256];
new name[MAX_PLAYER_NAME];
if(response)
{
if(IsPlayerRegistered(playerid)) return SendClientMessage(playerid,COLOR_RED,"Already Registered!");
if(strlen(inputtext) < MIN_PASS_SIZE || strlen(inputtext) > MAX_PASS_SIZE )//define these values
{
SendClientMessage(playerid, COLOR_RED, "The mass password size is 16 and min is 4");//change it
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Change Me", "Change Me", "Sumbit", ""); //Leave the last "" blank to hide the button
return 1;
}
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(file,sizeof(file),"Users/%s.user.ini", name);
INI_Open(file);
INI_WriteString("Password", encrypt(inputtext));
//Write the player info with INI_Write String/Int/Float (KEY[],VALUE[]);
INI_Save();
INI_Close();
GivePlayerMoney(playerid,SOLDI_REGISTRAZIONE);
SendClientMessage(playerid, COLOR_GREEN, "Account registered");
SetPVarInt(playerid, "Logged", 1);
}
return 1;
}
case DIALOG_LOGIN:
{
if(response)
{
if(!IsPlayerRegistered(playerid)) return SendClientMessage(playerid,COLOR_RED,"Not Registered!");
new read_pass[MAX_PASS_SIZE + 1];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(file,sizeof(file),"Users/%s.user.ini", name);
INI_Open(file);
INI_ReadString(read_pass, "Password");
if((!strcmp(encrypt(inputtext), read_pass, false)))
{
SetPVarInt(playerid, "Logged", 1);
SendClientMessage(playerid, COLOR_GREEN, "Hai eseguito l'accesso.");
//read player's info with INI_Read String/Int/Float (DEST, KEY);
}
else//If password was false
{
SetPVarInt(playerid, "FalseLogins", GetPVarInt(playerid, "FalseLogins") + 1);
if(GetPVarInt(playerid, "FalseLogins") >= 3)
{
new string[180];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string, 180, "%s was kicked for too many false logins.", name);
SendClientMessageToAll(COLOR_RED, string);
printf("%s was kicked for wrong password. Last try: \"%s\".", name, inputtext);
Kick(playerid);
}
else
{
SendClientMessage( playerid, COLOR_RED, "Wrong password!");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Text", "Text", "Sumbit", "");//Re-show the dialog
printf("%s insert wrong password \"%s\".", name, inputtext);
}
}
INI_Close();
}
else
{
new string[180];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,180,DIALOG_LOGIN_TEXT2, name);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Text", "Text", "Sumbit", "");//Re-show the dialog
}
return 1;
}
new name[MAX_PLAYER_NAME];
new file[256];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(file,sizeof(file),"Users/%s.user.ini", name);
if(!IsPlayerConnected(playerid)) return 1;
if(!IsPlayerRegistered(playerid)) return 1;
if(GetPVarInt(playerid, "Logged") != 1) return 1;
INI_Open(file);
//Write the strings, ints and floats like in register dialog
INI_Save();
INI_Close();
stock IsPlayerRegistered(playerid)
{
new name[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string,sizeof(string),"Users/%s.user.ini",name);
if(INI_Exist(string)) return true;
return false;
}
uhm...
1) To make a good user system it's recommended to use SII (Slick's Ini Include) |
I recomend .... |