03.04.2010, 17:20
pawn Код:
public OnPlayerRequestSpawn(playerid)
#if USE_DIALOGS == true
if(AccInfo[playerid][Registered] == 0 && (!IsPlayerNPC(playerid))){
new rstring[256];
format(rstring,256,"Dobrodosli '%s'\n\nAccount '%s' nije registriran\n\nUpisi svoju lozinku za registraciju:",GetServerHostName(),pName(playerid));
ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Registracija",rstring,"Registriraj","Odustani");
return 0;
}
if(AccInfo[playerid][Registered] == 1 && AccInfo[playerid][LoggedIn] == 0 && (!IsPlayerNPC(playerid))){
new lstring[256];
format(lstring,256,"Taj korisnik '%s je registriran\n\n Ulogiraj se kako bi pristupio svom racunu:",pName(playerid));
ShowPlayerDialog(playerid,DIALOGID+67,DIALOG_STYLE_INPUT,"Logiranje korisnika",lstring,"Logiraj","Odustani");
return 0;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOGID+66)
{
if(response == 0)
{
Kick(playerid);
}
if(response)
{
if (strlen(inputtext) < 4 || strlen(inputtext) > 20)
{
new rstring[256];
format(rstring,256,"Oprosti %s\n\nTvoja lozinka mora biti bolja od \nod 3 slova i manja od 20 slova \n\n Molim te napisi bolju lozinku:",pName(playerid));
return ShowPlayerDialog(playerid,DIALOGID+68,DIALOG_STYLE_INPUT,"Extreme Fun Server ERROR",rstring,"Registriraj","Izadi");
}
if (udb_Create(PlayerName2(playerid)))
{
new file[256],name[MAX_PLAYER_NAME], buf[145],tmp3[100];
new strdate[20], year,month,day;
getdate(year, month, day);
WP_Hash(buf, sizeof(buf), inputtext);
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(name));
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"Password",buf);
dini_Set(file,"Ip",tmp3);
dUserSetINT(PlayerName2(playerid)).("Registered",1);
format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
dini_Set(file,"RegisteredDate",strdate);
dUserSetINT(PlayerName2(playerid)).("Loggedin",1);
dUserSetINT(PlayerName2(playerid)).("Banned",0);
dUserSetINT(PlayerName2(playerid)).("Level",0);
dUserSetINT(PlayerName2(playerid)).("AccountType",0);
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("Money",0);
dUserSetINT(PlayerName2(playerid)).("Kills",0);
dUserSetINT(PlayerName2(playerid)).("Deaths",0);
dUserSetINT(PlayerName2(playerid)).("WantedLevel",0);
#if SaveScore == true
dUserSetINT(PlayerName2(playerid)).("Score",0);
#endif
dUserSetINT(PlayerName2(playerid)).("Hours",0);
dUserSetINT(PlayerName2(playerid)).("Minutes",0);
dUserSetINT(PlayerName2(playerid)).("Seconds",0);
AccInfo[playerid][LoggedIn] = 1;
AccInfo[playerid][Registered] = 1;
SendClientMessage(playerid, green, "Sada si registriran i automatski ulogiran!");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
return 1;
}
}
return 1;
}
//==============================================================================
//---------------
// Dialog - LOGIN
//---------------
//==============================================================================
if (dialogid == DIALOGID+67)
{
if(response == 0)
{
Kick(playerid);
}
if(response)
{
new lstring[256];
new file[128], Pass[256];
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
Pass = dini_Get(file, "Password");
new buf[145];
WP_Hash(buf, sizeof(buf), inputtext);
if(strcmp(Pass, buf, false) == 0)
{
new tmp3[100], string[128];
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"Ip",tmp3);
LoginPlayer(playerid);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
if(AccInfo[playerid][Level] > 0)
{
switch(AccInfo[playerid][Level])
{
case 1: AdmRank = "Basic Moderator";
case 2: AdmRank = "Moderator";
case 3: AdmRank = "Master Moderator";
case 4: AdmRank = "Administrator";
case 5: AdmRank = "Master Administrator";
}
if(AccInfo[playerid][Level] > 5)
{
AdmRank = "Professional Admin";
}
if(AccInfo[playerid][pVip] > 0)
{
switch(AccInfo[playerid][pVip])
{
case 1: AccType = "Silver";
case 2: AccType = "Gold";
case 3: AccType = "Premium";
}
format(string,sizeof(string),"Uspijesno si ulogiran | Racun: %s | Level %d - %s", AccType, AccInfo[playerid][Level], AdmRank);
return SendClientMessage(playerid,0x00C378AA,string);
}
else
{
format(string,sizeof(string),"Uspijesno si ulogiran | Level %d - %s", AccInfo[playerid][Level], AdmRank);
return SendClientMessage(playerid,green,string);
}
}
else
{
if(AccInfo[playerid][pVip] > 0)
{
switch(AccInfo[playerid][pVip])
{
case 1: AccType = "Silver";
case 2: AccType = "Gold";
case 3: AccType = "Premium";
}
format(string,sizeof(string),"Uspijesno si ulogiran | Racun: %s", AccType);
return SendClientMessage(playerid,0x00C896AA,string);
}
else return SendClientMessage(playerid,green,"Uspijesno si ulogiran!");
}
}
else
{
AccInfo[playerid][FailLogin]++;
printf("LOGIN: Neuspijelo logiranje: %s. Kriva sifra (%s) (%d)", PlayerName2(playerid), inputtext, AccInfo[playerid][FailLogin] );
if(AccInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
new string[128]; format(string, sizeof(string), "Igrac %s je automatski kickan (Razlog: previse netocnihunosasifre)", PlayerName2(playerid) );
SendClientMessageToAll(red, string);
print(string);
Kick(playerid);
}
format(lstring,256,"Oprosti '%s'\n\nSifra koju si napiso nije tocna\n\nMolim te napisi tocnu sifru:",pName(playerid));
return ShowPlayerDialog(playerid,DIALOGID+69,DIALOG_STYLE_INPUT,"Extreme Fun Server ERROR",lstring,"Logiraj","Izadi");
}
}
}