Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =============================================================================
- // =============================================================================
- // =============================================================================
- // =============================================================================
- // ----------------- Define Roleplay Romania Under Developing ------------------
- // =============================================================================
- // =============================================================================
- // =============================================================================
- // =============================================================================
- // --------------------------- Bibliotecile necesare ---------------------------
- #include <a_samp>
- #include <YSI\y_ini>
- // =============================================================================
- // --------------------------- Definitiile necesare ----------------------------
- #define Dialog_Inregistrare 1
- #define Dialog_Logare 2
- #define Dialog_Conectare_1 3
- #define Dialog_Conectare_2 4
- #define PATH "/Conturi/%s.ini"
- // =============================================================================
- // --------------------------- Variabilele necesare ----------------------------
- // =============================================================================
- // ---------------------- Variabile cu functie de returnare --------------------
- forward LoadUser_data (playerid, name[], value[]);
- // =============================================================================
- // --------------------------- Enumeratiile necesare ---------------------------
- enum pInfo
- {
- pParola,
- pBani,
- pAdmin,
- pCrime,
- pDecese
- }
- new PlayerInfo [MAX_PLAYERS] [pInfo];
- // =============================================================================
- // ------------------------ Functii cu valoarea initiala -----------------------
- stock UserPath (playerid)
- {
- new Mesaj [256];
- new Nume [MAX_PLAYER_NAME];
- GetPlayerName (playerid, Nume, sizeof (Nume));
- format (Mesaj, sizeof (Mesaj), PATH, Nume);
- return Mesaj;
- }
- stock udb_hash (buf[])
- {
- new Durata = strlen (buf);
- new s = 1;
- new d = 0;
- new n;
- for (n=0; n <= Durata; n++)
- {
- s = (s + buf [n]) % 65521;
- d = (d + s) % 65521;
- }
- return (d << 16) + s;
- }
- strtok (const string[], &index)
- {
- new Durata = strlen (string);
- while ((index < Durata) && (string [index] <= ' '))
- {
- index++;
- }
- new Variabila = index;
- new Rezultat [20];
- while ((index < Durata) && (string [index] > ' ') && ((index - Variabila) < (sizeof (Rezultat) - 1)))
- {
- Rezultat [index - Variabila] = string [index];
- index++;
- }
- Rezultat [index - Variabila] = EOS;
- return Rezultat;
- }
- ReturnUser (string [])
- {
- new Este_Numeric = 1;
- new tmpstring [MAX_PLAYER_NAME];
- for (new Celula; Celula < strlen (string); Celula++)
- {
- if ((string [Celula] <= '0') || (string [Celula] >= '9'))
- {
- Este_Numeric = 0;
- }
- if (Este_Numeric)
- {
- return strval (string);
- }
- else
- {
- for (new Jucatori; Jucatori < MAX_PLAYERS; Jucatori++)
- {
- GetPlayerName (Jucatori, tmpstring, sizeof (tmpstring));
- if (strfind (tmpstring, string, true) > -1)
- {
- return Jucatori;
- }
- }
- }
- }
- return INVALID_PLAYER_ID;
- }
- // =============================================================================
- // ----------------------------- Functii generale ------------------------------
- public LoadUser_data (playerid, name[], value[])
- {
- INI_Int ("Parola", PlayerInfo [playerid] [pParola]);
- INI_Int ("Bani", PlayerInfo [playerid] [pBani]);
- INI_Int ("Admin", PlayerInfo [playerid] [pAdmin]);
- INI_Int ("Crime", PlayerInfo [playerid] [pCrime]);
- INI_Int ("Decese", PlayerInfo [playerid] [pDecese]);
- return 1;
- }
- public OnPlayerConnect (playerid)
- {
- if (fexist (UserPath (playerid)))
- {
- INI_ParseFile (UserPath (playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog (playerid, Dialog_Logare, DIALOG_STYLE_INPUT, "{336633}Fereastra de logare", "{FFCC99}Bine ai revenit pe {6666CC}Define Roleplay Romania{FFCC99}. \n{FFCC99}Acest cont {66FF33}este inregistrat {FFCC99}in baza noastra de date. \n{FFCC99}Te rog introdu parola corecta in casuta de mai jos pentru a te conecta.", "Ok", "Renunta");
- }
- else
- {
- ShowPlayerDialog (playerid, Dialog_Inregistrare, DIALOG_STYLE_INPUT, "{336633}Fereastra de inregistrare", "{FFCC99}Bine ai venit pe {6666CC}Define Roleplay Romania{FFCC99}. \n{FFCC99}Acest cont {CC0000}nu este inregistrat {FFCC99}in baza noastra de date. \n{FFCC99}Te rog introdu parola dorita in casuta de mai jos pentru a te inregistra.", "Ok", "Renunta");
- }
- return 1;
- }
- public OnDialogResponse (playerid, dialogid, response, listitem, inputtext[])
- {
- switch (dialogid)
- {
- case Dialog_Inregistrare :
- {
- if (!response)
- {
- return Kick (playerid);
- }
- if (response)
- {
- if (!strlen (inputtext))
- {
- return ShowPlayerDialog (playerid, Dialog_Inregistrare, DIALOG_STYLE_INPUT, "{336633}Fereastra de inregistrare", "{FFCC99}Nu ai reusit sa te conectezi la server deoarece parola introdusa este {CC0000}incorecta{FFCC99}. \n{FFCC99}Te rog introdu o parola in casuta de mai jos pentru a te conecta.", "Ok", "Renunta");
- }
- new INI:Fisier = INI_Open (UserPath (playerid));
- INI_SetTag (Fisier, "data");
- INI_WriteInt (Fisier, "Parola", udb_hash (inputtext));
- INI_WriteInt (Fisier, "Bani", 0);
- INI_WriteInt (Fisier, "Admin", 0);
- INI_WriteInt (Fisier, "Crime", 0);
- INI_WriteInt (Fisier, "Decese", 0);
- INI_Close (Fisier);
- SetSpawnInfo (playerid, 0, 0, 1642.2238, -2332.9924, 13.5469, 359.0938, 0, 0, 0, 0, 0 , 0);
- SpawnPlayer (playerid);
- PlayerInfo [playerid] [pBani] = 600;
- GivePlayerMoney (playerid, PlayerInfo [playerid] [pBani]);
- ShowPlayerDialog (playerid, Dialog_Conectare_1, DIALOG_STYLE_MSGBOX, "{66CC00}Fereastra de conectare", "{FFCC99}Te-ai conectat cu {66CC00}succes {FFCC99}pe Define Roleplay Romania. \n{FFCC99}Echipa noastra iti ureaza o distractie placuta.", "Ok", "");
- }
- }
- case Dialog_Logare :
- {
- if (!response)
- {
- return Kick (playerid);
- }
- if (response)
- {
- if (udb_hash (inputtext) == PlayerInfo [playerid] [pParola])
- {
- INI_ParseFile (UserPath (playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- GivePlayerMoney (playerid, PlayerInfo [playerid] [pBani]);
- SetSpawnInfo (playerid, 0, 0, 1642.2238, -2332.9924, 13.5469, 359.0938, 0, 0, 0, 0, 0 , 0);
- SpawnPlayer (playerid);
- ShowPlayerDialog (playerid, Dialog_Conectare_2, DIALOG_STYLE_MSGBOX, "{66CC00}Fereastra de conectare", "{FFCC99}Te-ai conectat cu {66CC00}succes {FFCC99}pe Define Roleplay Romania. \n{FFCC99}Echipa noastra iti ureaza o distractie placuta.", "Ok", "");
- }
- else
- {
- ShowPlayerDialog (playerid, Dialog_Logare, DIALOG_STYLE_INPUT, "{336633}Fereastra de logare", "{FFCC99}Nu ai reusit sa te conectezi la server deoarece parola introdusa este {CC0000}incorecta{FFCC99}. \n{FFCC99}Te rog introdu parola corecta in casuta de mai jos pentru a te conecta.", "Ok", "Renunta");
- }
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerCommandText (playerid, cmdtext[])
- {
- new Comanda [256];
- new Variabila;
- if (strcmp (Comanda, "/asetadmin", true) == 0)
- {
- new Mesaj [256];
- new Format [256];
- new Trimitator [MAX_PLAYER_NAME];
- new Receptor [MAX_PLAYER_NAME];
- new Receptor_ID;
- if (PlayerInfo [playerid] [pAdmin] == 4)
- {
- Format = strtok (cmdtext, Variabila);
- if (!strlen (Format))
- {
- SendClientMessage (playerid, 0xFFFFFF, "{CC0000}*** {336633}[Informatie] {FFCC99}Formatul corect al acestei comenzi este : '/asetadmin [ID Jucator] [Nivel Admin]'. {CC0000}***");
- return 1;
- }
- Receptor_ID = ReturnUser (Format);
- Format = strtok (cmdtext, Variabila);
- new Nivel = strval (Format);
- if (Receptor_ID != INVALID_PLAYER_ID)
- {
- GetPlayerName (Receptor_ID, Receptor, sizeof (Receptor));
- GetPlayerName (playerid, Trimitator, sizeof (Trimitator));
- PlayerInfo [Receptor_ID] [pAdmin] = Nivel;
- format (Mesaj, sizeof (Mesaj), "{CC0000}*** {336633}[Informatie] {FFCC99}Ai fost promovat la statutul de Admin Level %d de Administratorul %s. Felicitari. {CC0000}***", Nivel, Trimitator);
- SendClientMessage (Receptor_ID, 0xFFFFFF, Mesaj);
- format (Mesaj, sizeof (Mesaj), "{CC0000}*** {336633}[Informatie] {FFCC99}L-ai promovat la statutul de Admin Level %s pe %d. Speram sa nu dezamageasca. {CC0000}***", Receptor, PlayerInfo [Receptor_ID] [pAdmin]);
- SendClientMessage (playerid, 0xFFFFFF, Mesaj);
- }
- else if (Receptor_ID == INVALID_PLAYER_ID)
- {
- format (Mesaj, sizeof (Mesaj), "{CC0000}*** {336633}[Informatie] {FFCC99}%i nu este conectat pe server. Verifica daca ai scris ID-ul corect. {CC0000}***", Receptor_ID);
- SendClientMessage (playerid, 0xFFFFFF, Mesaj);
- }
- }
- else
- {
- SendClientMessage (playerid, 0xFFFFFF, "{CC0000}*** {336633}[Informatie] {FFCC99}Nu esti autorizat sa folosesti aceasta comanda. Ia legatura cu unul din membrii echipei noastre pentru mai multe detalii. {CC0000}***");
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerDisconnect (playerid, reason)
- {
- new INI:Fisier = INI_Open (UserPath (playerid));
- INI_SetTag (Fisier, "data");
- INI_WriteInt (Fisier, "Bani", GetPlayerMoney (playerid));
- INI_WriteInt (Fisier, "Admin", PlayerInfo [playerid] [pAdmin]);
- INI_WriteInt (Fisier, "Crime", PlayerInfo [playerid] [pCrime]);
- INI_WriteInt (Fisier, "Decese", PlayerInfo [playerid] [pDecese]);
- INI_Close (Fisier);
- return 1;
- }
- public OnPlayerDeath (playerid, killerid, reason)
- {
- PlayerInfo [killerid] [pCrime] ++;
- PlayerInfo [playerid] [pDecese] --;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment