Command register.
Код:
CMD:register(playerid,cmdtext[]){//Na Dole Mapy!
if (registerr == 0) {
SendClientMessage(playerid, COLOR_RED, "Register off!");
return 1;
}
if (users >= maxusers) {
SendClientMessage(playerid, COLOR_RED, "Max register users!");
return 1;
}
if(Registered[playerid]) {
SendClientMessage(playerid, COLOR_RED2, "You already register");
return 1;
}
ShowPlayerDialog(playerid,40,1,"Register","To register account \n\nWrite password","Register","Cancel");
return 1;
#pragma unused cmdtext
}
Register OnDialogResponse..
Код:
if(dialogid == 40)
{
if(response == 1)
{
if(20 < strlen(inputtext) || strlen(inputtext) < 5) {
SendClientMessage(playerid, COLOR_RED2, "Hasło musi mieć od 5 do 20 znakуw");
ShowPlayerDialog(playerid,8,1,"Rejestracja","Aby zarejestrowac sie na tym nicku \n\nMusisisz tylko ustawic haslo","Anuluj","Rejestruj");
return 1;
}
if(FindBadSign(inputtext)){
SendClientMessage(playerid, COLOR_RED2,"Password sign, only [a-z] [A-Z] [0-9]");
return 1;
}
new nick[MAX_PLAYER_NAME];
GetPlayerName(playerid,nick,sizeof(nick));
if(mysqluse == 1){
new string[256];
format(string, sizeof(string), "INSERT INTO `Players` SET `Nick` = '%s',`Pass` = '%s',`Score` = '0',`Bank` = '0',`Bounty` = '0',`Kills` = '0',`Deaths` = '0',`Suicides` = '0',`Used_Score` = '0',`Skin` = '0',`Row_Kills` = '0',`Arena` = '0',`Drag` = '100000'",nick,inputtext);
mysql_query(string);
}
if(diniuse == 1){
new string[128];
format(string,sizeof(string),"PSZD/Gracze/%s.ini",nick);
dini_Create(string);
new File:fl = fopen(string,io_write);
format(string,sizeof(string),"Pass=%s\n\rScore=0\n\rBank=0\n\rBounty=0\n\rKills=0\n\rDeaths=0\n\rSuicides=0\n\rUsed_Score=0\n\rSkin=0\n\rRow_Kills=0\n\rArena=0\n\rDrag=100000\n\rTime=0",inputtext);
fwrite(fl,string);
fclose(fl);
}
users ++;
SendClientMessage(playerid, COLOR_GREEN, "");
new string[128];
format(string, sizeof(string), "You create account: %s , Password: %s", nick, inputtext);
SendClientMessage(playerid, COLOR_GREEN, string);
format(Pass[playerid],21,"%s",inputtext);
format(LoginNick[playerid],MAX_PLAYER_NAME,"%s",nick);
logged[playerid] = true;
Registered[playerid] = true;
}
if(response == 0){
SendClientMessage(playerid,COLOR_RED2,"You cancel register");
}
return 1;
}
Login OnDialogResponse:
Код:
if(dialogid == 39){
if(response == 1)
{
new nick[MAX_PLAYER_NAME];
GetPlayerName(playerid,nick,sizeof(nick));
new haslo[21];
new tmp[256];
format(haslo,sizeof(haslo),"%s",Pass[playerid]);
if (udb_hash(inputtext) != udb_hash(haslo)) {
BadPasCount[playerid] ++;
if(BadPasCount[playerid] >= 3){
SendClientMessage(playerid,COLOR_ORANGE,"Zbyt dużo razy wpisałeś(aś) błędne hasło");
Kick(playerid);
}
SendClientMessage(playerid, COLOR_RED2, "Błędne hasło!");
logged[playerid] = false;
ShowPlayerDialog(playerid,39,1, "Zaloguj się", ""C_ZOLTY"Błędne hasło "C_JZIELONY""VERSION"!\n"C_CZERWONY"\nSprуbuj ponownie. Zaloguj się:", "OK", "Anuluj");
return 1;
}
format(Pass[playerid],21,"%s",haslo);
format(LoginNick[playerid],MAX_PLAYER_NAME,"%s",nick);
logged[playerid] = true;
format(tmp, sizeof(tmp), "Zostałeś zalogowany(a) jako: %s", nick);
SendClientMessage(playerid, COLOR_GREEN, tmp);