Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma tabsize 0
- // ============================ INCLUDES ====================================================
- #include <a_samp>
- #include <a_players>
- #include <a_mysql>
- #include <zcmd>
- #include <sscanf2>
- #include <YSI>
- // ===============================DEFINE=====================================================
- #define COLOR_WHITE 0xFFFFFFAA
- #define SCM SendClientMessage
- #define SCMALL SendClientMessageToAll
- // ======================= MYSQL CONNECT DETAILS ============================================
- #define MYSQL_HOST "localhost"
- #define MYSQL_USER "root"
- #define MYSQL_DB "zp_hid3099"
- #define MYSQL_PASS "thisba"
- new username_query[100],
- check_password[90];
- new login_scm[120],
- login_dialog[120],
- register_dialog[120];
- //========================= ENUMS ============================================================
- enum
- {
- DIALOG_REGISTER,
- DIALOG_LOGIN,
- };
- // ===================================== STOCKS =========================================
- stock GetName(playerid)
- {
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- // ============================ FUNCTIONS ===========================================================
- // ========================= Public Factions Location Functions ==============================================
- forward spwCivil(playerid);
- public spwCivil(playerid)
- {
- SetSpawnInfo( playerid, 0, 0, 1744.4681, -1862.5240, 13.5762, 354.0875, 0, 0, 0, 0, 0, 0 );
- SpawnPlayer(playerid);
- }
- forward @Kick(playerid);
- @Kick(playerid) Kick(playerid);
- forward @ban(playerid);
- @ban(playerid) Ban(playerid);
- forward OnAccountCheck(playerid);
- public OnAccountCheck(playerid)
- {
- if(playerid != INVALID_PLAYER_ID)
- {
- new rows, fields;
- cache_get_data(rows, fields, 1);
- if(rows == 1)
- {
- format(login_dialog, sizeof(login_dialog), "{FFFFFF} Bine ai venit {221BE0}%s, {FFFFFF} Introdu {E01B6A} parola {FFFFFF} pentru a te loga:", GetName(playerid));
- ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_dialog, "Login", "Exit");
- spwCivil(playerid);
- }
- else
- {
- SendClientMessage(playerid,0xFF0000C8 , "{2641FE}[INDUNGI]{ffffff}Bine ai venit,raspunde la intrebari pentru a te inregistra.");
- format(register_dialog, sizeof(register_dialog), "{FFFFFF}Salut {221BE0} %s, {FFFFFF} Introdu {E01B6A} o parola {FFFFFF} pentru a te inregistra:", GetName(playerid));
- ShowPlayerDialog(playerid,DIALOG_REGISTER, DIALOG_STYLE_INPUT , "REGISTER", register_dialog, "Register", "Exit");
- }
- }
- }
- forward CheckUserPassword(playerid);
- public CheckUserPassword(playerid)
- {
- new rows,fields;
- cache_get_data(rows, fields, 1);
- if(rows == 1)
- {
- spwCivil(playerid);
- }
- else
- {
- format(login_scm, sizeof(login_scm), "[ACCOUNT] Parola gresita. Incearca din nou!");
- ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_scm, "Login", "Exit");
- }
- }
- // ===================================================================================================
- main()
- {
- print("\n----------------------------------");
- print(" IDG Romania V0.1");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- print("\n------------------------");
- print(" IDG Register V0.1");
- print("------------------------\n");
- SetGameModeText("IDG Romania V.1");
- // ====================== MYSQL CONNECTED ================================================
- if(mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS))
- {
- print("\n-------------------------------------------------");
- print(" Conexiunea la baza de date sa facut cu succes! ");
- print("---------------------------------------------------\n");
- }
- else
- {
- print("\n------------------------------------------");
- print(" Conectarea la baza de date nu a reusit! ");
- print("------------------------------------------\n");
- }
- if(mysql_ping())
- {
- print("\n----------------------------------");
- print(" MySQL connection is still alive! ");
- print("----------------------------------\n");
- }
- if(!mysql_ping())
- {
- print("\n------------------------------");
- print(" MySQL connection is dead! ");
- print("------------------------------\n");
- }
- mysql_debug(1);
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_LOGIN)
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- if (strlen(inputtext) < 5 )
- {
- format(login_scm, sizeof(login_scm), "{FFFFFF}Salut {221BE0}%s, {FFFFFF} Introdu {E01B6A} o parola {FFFFFF} pentru a te intra:", GetName(playerid));
- ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_scm, "Login", "Exit");
- }
- else if(strlen(inputtext) > 5)
- {
- mysql_format(1, check_password, "SELECT * FROM users WHERE username = '%s' AND password = '%s'", GetName(playerid),inputtext);
- mysql_function_query(1 , check_password, true, "CheckUserPassword", "", "");
- }
- else
- {
- format(login_scm, sizeof(login_scm), "{FFFFFF}Salut {221BE0}%s, {FFFFFF} Introdu {E01B6A} o parola {FFFFFF} pentru a te intra:", GetName(playerid));
- ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_scm, "Login", "Exit");
- }
- }
- }
- }
- // ========================= BASIC CALLBACKS =======================================================================
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1133.0504, -2038.4034, 69.0395);
- SetPlayerCameraPos(playerid, 1133.0504, -2038.4034, 69.0395);
- SetPlayerCameraLookAt(playerid, 1133.0504, -2038.4034, 69.0395);
- mysql_format(1 ,username_query,"SELECT * FROM users WHERE username = '%s'", GetName(playerid));
- mysql_function_query(1 , username_query, true, "OnAccountCheck", "", "");
- }
Add Comment
Please, Sign In to add comment