Szerző Téma: Regisztráció rendszer  (Megtekintve 1153 alkalommal)

Regisztráció rendszer
« Dátum: 2017. március 26. - 20:29:17 »
0 Show voters
Sziasztok készitettem egy regisztrációs rendszert. Remélem tetszik.
 

#include <a_samp>
#include <dini>
#include <dudb>
#define SERVERFILE \"urp/accounts/%s.ini\"
#define COLOR_CUSRED 0xcc0000ff
#pragma unused ret_memcpy
enum pLINFO
{
pLevel,
pAdmin,
}
new pInfo[MAX_PLAYERS][pLINFO];
new gPlayerLogged[MAX_PLAYERS];
new Text:SD1;
new Text:SD2;
new Text:szervernev;
new Text:WebURL;
new Connections=0;
new logouts=0;
new playersconnected=0;
forward SetPlayerStats(playerid);
forward OnServerUpdate();
public OnFilterScriptInit()
{
SetTimer(\"OnServerUpdate\",500,true);
SD1 = TextDrawCreate(660.000000, -2.000000, \"                 \");
TextDrawBackgroundColor(SD1, 255);
TextDrawFont(SD1, 1);
TextDrawLetterSize(SD1, 0.500000, 1.000000);
TextDrawColor(SD1, -1);
TextDrawSetOutline(SD1, 0);
TextDrawSetProportional(SD1, 1);
TextDrawSetShadow(SD1, 1);
TextDrawUseBox(SD1, 1);
TextDrawBoxColor(SD1, 255);
TextDrawTextSize(SD1, -98.000000, 225.000000);
SD2 = TextDrawCreate(641.000000, 302.000000, \"                        \");
TextDrawBackgroundColor(SD2, 255);
TextDrawFont(SD2, 1);
TextDrawLetterSize(SD2, 0.500000, 1.000000);
TextDrawColor(SD2, -1);
TextDrawSetOutline(SD2, 0);
TextDrawSetProportional(SD2, 1);
TextDrawSetShadow(SD2, 1);
TextDrawUseBox(SD2, 1);
TextDrawBoxColor(SD2, 255);
TextDrawTextSize(SD2, 2.000000, 73.000000);
szervernev = TextDrawCreate(237.000000, 320.000000, \"szervernev\");
TextDrawBackgroundColor(szervernev, 65535);
TextDrawFont(szervernev, 2);
TextDrawLetterSize(szervernev, 0.749999, 1.800000);
TextDrawColor(szervernev, 16777215);
TextDrawSetOutline(szervernev, 1);
TextDrawSetProportional(szervernev, 0);
 
WebURL = TextDrawCreate(350.000000, 350.000000, \"weboldal\");
TextDrawBackgroundColor(WebURL, -16776961);
TextDrawFont(WebURL, 3);
TextDrawLetterSize(WebURL, 0.569999, 2.200000);
TextDrawColor(WebURL, -1);
TextDrawSetOutline(WebURL, 1);
TextDrawSetProportional(WebURL, 1);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
Connections++;
playersconnected++;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVERFILE, name);
gPlayerLogged[playerid] = 0;
if(!dini_Exists(file)) return ShowPlayerDialog(playerid, 920, DIALOG_STYLE_INPUT, \" Helló ! \" , \"Bocsi ! Te még nem vagy regisztrálva ! \\n{CC0000} Kérlek írj be egy jelszót.\",\"Rendben\",\"Mégsem\");
if(dini_Exists(file))
{
    ShowPlayerDialog(playerid, 921, DIALOG_STYLE_INPUT,\"Helló ! \" ,\"Te már regisztrálva vagy!\",\"Rendben\",\"Mégsem\");
}

TextDrawShowForPlayer(playerid,SD1);
TextDrawShowForPlayer(playerid,SD2);
    TextDrawShowForPlayer(playerid,szervernev);
    TextDrawShowForPlayer(playerid,WebURL);


return 1;
}
public OnPlayerSpawn(playerid)
{
    if(gPlayerLogged[playerid] == 0) return Kick(playerid);
    if(gPlayerLogged[playerid] == 1)
    {
        TextDrawHideForPlayer(playerid,SD1);
        TextDrawHideForPlayer(playerid,SD2);
        TextDrawHideForPlayer(playerid,szervernev);
        TextDrawHideForPlayer(playerid,WebURL);
    }
    return 0;
}
public OnPlayerDisconnect(playerid, reason)
{
logouts++;
playersconnected--;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVERFILE, name);
if(gPlayerLogged[playerid] == 1)
{
   dini_IntSet(file,\"AdminLevel\",pInfo[playerid][pAdmin]);
   dini_IntSet(file,\"lvl\",pInfo[playerid][pLevel]);
}

gPlayerLogged[playerid] = 0;
return 1;
}
 
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 920)
{
   new name[MAX_PLAYER_NAME], file[256];
   GetPlayerName(playerid, name, sizeof(name));
   format(file, sizeof(file), SERVERFILE, name);
    if(!response) return Kick(playerid);
    if(response)
    {
        if(strlen(inputtext) < 4)
        {
        ShowPlayerDialog(playerid, 920, DIALOG_STYLE_INPUT, \" Helló ! \" , \"Bocsi ! Te még nem vagy regisztrálva ! \\n{CC0000} Kérlek írj be egy jelszót.\",\"Rendben\",\"Mégsem\");
      SendClientMessage(playerid,COLOR_CUSRED,\"[Szerver] : A jelszavadnak legalább 4 karakterből kell állnia !\");
      }
      if(strlen(inputtext) >= 4)
      {
      dini_Create(file);
      dini_IntSet(file, \"Password\", udb_hash(inputtext));
      new string[256];
      format(string,sizeof(string),\"[Szerver] : [Infó : Sikeres regisztrálás %s . Jelszavad %s]\",name, inputtext);
      SendClientMessage(playerid, COLOR_CUSRED, string);
      gPlayerLogged[playerid] = 1;
      dini_IntSet(file,\"lvl\",1);
      dini_IntSet(file,\"AdminLevel\",0);
      SetPlayerScore(playerid,1);
      }
    }
}

if(dialogid == 921)
{
   new name[MAX_PLAYER_NAME], file[256];
   GetPlayerName(playerid, name, sizeof(name));
   format(file, sizeof(file), SERVERFILE, name);
   new pass = dini_Int(file, \"Password\");
   if(!response) return SendClientMessage(playerid,COLOR_CUSRED,\"[Szerver] : Elutasítva !\") && Kick(playerid);
   if(strlen(inputtext) < 4) return  ShowPlayerDialog(playerid, 921, DIALOG_STYLE_INPUT,\"Helló ! \" ,\"Te már regisztrálva vagy !\",\"Oké\",\"Mégsem\") && SendClientMessage(playerid,COLOR_CUSRED,\"[URP RGS] : A jelszódnak legalább 4 karakterből kell állnia !\");
   if(udb_hash(inputtext) != pass) return SendClientMessage(playerid,COLOR_CUSRED,\"[Szerver] : Rossz jelszó !\") && ShowPlayerDialog(playerid, 921, DIALOG_STYLE_INPUT,\"Hello ! \" ,\"Te már regisztrálva vagy !\",\"Oké\",\"Mégsem\");
   if(udb_hash(inputtext) == pass)
   {
   gPlayerLogged[playerid] = 1;
   SendClientMessage(playerid,COLOR_CUSRED, \"[Szerver]: Sikeres belépés !\");
   SetPlayerStats(playerid);
   }
}

return 1;
}
public SetPlayerStats(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVERFILE, name);
pInfo[playerid][pAdmin] = dini_Int(file,\"AdminLevel\");
pInfo[playerid][pLevel] = dini_Int(file,\"lvl\");
SetPlayerScore(playerid,pInfo[playerid][pLevel]);
return 1;
}
 
public OnPlayerUpdate(playerid)
{
if(gPlayerLogged[playerid] == 1)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVERFILE, name);
dini_IntSet(file,\"lvl\",GetPlayerScore(playerid));
pInfo[playerid][pLevel] = dini_Int(file,\"lvl\");
dini_IntSet(file,\"AdminLevel\",pInfo[playerid][pAdmin]);
SetPlayerScore(playerid,pInfo[playerid][pLevel]);
pInfo[playerid][pAdmin] = dini_Int(file,\"AdminLevel\");
}
return 1;
}
 

 
 

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal