Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- // change MAX_PLAYERS to the amount of players (slots) you want
- // It is by default 1000 (as of 0.3.7 version)
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 50
- //----------
- // INCLUDE
- #include <a_mysql>
- #include <zcmd>
- #include <sscanf2>
- // Define
- // stili dialogo
- #define d_input DIALOG_STYLE_INPUT
- #define d_list DIALOG_STYLE_LIST
- // Configurazione MySQL
- #define MYSQL_HOST "127.0.0.1"
- #define MYSQL_USER "root"
- #define MYSQL_PASSWORD "Pass123!"
- #define MYSQL_DATABASE "dbrp"
- //-------------
- // info server
- #define emailserver "asd@gmail.com"
- #define nomeserver "server bello"
- //-----------------------
- // Textdraw
- new Text:AdminInDuty;
- // domande di sicurezza
- // per modificare la password con il comando /cambia -> password
- #define MAX_SECURITY_QUESTION_SIZE 128
- // colori
- // system color
- #define COLOR_SYSTEM_ERROR 0xAA3333AA
- #define COLOR_SYSTEM_TITLE 0xFFFFFFAA
- #define COLOR_SYSTEM_TEXT 0xFFFFFFAA
- #define COLOR_SYSTEM_SUCCESS 0x33AA33AA
- #define COLOR_SYSTEM_INFO 0xAFAFAFAA
- #define COLOR_SYSTEM_ADMIN 0xFFFF00AA
- #define COL_STRING_ERROR "{FF0000}"
- #define COL_STRING_SUCCESS "{00FF00}"
- #define COLOR_RED 0xFF0000
- #define COLOR_INFO 0xAFAFAF
- #define COLOR_WHITE (0xFFFFFFFF)
- #define COL_WHITE "{FFFFFF}"
- #define COLOR_TOMATO (0xFF6347FF)
- #define COL_TOMATO "{FF6347}"
- #define COLOR_YELLOW (0xFFDD00FF)
- #define COL_YELLOW "{FFDD00}"
- #define COLOR_GREEN (0x00FF00FF)
- #define COL_GREEN "{00FF00}"
- #define COLOR_DEFAULT (0xA9C4E4FF)
- #define COL_DEFAULT "{A9C4E4}"
- // how many seconds until it kicks the player for taking too long to login
- #define SECONDS_TO_LOGIN 30
- #define NAME_CHECKER1 30
- // Spawn default dopo la registrazione
- #define DEFAULT_POS_X -1965.3541
- #define DEFAULT_POS_Y 158.4787
- #define DEFAULT_POS_Z 27.6940
- #define DEFAULT_POS_A 90.0000
- #define DEFAULT_POS_INTERIOR 0
- /* Es: Las Venturas
- #define DEFAULT_POS_X 1958.3783
- #define DEFAULT_POS_Y 1343.1572
- #define DEFAULT_POS_Z 15.3746
- #define DEFAULT_POS_A 270.1425
- #define DEFAULT_POS_INTERIOR 0
- */
- // MySQL connection handle
- new MySQL: g_SQL;
- // player data
- enum E_PLAYERS
- {
- ID,
- Name[MAX_PLAYER_NAME],
- Password[65], // the output of SHA256_PassHash function (which was added in 0.3.7 R1 version) is always 256 bytes in length, or the equivalent of 64 Pawn cells
- Salt[17],
- Kills,
- Admin,
- Age,
- ADuty,
- Sex,
- Soldi,
- PatenteA[64],
- PatenteB[64],
- PatenteC[64],
- PatenteD[64],
- PortoDarmi[64],
- Deaths,
- Float:Vita,
- Float:Armatura,
- e_USER_SECURITY_QUESTION[MAX_SECURITY_QUESTION_SIZE],
- e_USER_SECURITY_ANSWER[64],
- PlayerEmail[64],
- Float: X_Pos,
- Float: Y_Pos,
- Float: Z_Pos,
- Float: A_Pos,
- Interior,
- Cache: Cache_ID,
- bool: IsLoggedIn,
- LoginAttempts,
- LoginTimer
- };
- new Player[MAX_PLAYERS][E_PLAYERS];
- new g_MysqlRaceCheck[MAX_PLAYERS];
- // dialog data
- enum
- {
- DIALOG_UNUSED,
- DIALOG_LOGIN,
- DIALOG_REGISTER,
- DIALOG_REGISTER_AGE,
- DIALOG_REGISTER_SEX,
- DIALOG_REGISTER_EMAIL,
- DIALOG_REGISTER_DOMANDASEC,
- DIALOG_REGISTER_RISPOSTASEC,
- DIALOG_PROVA
- };
- // protocollo controllo nome RP
- stock RPnamecheck(playerid)
- {
- new pname[MAX_PLAYER_NAME],underline=0;
- GetPlayerName(playerid, pname, sizeof(pname));
- if(strfind(pname,"[",true) != (-1)) return 0;
- else if(strfind(pname,"]",true) != (-1)) return 0;
- else if(strfind(pname,"$",true) != (-1)) return 0;
- else if(strfind(pname,"(",true) != (-1)) return 0;
- else if(strfind(pname,")",true) != (-1)) return 0;
- else if(strfind(pname,"=",true) != (-1)) return 0;
- else if(strfind(pname,"@",true) != (-1)) return 0;
- else if(strfind(pname,"1",true) != (-1)) return 0;
- else if(strfind(pname,"2",true) != (-1)) return 0;
- else if(strfind(pname,"3",true) != (-1)) return 0;
- else if(strfind(pname,"4",true) != (-1)) return 0;
- else if(strfind(pname,"5",true) != (-1)) return 0;
- else if(strfind(pname,"6",true) != (-1)) return 0;
- else if(strfind(pname,"7",true) != (-1)) return 0;
- else if(strfind(pname,"8",true) != (-1)) return 0;
- else if(strfind(pname,"9",true) != (-1)) return 0;
- else if(strfind(pname,"fuck",true) != (-1)) return 0;
- else if(strfind(pname,"FUCK",true) != (-1)) return 0;
- else if(strfind(pname,"Boobies",true) != (-1)) return 0;
- else if(strfind(pname,"Tupac_Shakur",true) != (-1)) return 0;
- else if(strfind(pname,"Pussy",true) != (-1)) return 0;
- else if(strfind(pname,"Rape",true) != (-1)) return 0;
- else if(strfind(pname,"kill",true) != (-1)) return 0;
- else if(strfind(pname,"shit",true) != (-1)) return 0;
- else if(strfind(pname,"ass",true) != (-1)) return 0;
- else if(strfind(pname,"Jack_Black",true) != (-1)) return 0;
- else if(strfind(pname,"Max_Kenton",true) != (-1)) return 0;
- else if(strfind(pname,"Will_Smith",true) != (-1)) return 0;
- else if(strfind(pname,"Jaden_Smith",true) != (-1)) return 0;
- else if(strfind(pname,"Megan_Fox",true) != (-1)) return 0;
- else if(strfind(pname,"Charlie_Kenton",true) != (-1)) return 0;
- else if(strfind(pname,"Hugh_Hefner",true) != (-1)) return 0;
- else if(strfind(pname,"Paris_Hilton",true) != (-1)) return 0;
- else if(strfind(pname,"Marshall_Mathers",true) != (-1)) return 0;
- else if(strfind(pname,"Sheldon_Cooper",true) != (-1)) return 0;
- else if(strfind(pname,"Jet_Lee",true) != (-1)) return 0;
- else if(strfind(pname,"Jackie_Chan",true) != (-1)) return 0;
- else if(strfind(pname,"Chuck_Norris",true) != (-1)) return 0;
- else if(strfind(pname,"Peter_Parker",true) != (-1)) return 0;
- else if(strfind(pname,"Spider_Man",true) != (-1)) return 0;
- else if(strfind(pname,"Bat_Man",true) != (-1)) return 0;
- else if(strfind(pname,"Emma_Stone",true) != (-1)) return 0;
- else if(strfind(pname,"whore",true) != (-1)) return 0;
- else if(strfind(pname,"Hugh_Jackman",true) != (-1)) return 0;
- else if(strfind(pname,"Charles_Kenton",true) != (-1)) return 0;
- else if(strfind(pname,"Harry_Potter",true) != (-1)) return 0;
- else if(strfind(pname,"Chris_Hemsworth",true) != (-1)) return 0;
- else if(strfind(pname,"Penis",true) != (-1)) return 0;
- else if(strfind(pname,"_Dick",true) != (-1)) return 0;
- else if(strfind(pname,"Vagina",true) != (-1)) return 0;
- else if(strfind(pname,"Cock",true) != (-1)) return 0;
- else if(strfind(pname,"Rectum",true) != (-1)) return 0;
- else if(strfind(pname,"Sperm",true) != (-1)) return 0;
- else if(strfind(pname,"Rektum",true) != (-1)) return 0;
- else if(strfind(pname,"Pistol",true) != (-1)) return 0;
- else if(strfind(pname,"AK47",true) != (-1)) return 0;
- else if(strfind(pname,"Shotgun",true) != (-1)) return 0;
- else if(strfind(pname,"Cum",true) != (-1)) return 0;
- else if(strfind(pname,"Hitler",true) != (-1)) return 0;
- else if(strfind(pname,"Jesus",true) != (-1)) return 0;
- else if(strfind(pname,"God",true) != (-1)) return 0;
- else if(strfind(pname,"Shotgun",true) != (-1)) return 0;
- else if(strfind(pname,"Desert_Eagle",true) != (-1)) return 0;
- else if(strfind(pname,"fucker",true) != (-1)) return 0;
- else if(strfind(pname,"Retard",true) != (-1)) return 0;
- else if(strfind(pname,"Tarded",true) != (-1)) return 0;
- else if(strfind(pname,"fanny",true) != (-1)) return 0;
- else if(strfind(pname,"Daniel_Hardy",true) != (-1)) return 0;
- else if(strfind(pname,"abcdefghijklmnopqrstuvwxyz",true) != (-1)) return 0;
- new maxname = strlen(pname);
- for(new i=0; i<maxname; i++)
- {
- if(pname[i] == '_') underline ++;
- }
- if(underline != 1) return 0;
- pname[0] = toupper(pname[0]);
- for(new x=1; x<maxname; x++)
- {
- if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
- else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
- }
- SetPlayerName(playerid, "New_Name");
- SetPlayerName(playerid, pname);
- return 1;
- }
- main() {}
- public OnGameModeInit()
- {
- new MySQLOpt: option_id = mysql_init_options();
- mysql_set_option(option_id, AUTO_RECONNECT, true); // it automatically reconnects when loosing connection to mysql server
- g_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id); // AUTO_RECONNECT is enabled for this connection handle only
- if (g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0)
- {
- print("MySQL connection failed. Server is shutting down.");
- SendRconCommand("exit"); // close the server if there is no connection
- return 1;
- }
- new infomysql[128];
- print("[MySQL] - Connessione con successo al MySQL.");
- format(infomysql, sizeof(infomysql), "[MySQL] - MySQL connesso all'host '%s'", MYSQL_HOST);
- print(infomysql);
- format(infomysql, sizeof(infomysql), "[MySQL] - Utente collegato '%s'", MYSQL_USER);
- print(infomysql);
- format(infomysql, sizeof(infomysql), "[MySQL] - Password utilizzata '%s'", MYSQL_PASSWORD);
- print(infomysql);
- format(infomysql, sizeof(infomysql), "[MySQL] - Connesso al database '%s' con successo", MYSQL_DATABASE);
- print(infomysql);
- // TextDraws
- AdminInDuty = TextDrawCreate(102.606338, 313.833496, "ADMIN ON");
- TextDrawLetterSize(AdminInDuty, 0.506222, 1.518333);
- TextDrawAlignment(AdminInDuty, 3);
- TextDrawColor(AdminInDuty, -1);
- TextDrawUseBox(AdminInDuty, true);
- TextDrawBoxColor(AdminInDuty, 255);
- TextDrawSetShadow(AdminInDuty, 0);
- TextDrawSetOutline(AdminInDuty, 0);
- TextDrawBackgroundColor(AdminInDuty, 41215);
- TextDrawFont(AdminInDuty, 1);
- TextDrawSetProportional(AdminInDuty, 1);
- // if the table has been created, the "SetupPlayerTable" function does not have any purpose so you may remove it completely
- SetupPlayerTable();
- return 1;
- }
- public OnGameModeExit()
- {
- // save all player data before closing connection
- for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // GetPlayerPoolSize function was added in 0.3.7 version and gets the highest playerid currently in use on the server
- {
- if (IsPlayerConnected(i))
- {
- // reason is set to 1 for normal 'Quit'
- OnPlayerDisconnect(i, 1);
- }
- }
- mysql_close(g_SQL);
- return 1;
- }
- // quando l'utente si connette al server
- public OnPlayerConnect(playerid)
- {
- if(!RPnamecheck(playerid))
- {
- SetTimerEx("KickTimerNameRP", 3000, 0, "d", playerid);
- SetPlayerPos(playerid, 982.1890, -1624.2583, 14.9526);
- SetPlayerFacingAngle(playerid, 90);
- new string[128], pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
- format(string, sizeof(string), "{FF0000}[INFO] Devi inserire un nome {00FF00}RP per entrare nel server");
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
- format(string, sizeof(string), "{AFAFAF}Il nome {FF0000}%s non è valido.{AFAFAF} (devi usare tipo {00FF00}Nome_Cognome{AFAFAF})", Player[playerid][Name]);
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
- }
- else if(RPnamecheck(playerid))
- {
- g_MysqlRaceCheck[playerid]++;
- // reset player data
- static const empty_player[E_PLAYERS];
- Player[playerid] = empty_player;
- GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
- // send a query to recieve all the stored player data from the table
- new query[103];
- mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
- mysql_tquery(g_SQL, query, "OnPlayerDataLoaded", "dd", playerid, g_MysqlRaceCheck[playerid]);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- g_MysqlRaceCheck[playerid]++;
- UpdatePlayerData(playerid, reason);
- UpdatePlayerWeapons(playerid);
- // if the player was kicked (either wrong password or taking too long) during the login part, remove the data from the memory
- if (cache_is_valid(Player[playerid][Cache_ID]))
- {
- cache_delete(Player[playerid][Cache_ID]);
- Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
- }
- // if the player was kicked before the time expires (30 seconds), kill the timer
- if (Player[playerid][LoginTimer])
- {
- KillTimer(Player[playerid][LoginTimer]);
- Player[playerid][LoginTimer] = 0;
- }
- // sets "IsLoggedIn" to false when the player disconnects, it prevents from saving the player data twice when "gmx" is used
- Player[playerid][IsLoggedIn] = false;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- // spawn the player to their last saved position
- SetPlayerInterior(playerid, Player[playerid][Interior]);
- SetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]);
- SetPlayerFacingAngle(playerid, Player[playerid][A_Pos]);
- SetCameraBehindPlayer(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- UpdatePlayerDeaths(playerid);
- UpdatePlayerKills(killerid);
- return 1;
- }
- //-------------------------------------------
- // dialoghi
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new const SECURITY_QUESTIONS[][MAX_SECURITY_QUESTION_SIZE] =
- {
- "What was your childhood nickname?",
- "What is the name of your favorite childhood friend?",
- "In what city or town did your mother and father meet?",
- "What is the middle name of your oldest child?",
- "What is your favorite team?",
- "What is your favorite movie?",
- "What is the first name of the boy or girl that you first kissed?",
- "What was the make and model of your first car?",
- "What was the name of the hospital where you were born?",
- "Who is your childhood sports hero?",
- "In what town was your first job?",
- "What was the name of the company where you had your first job?",
- "What school did you attend for sixth grade?",
- "What was the last name of your third grade teacher?"
- };
- switch (dialogid)
- {
- case DIALOG_UNUSED: return 1; // Useful for dialogs that contain only information and we do nothing depending on whether they responded or not
- case DIALOG_LOGIN:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- new hashed_pass[65];
- SHA256_PassHash(inputtext, Player[playerid][Salt], hashed_pass, 65);
- if (strcmp(hashed_pass, Player[playerid][Password]) == 0)
- {
- //correct password, spawn the player
- ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Login con successo.", "Okay", "");
- // sets the specified cache as the active cache so we can retrieve the rest player data
- cache_set_active(Player[playerid][Cache_ID]);
- AssignPlayerData(playerid);
- // remove the active cache from memory and unsets the active cache as well
- cache_delete(Player[playerid][Cache_ID]);
- Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
- KillTimer(Player[playerid][LoginTimer]);
- Player[playerid][LoginTimer] = 0;
- Player[playerid][IsLoggedIn] = true;
- // spawn the player to their last saved position after login
- SetSpawnInfo(playerid, NO_TEAM, 0, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- }
- else
- {
- Player[playerid][LoginAttempts]++;
- if (Player[playerid][LoginAttempts] >= 3)
- {
- ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Hai superato i tentativi di accesso (3 tentativi).", "Okay", "");
- DelayedKick(playerid);
- }
- else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{FF0000}Password errata!\n{AFAFAF}Inserisci la password per entrare:", "Login", "Annulla");
- }
- }
- // Dialog - registrazione 1/6 password
- case DIALOG_REGISTER:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- if (strlen(inputtext) <= 5) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrazione... [Step: 1/6]", "{FF0000}[ERRORE:]Hai inserito una password troppo corta, usa almeno 5 caratteri!\n{AFAFAF}Inserisci una password per registrarti:", "Continua", "Annulla");
- // 16 random characters from 33 to 126 (in ASCII) for the salt
- for (new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
- SHA256_PassHash(inputtext, Player[playerid][Salt], Player[playerid][Password], 65);
- new query[221];
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`) VALUES ('%e', '%s', '%e')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt]);
- // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
- new string[128];
- format(string, sizeof(string), "{AFAFAF}[INFO:] Ricorda la tua password è: {f4b642}'%s'", inputtext);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
- format(string, sizeof(string), "{AFAFAF}[INFO:] Puoi cambiarla in game con il comando {ff0000}/cambia -> PASSWORD");
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
- ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... [Step: 2/6]", "Inserisci l'età che vuoi avere nel server\nNon influenzerà il gioco", "Continua", "Annulla");
- }
- // Dialog - registrazione 2/6 età
- case DIALOG_REGISTER_AGE:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- if (!strlen(inputtext))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... età [Step: 2/6]", "{FF0000}[ERRORE:]Devi inserire l'età per continuare!\n{AFAFAF}Non influenzerà il gioco:", "Continua", "Annulla");
- return 1;
- }
- else if (strlen(inputtext))
- {
- if (!IsNumeric(inputtext))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... età [Step: 2/6]", "{FF0000}[ERRORE:]Devi inserire un numero per l'età!\n{AFAFAF}Non influenzerà il gioco:", "Continua", "Annulla");
- return 1;
- }
- else if (IsNumeric(inputtext))
- {
- new eta = strval(inputtext);
- if(eta < 18 || eta > 75)
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... età [Step: 2/6]", "{FF0000}[ERRORE:]Devi inserire un'età compresa tra 18 e 75!\n{AFAFAF}Non influenzerà il gioco:", "Continua", "Annulla");
- }
- else
- {
- new query[221];
- Player[playerid][Age] = strval(inputtext);
- //format(query, sizeof(query), "UPDATE `players` SET `age` = %d WHERE `id` = %d LIMIT 1", strval(inputtext), Player[playerid][ID]);
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`) VALUES ('%e', '%s', '%e', '%d', '%d')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age]);
- new string[128];
- format(string, sizeof(string), "{AFAFAF}[INFO:] Hai %d anni.", strval(inputtext));
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
- ShowPlayerDialog(playerid, DIALOG_REGISTER_SEX, DIALOG_STYLE_LIST, "Seleziona il sesso", "{FF6666}Donna\n{0000cc}Uomo", "Continua", "");
- }
- }
- }
- }
- // Dialog - registrazione 3/6 sesso
- case DIALOG_REGISTER_SEX:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- switch(listitem)// Dialog: registrazione fase 3: sesso
- {
- case 0: // Registrazione sesso: selezionato: donna
- {
- // Player[playerid][Sex] = 1; // 1 = donna
- format(Player[playerid][Sex], 64, "Donna");
- new query[221];
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`) VALUES ('%e', '%s', '%e', '%d', '%d')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex]);
- // format(query, sizeof(query), "UPDATE `players` SET `sex` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Sex], Player[playerid][ID]);
- // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
- new Messaggio[256];
- format(Messaggio, sizeof (Messaggio), "{AFAFAF}[INFO]: %s sei {FF6666}una donna", Player[playerid][Name]);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, Messaggio);
- ShowPlayerDialog(playerid, DIALOG_REGISTER_EMAIL, DIALOG_STYLE_INPUT, "Registrazione - email [4/7]", "{FFFFFF}Inserisci una mail per proteggere l'account\nServirà in caso volessi cambiare la password o la domanda di sicurezza e la risposta\n{AFAFAF}Quest'ultima verrà mostrata solo a te stesso, usa una mail a cui puoi accedere", "Continua", "Annula");
- PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
- }
- case 1: // Registrazione sesso: selezionato: uomo
- {
- // Player[playerid][Sex] = 2; // 2 = uomo
- format(Player[playerid][Sex], 64, "Uomo");
- new query[221];
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`) VALUES ('%e', '%s', '%e', '%d', '%d')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex]);
- //format(query, sizeof(query), "UPDATE `players` SET `sex` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Sex], Player[playerid][ID]);
- // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
- new Messaggio[256];
- format(Messaggio, sizeof (Messaggio), "[INFO]: %s sei {0000cc}un uomo", Player[playerid][Name]);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, Messaggio);
- ShowPlayerDialog(playerid, DIALOG_REGISTER_EMAIL, DIALOG_STYLE_INPUT, "Registrazione - email [4/7]", "{FFFFFF}Inserisci una mail per proteggere l'account\nServirà in caso volessi cambiare la password o la domanda di sicurezza e la risposta\n{AFAFAF}Quest'ultima verrà mostrata solo a te stesso, usa una mail a cui puoi accedere", "Continua", "Annula");
- PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
- //******
- }
- }
- }
- case DIALOG_REGISTER_EMAIL:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- else
- {
- if (IsEmailString(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER_EMAIL, DIALOG_STYLE_INPUT, "Registrazione... [Step: 4/6]", "{FF0000}[ERRORE:]Devi inserire una mail valida\n{AFAFAF}Servirà per proteggere il tuo acount e cambiare domanda e/o risposta di sicurezza:", "Continua", "Annulla");
- // new query[221];
- new StringEmail[64];
- format(StringEmail, sizeof(StringEmail), "[INFO]: La tua email sarà %s", inputtext);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, StringEmail);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Puoi cambiarla con il comando /cambia -> email");
- format(Player[playerid][PlayerEmail], 128, inputtext);
- // mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`, `email`) VALUES ('%e', '%s', '%e', '%d', '%d', '%s')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex], Player[playerid][PlayerEmail]);
- // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
- new list[2 + (sizeof(SECURITY_QUESTIONS) * MAX_SECURITY_QUESTION_SIZE)];
- for (new i; i < sizeof(SECURITY_QUESTIONS); i++)
- {
- strcat(list, SECURITY_QUESTIONS[i]);
- strcat(list, "\n");
- }
- ShowPlayerDialog(playerid, DIALOG_REGISTER_DOMANDASEC, DIALOG_STYLE_LIST, "Registrazione - Domanda di sicurezza", list, "Continua", "Annulla");
- }
- }
- case DIALOG_REGISTER_DOMANDASEC:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- else
- {
- format(Player[playerid][e_USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE, SECURITY_QUESTIONS[listitem]);
- new query[1024]; //221
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`, `email`, `domandasec`) VALUES ('%e', '%s', '%e', '%d', '%d', '%s', '%e')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex], Player[playerid][PlayerEmail], Player[playerid][e_USER_SECURITY_QUESTION]);
- new string[128];
- format(string, sizeof(string), "{AFAFAF}Hai selezionato come domanda di sicurezza:\n%s\n{FFFFFF}Inserisci una risposta di sicurezza", Player[playerid][e_USER_SECURITY_QUESTION]);
- ShowPlayerDialog(playerid, DIALOG_REGISTER_RISPOSTASEC, DIALOG_STYLE_INPUT, "Registrazione - Domanda di sicurezza [6/6]", string, "Continua", "Annuila");
- }
- }
- case DIALOG_REGISTER_RISPOSTASEC:
- {
- if (!response)
- {
- Kick(playerid);
- return 1;
- }
- else
- {
- new string[128];
- format(string, sizeof(string), "{FF0000}Devi inserire una risposta alla domanda di sicurezza!\n{AFAFAF}Hai selezionato come domanda di sicurezza:\n%s\n{FFFFFF}Inserisci una risposta di sicurezza", Player[playerid][e_USER_SECURITY_QUESTION]);
- if (strlen(inputtext) <= 2) return ShowPlayerDialog(playerid, DIALOG_REGISTER_RISPOSTASEC, DIALOG_STYLE_INPUT, "Registrazione - Domanda di sicurezza [6/6]", string, "Continua", "Annuila");
- format(Player[playerid][e_USER_SECURITY_ANSWER], 128, inputtext);
- new query[1024];
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`, `email`, `domandasec`, `rispostasec`) VALUES ('%e', '%s', '%e', '%d', '%d', '%s', '%e', '%s')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex], Player[playerid][PlayerEmail], Player[playerid][e_USER_SECURITY_QUESTION], Player[playerid][e_USER_SECURITY_ANSWER]);
- mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
- }
- }
- case DIALOG_PROVA:
- {
- GivePlayerMoney(playerid, strval(inputtext));
- return 1;
- }
- default: return 0; // dialog ID was not found, search in other scripts
- }
- return 1;
- }
- //-----------------------------------------------------
- // controllo se una string è numerica
- IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- // controllo se una string è numerica
- IsEmailString(const string[])
- {/*
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] == '@') return 0;
- }*/
- // if(strfind(pname,"[",true) != (-1)) return 0;
- if(strfind(string,"@",true) && strfind(string,".com",true) != (-1)) return 0;
- return 1;
- }
- forward OnPlayerDataLoaded(playerid, race_check);
- public OnPlayerDataLoaded(playerid, race_check)
- {
- /* race condition check:
- player A connects -> SELECT query is fired -> this query takes very long
- while the query is still processing, player A with playerid 2 disconnects
- player B joins now with playerid 2 -> our laggy SELECT query is finally finished, but for the wrong player
- what do we do against it?
- we create a connection count for each playerid and increase it everytime the playerid connects or disconnects
- we also pass the current value of the connection count to our OnPlayerDataLoaded callback
- then we check if current connection count is the same as connection count we passed to the callback
- if yes, everything is okay, if not, we just kick the player
- */
- if (race_check != g_MysqlRaceCheck[playerid]) return Kick(playerid);
- new string[115];
- if(cache_num_rows() > 0)// Giocatore registrato sul server
- {
- cache_get_value(0, "password", Player[playerid][Password], 65);
- cache_get_value(0, "salt", Player[playerid][Salt], 17);
- Player[playerid][Cache_ID] = cache_save();
- format(string, sizeof string, "%s risulta registrato sul server.\nInserisci la password per entrare:", Player[playerid][Name]);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Annulla");
- Player[playerid][LoginTimer] = SetTimerEx("OnLoginTimeout", SECONDS_TO_LOGIN * 1000, false, "d", playerid);
- }
- else // Giocatore non registrato sul server
- {
- format(string, sizeof string, "Benvenuto %s,\nPer iniziare a registrarti su %s, inserisci una password", Player[playerid][Name], nomeserver);
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrazione [1/6]", string, "Continua", "Annulla");
- }
- return 1;
- }
- forward OnLoginTimeout(playerid);
- public OnLoginTimeout(playerid)
- {
- // reset the variable that stores the timerid
- Player[playerid][LoginTimer] = 0;
- ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Sei stato kickato dal server per aver impiegato troppo tempo nel loggarti.", "Okay", "");
- DelayedKick(playerid);
- return 1;
- }
- // prova timer
- forward KickTimerNameRP(playerid);
- public KickTimerNameRP(playerid)
- {
- Kick(playerid);
- }
- //-----------------------------------------------------
- // stocks
- // Stock per mandare un messaggio agli admin
- stock SendMessageToAdmins(text[])
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(Player[i][Admin] >= 1)
- {
- SendClientMessage(i, COLOR_SYSTEM_ADMIN, text);
- }
- }
- }
- // Stock chat staff
- stock ChatStaffMember(text[])
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(Player[i][Admin] >= 1)
- {
- SendClientMessage(i, COLOR_SYSTEM_ADMIN, text);
- }
- }
- }
- forward OnPlayerRegister(playerid);
- public OnPlayerRegister(playerid)
- {
- // retrieves the ID generated for an AUTO_INCREMENT column by the sent query
- Player[playerid][ID] = cache_insert_id();
- ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Registration", "Account successfully registered, you have been automatically logged in.", "Okay", "");
- Player[playerid][IsLoggedIn] = true;
- format(Player[playerid][PatenteA], 64, "Si");
- format(Player[playerid][PatenteB], 64, "Si");
- format(Player[playerid][PatenteC], 64, "Si");
- format(Player[playerid][PatenteD], 64, "Si");
- format(Player[playerid][PortoDarmi], 64, "No");
- Player[playerid][X_Pos] = DEFAULT_POS_X;
- Player[playerid][Y_Pos] = DEFAULT_POS_Y;
- Player[playerid][Z_Pos] = DEFAULT_POS_Z;
- Player[playerid][A_Pos] = DEFAULT_POS_A;
- Player[playerid][Interior] = DEFAULT_POS_INTERIOR;
- SetSpawnInfo(playerid, NO_TEAM, 0, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0);
- SetPlayerInterior(playerid, DEFAULT_POS_INTERIOR);
- SpawnPlayer(playerid);
- return 1;
- }
- forward _KickPlayerDelayed(playerid);
- public _KickPlayerDelayed(playerid)
- {
- Kick(playerid);
- return 1;
- }
- //-----------------------------------------------------
- // login player
- AssignPlayerData(playerid)
- { // quando il player effettua il login
- // ID
- cache_get_value_int(0, "id", Player[playerid][ID]);
- // Kill fatte
- cache_get_value_int(0, "kills", Player[playerid][Kills]);
- // Patente A
- cache_get_value_name(0, "patentea", Player[playerid][PatenteA], 64);
- // Patente B
- cache_get_value_name(0, "patenteb", Player[playerid][PatenteB], 64);
- // Patente C
- cache_get_value_name(0, "patentec", Player[playerid][PatenteC], 64);
- // Patente D
- cache_get_value_name(0, "patented", Player[playerid][PatenteD], 64);
- // Porto D'armi
- cache_get_value_name(0, "portodarmi", Player[playerid][PortoDarmi], 64);
- // Soldi
- cache_get_value_int(0, "soldi", Player[playerid][Soldi]);
- // Numero di morti
- cache_get_value_int(0, "deaths", Player[playerid][Deaths]);
- // Livello admin
- cache_get_value_int(0, "admin", Player[playerid][Admin]);
- // Se in servizio admin
- cache_get_value_int(0, "aduty", Player[playerid][ADuty]);
- // Sesso
- cache_get_value_name(0, "sex", Player[playerid][Sex], 64);
- // Età
- cache_get_value_int(0, "age", Player[playerid][Age]);
- // Ultima posizione 'X'
- cache_get_value_float(0, "x", Player[playerid][X_Pos]);
- // Ultima posizione 'Y'
- cache_get_value_float(0, "y", Player[playerid][Y_Pos]);
- // Ultima posizione 'Z'
- cache_get_value_float(0, "z", Player[playerid][Z_Pos]);
- // Ultima posizione 'Angolo visuale'
- cache_get_value_float(0, "angle", Player[playerid][A_Pos]);
- // Vita
- cache_get_value_float(0, "vita", Player[playerid][Vita]);
- // Armatura
- cache_get_value_float(0, "armatura", Player[playerid][Armatura]);
- // Ultima posizione 'Interior'
- cache_get_value_int(0, "interior", Player[playerid][Interior]);
- // Domanda di sicurezza scelta
- cache_get_value_name(0, "domandasec", Player[playerid][e_USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE);
- // Risposta alla domanda di sicurezza
- cache_get_value_name(0, "rispostasec", Player[playerid][e_USER_SECURITY_ANSWER], 128);
- // Email
- cache_get_value_name(0, "email", Player[playerid][PlayerEmail], 128);
- // setting statistiche
- GivePlayerMoney(playerid, Player[playerid][Soldi]);
- SetPlayerHealth(playerid, Player[playerid][Vita]);
- SetPlayerArmour(playerid, Player[playerid][Armatura]);
- GivePlayerSavedWeapons(playerid, weaponid, ammo);
- return 1;
- }
- DelayedKick(playerid, time = 500)
- {
- SetTimerEx("_KickPlayerDelayed", time, false, "d", playerid);
- return 1;
- }
- SetupPlayerTable()
- {
- mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(24) NOT NULL,`password` char(64) NOT NULL,`salt` char(16) NOT NULL,`kills` mediumint(8) NOT NULL DEFAULT '0',`deaths` mediumint(8) NOT NULL DEFAULT '0',`x` float NOT NULL DEFAULT '0',`y` float NOT NULL DEFAULT '0',`z` float NOT NULL DEFAULT '0',`angle` float NOT NULL DEFAULT '0',`interior` tinyint(3) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`))");
- return 1;
- }
- UpdatePlayerData(playerid, reason)
- {
- if (Player[playerid][IsLoggedIn] == false) return 0;
- // if the client crashed, it's not possible to get the player's position in OnPlayerDisconnect callback
- // so we will use the last saved position (in case of a player who registered and crashed/kicked, the position will be the default spawn point)
- if (reason == 1)
- {
- GetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]);
- GetPlayerFacingAngle(playerid, Player[playerid][A_Pos]);
- }
- new query[145];
- mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `x` = %f, `y` = %f, `z` = %f, `angle` = %f, `interior` = %d WHERE `id` = %d LIMIT 1", Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], GetPlayerInterior(playerid), Player[playerid][ID]);
- mysql_tquery(g_SQL, query);
- return 1;
- }
- UpdatePlayerWeapons(playerid)
- {
- new
- weaponid,
- munizioni;
- for(new i; i < 13; i++) // looping through all weapon slots (0 - 12)
- {
- GetPlayerWeaponData(playerid, i, weaponid, munizioni); // get weaponid and ammo
- if(!weaponid) continue; // don't insert if there's no weapon in this slot
- new query[145];
- mysql_format(g_SQL, query, sizeof query, "INSERT INTO armi VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE munizioni = %d;", Player[playerid][ID], weaponid, munizioni, munizioni);
- mysql_tquery(g_SQL, query);
- }
- return 1;
- }
- GivePlayerSavedWeapons(playerid, weaponid, ammo)
- {
- new
- weaponid,
- ammo;
- for(new i, j = cache_get_row_count(dbrp); i < j; i++) // loop through all the rows that were found
- {
- weaponid = cache_get_row_int(i, 0, dbrp);
- ammo = cache_get_row_int(i, 1, dbrp);
- if(!(0 <= weaponid <= 46)) // check if weapon is valid (should be)
- {
- printf("[info] Warning: OnLoadPlayerWeapons - Unknown weaponid '%d'. Skipping.", weaponid);
- continue;
- }
- GivePlayerWeapon(playerid, weaponid, ammo);
- }
- return 1;
- }
- UpdatePlayerDeaths(playerid)
- {
- if (Player[playerid][IsLoggedIn] == false) return 0;
- Player[playerid][Deaths]++;
- new query[70];
- mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `deaths` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Deaths], Player[playerid][ID]);
- mysql_tquery(g_SQL, query);
- return 1;
- }
- UpdatePlayerKills(killerid)
- {
- // we must check before if the killer wasn't valid (connected) player to avoid run time error 4
- if (killerid == INVALID_PLAYER_ID) return 0;
- if (Player[killerid][IsLoggedIn] == false) return 0;
- Player[killerid][Kills]++;
- new query[70];
- mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `kills` = %d WHERE `id` = %d LIMIT 1", Player[killerid][Kills], Player[killerid][ID]);
- mysql_tquery(g_SQL, query);
- return 1;
- }
- //-----------------------------------------------------------------------
- // comandi - zcmd
- CMD:adminchat(playerid, params[])
- {
- if(Player[playerid][Admin] >= 1)
- {// Se è un membro dellos taff
- // se int è uguale a 0 (non in servizio) cambia l'int in 1 - entra in servizio
- new
- Messaggio[128],
- NomeUtente[MAX_PLAYER_NAME];
- GetPlayerName(playerid, NomeUtente, MAX_PLAYER_NAME);
- if (sscanf(params, "s[128]", Messaggio))
- {
- return SendClientMessage(playerid, COLOR_INFO, "[INFO]: /adminchat (Messaggio)");
- }
- format(Messaggio, sizeof(Messaggio), "[ADMIN CHAT] %s(%d): %s", NomeUtente, playerid, Messaggio);
- ChatStaffMember(Messaggio);
- }
- else if(Player[playerid][Admin] < 1)
- {// se no è uno dello staff
- new string[128];
- format(string, sizeof(string), "[ERRORE]: Mi dispiace %s non sei autorizzato ad usare questo comando", Player[playerid][Name]);
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
- return 1;
- }
- return 1;
- }
- COMMAND:admina(playerid, params[])
- {
- new
- option[128],
- item[128],
- amount[128],
- Messaggio[128];
- new TargetPlayerID;
- new GivingAmmount;
- new AdminName[MAX_PLAYER_NAME],
- TargetPlayerName[MAX_PLAYER_NAME];
- // Nome dell'admin
- GetPlayerName(playerid, AdminName, MAX_PLAYER_NAME);
- // Nome del giocatore selezionato
- GetPlayerName(TargetPlayerID, TargetPlayerName, MAX_PLAYER_NAME);
- //----
- sscanf(params, "s[128]s[128]s[128]", option, item, amount);
- if (isnull(option))
- {
- SendClientMessage(playerid, COLOR_WHITE, "[INFO]: Uso comando /admina [Opzione]");
- SendClientMessage(playerid, COLOR_WHITE, "Opzioni: Dai | Set");
- return 1;
- }
- if (!strcmp(option, "dai") || !strcmp(option, "Dai"))
- { // Comando: /admin give [opzione]
- if (isnull(item))
- {
- SendClientMessage(playerid, COLOR_WHITE, "[INFO]: Uso comando /admin give [Opzione]");
- SendClientMessage(playerid, COLOR_WHITE, "Opzioni: Soldi");
- return 1;
- }
- if (!strcmp(item, "soldi") || strcmp(item, "Soldi"))
- { // Comando: /admin give soldi [Quantità]
- if(sscanf(amount,"ui", TargetPlayerID, GivingAmmount))
- {
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR , "[INFO]: Uso comando /admina dai soldi [ID/NOME][QUANTITA']");
- return 1;
- }
- if(!IsPlayerConnected(TargetPlayerID))
- { // Messaggio d'errore se: giocatore non trovato/connesso
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
- return 1;
- }
- else
- { // se il giocatore è connesso
- if(GivingAmmount >= 1)
- {
- GivePlayerMoney(TargetPlayerID, GivingAmmount);
- // MEssaggio all'utente selezionato
- format(Messaggio, sizeof (Messaggio), "[ADMIN]: %s ti ha givvato %i$", AdminName, GivingAmmount );
- SendClientMessage(TargetPlayerID, 0x33FF33AA, Messaggio);
- // Messaggio all'ADMIN
- format(Messaggio, sizeof (Messaggio), "[INFO]: Hai givvato %i$ all'utente %s", GivingAmmount, TargetPlayerName );
- SendClientMessage(playerid, 0x33FF33AA, Messaggio);
- return 1;
- }
- else if(GivingAmmount < 0)
- {
- new StringSoldi[64];
- format(StringSoldi, sizeof(StringSoldi), "{FF0000}[ERRORE]: {AFAFAF} Non puoi givvare $i, per togliere soldi usa /admina togli soldi", GivingAmmount);
- SendClientMessage(playerid, -1, StringSoldi);
- return 1;
- }
- }
- }
- else if (!strcmp(item, "armatura") || (!strcmp(item, "Armatura")))
- {
- if(sscanf(amount,"u", TargetPlayerID))
- {
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR , "[INFO]: Uso comando /admina set armatura [ID/NOME]");
- return 1;
- }
- if(!IsPlayerConnected(TargetPlayerID))
- { // Messaggio d'errore se: giocatore non trovato/connesso
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
- return 1;
- }
- else
- { // Comando effettuato con successo
- SetPlayerArmour(TargetPlayerID, 100);
- // MEssaggio all'utente selezionato
- format(Messaggio, sizeof (Messaggio), "[ADMIN]: %s ti ha settato l'armatura al 100%", AdminName );
- SendClientMessage(TargetPlayerID, 0x33FF33AA, Messaggio);
- // Messaggio all'ADMIN
- format(Messaggio, sizeof (Messaggio), "[INFO]: Hai settato l'armatura all'utente %s", TargetPlayerName );
- SendClientMessage(playerid, 0x33FF33AA, Messaggio);
- return 1;
- }
- }
- else if (!strcmp(item, "money"))
- {
- // Code for the money...
- }
- }
- else if (!strcmp(option, "set"))
- {
- if (isnull(item))
- {
- SendClientMessage(playerid, COLOR_WHITE, "[INFO]: uso comando /admina set [Opzione]");
- SendClientMessage(playerid, COLOR_WHITE, "Opzioni: Gun, Drugs, Money");
- return 1;
- }
- if (!strcmp(item, "armatura") || (!strcmp(item, "Armatura")))
- {
- if(sscanf(amount,"u", TargetPlayerID))
- {
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR , "[INFO]: Uso comando /admina set armatura [ID/NOME]");
- return 1;
- }
- if(!IsPlayerConnected(TargetPlayerID))
- { // Messaggio d'errore se: giocatore non trovato/connesso
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
- return 1;
- }
- else
- { // Comando effettuato con successo
- SetPlayerArmour(TargetPlayerID, 100);
- // MEssaggio all'utente selezionato
- format(Messaggio, sizeof (Messaggio), "[ADMIN]: %s ti ha settato l'armatura al 100%", AdminName );
- SendClientMessage(TargetPlayerID, 0x33FF33AA, Messaggio);
- // Messaggio all'ADMIN
- format(Messaggio, sizeof (Messaggio), "[INFO]: Hai settato l'armatura all'utente %s", TargetPlayerName );
- SendClientMessage(playerid, 0x33FF33AA, Messaggio);
- return 1;
- }
- }
- else if (!strcmp(item, "drugs"))
- {
- // Code for the drugs...
- }
- else if (!strcmp(item, "money"))
- {
- // Code for the money...
- }
- }
- return 1;
- }
- // admin give fine
- CMD:report(playerid, params[]) {
- new id; // id player reportato
- new reason[128]; // Ragione del report
- if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[SERVER] - USAGE: /report [ID] [REASON]");
- new string[150], // stringa messaggio report
- sender[MAX_PLAYER_NAME], // Nome di chi manda il report
- receiver[MAX_PLAYER_NAME]; // Chi riceve il report
- GetPlayerName(playerid, sender, sizeof(sender));
- GetPlayerName(id, receiver, sizeof(receiver));
- format(string, sizeof(string), "[ADMIN]: %s(%d) ha reportato %s(%d)", sender, playerid, receiver, id);
- SendMessageToAdmins(string);
- format(string, sizeof(string), "[ADMIN]: Motivo: %s", reason);
- SendMessageToAdmins(string);
- SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, "[INFO]: Il tuo report è stato inviato.");
- return 1;
- }
- CMD:stats(playerid, params[])
- {
- new StatsString[512];
- new StatsLicense[1500];
- format(StatsString, sizeof(StatsString), "[STATISTICHE] - Ecco le tue informazioni %s", Player[playerid][Name]);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, StatsString);
- format(StatsLicense, sizeof(StatsLicense), "[License] - Patente A: %s | Patente B: %s | Patente C: %s | Patente D: %s | Porto d'armi: %s", Player[playerid][PatenteA], Player[playerid][PatenteB], Player[playerid][PatenteC], Player[playerid][PatenteD], Player[playerid][PortoDarmi]);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, StatsLicense);
- return 1;
- }
- CMD:aiuto(playerid, params[])
- {
- new
- MessaggioAiuto[128],
- NomeUtente[MAX_PLAYER_NAME];
- GetPlayerName(playerid, NomeUtente, MAX_PLAYER_NAME);
- if (sscanf(params, "s[128]", MessaggioAiuto))
- {
- return SendClientMessage(playerid, COLOR_INFO, "[INFO]: /aiuto (Messaggio di aiuto)");
- }
- format(MessaggioAiuto, sizeof(MessaggioAiuto), "[AIUTO]: %s(%d): %s", Player[playerid][PatenteA], playerid, MessaggioAiuto); // NomeUtente
- SendMessageToAdmins(MessaggioAiuto);
- SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Il tuo messaggio è stato mandato");
- return 1;
- }
- CMD:aduty(playerid, params[])
- {
- if(Player[playerid][Admin] >= 1)
- {// Se è un membro dellos taff
- // se int è uguale a 0 (non in servizio) cambia l'int in 1 - entra in servizio
- if(Player[playerid][ADuty] == 0)
- {// entra in servizio
- TextDrawShowForPlayer(playerid,AdminInDuty);
- SetPlayerArmour(playerid, 10000);
- SetPlayerHealth(playerid, 10000);
- new ADutyString[64];
- format(ADutyString, sizeof(ADutyString), "[ADMIN]: L'admin %s è in servizio", Player[playerid][Name]);
- SendClientMessageToAll(COLOR_SYSTEM_ADMIN, ADutyString);
- Player[playerid][ADuty] = 1;
- return 1;
- }
- // se int è uguale a 1 (in servizio) cambia l'int in 0 - esce dal servizio
- if(Player[playerid][ADuty] == 1)
- {// esce dal servizio
- TextDrawHideForPlayer(playerid,AdminInDuty);
- SetPlayerArmour(playerid, Player[playerid][Armatura]);
- SetPlayerHealth(playerid, Player[playerid][Vita]);
- new ADutyString[64];
- format(ADutyString, sizeof(ADutyString), "[ADMIN]: L'admin %s non è più in servizio", Player[playerid][Name]);
- SendClientMessageToAll(COLOR_SYSTEM_ADMIN, ADutyString);
- Player[playerid][ADuty] = 0;
- return 1;
- }
- }
- else if(Player[playerid][Admin] < 1)
- {// se no è uno dello staff
- new string[128];
- format(string, sizeof(string), "[ERRORE]: Mi dispiace %s non sei autorizzato ad usare questo comando", Player[playerid][Name]);
- SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
- return 1;
- }
- return 1;
- }
- CMD:suicidio(playerid, params[])
- {
- SetPlayerHealth(playerid, 0);
- return 1;
- }
- public OnPlayerRequestClass(playerid,classid)
- { // quando un giocatore si registra/logga
- // SetPlayerPos(playerid, 982.1890, -1624.2583, 14.9526); // posizione dafault las venturas
- SetPlayerPos(playerid, -1965.3541, 158.4787, 27.6940);
- SetPlayerFacingAngle(playerid, 90.0000);
- return 1;
- }
Add Comment
Please, Sign In to add comment