Guest User

Untitled

a guest
Jan 27th, 2019
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. // change MAX_PLAYERS to the amount of players (slots) you want
  3. // It is by default 1000 (as of 0.3.7 version)
  4. /*
  5. #undef MAX_PLAYERS
  6. #define MAX_PLAYERS 500
  7. */
  8.  
  9. #undef MAX_PLAYERS
  10. #define MAX_PLAYERS 20
  11.  
  12.  
  13. //----------
  14. // INCLUDE
  15. #include <a_mysql>
  16. #include <zcmd>
  17. #include <sscanf2>
  18.  
  19. // Define
  20. // stili dialogo
  21. #define d_input DIALOG_STYLE_INPUT
  22. #define d_list DIALOG_STYLE_LIST
  23.  
  24. // Configurazione MySQL
  25. #define MYSQL_HOST "127.0.0.1"
  26. #define MYSQL_USER "root"
  27. #define MYSQL_PASSWORD "Pass123!"
  28. #define MYSQL_DATABASE "dbrp"
  29.  
  30. //-------------
  31. // info server
  32. #define emailserver "asd@gmail.com"
  33. #define nomeserver "server bello"
  34.  
  35. #define MAX_SECURITY_QUESTION_SIZE 128
  36.  
  37. // Text draw
  38.  
  39. new Text:AdminInDuty;
  40.  
  41.  
  42.  
  43.  
  44. // colori
  45. // system color
  46. #define COLOR_SYSTEM_ERROR 0xAA3333AA
  47. #define COLOR_SYSTEM_TITLE 0xFFFFFFAA
  48. #define COLOR_SYSTEM_TEXT 0xFFFFFFAA
  49. #define COLOR_SYSTEM_SUCCESS 0x33AA33AA
  50. #define COLOR_SYSTEM_INFO 0xAFAFAFAA
  51. #define COLOR_SYSTEM_ADMIN 0xFFFF00AA
  52.  
  53. #define COL_STRING_ERROR "{FF0000}"
  54. #define COL_STRING_SUCCESS "{00FF00}"
  55. #define COLOR_RED 0xFF0000
  56. #define COLOR_INFO 0xAFAFAF
  57.  
  58. #define COLOR_WHITE (0xFFFFFFFF)
  59. #define COL_WHITE "{FFFFFF}"
  60.  
  61. #define COLOR_TOMATO (0xFF6347FF)
  62. #define COL_TOMATO "{FF6347}"
  63.  
  64. #define COLOR_YELLOW (0xFFDD00FF)
  65. #define COL_YELLOW "{FFDD00}"
  66.  
  67. #define COLOR_GREEN (0x00FF00FF)
  68. #define COL_GREEN "{00FF00}"
  69.  
  70. #define COLOR_DEFAULT (0xA9C4E4FF)
  71. #define COL_DEFAULT "{A9C4E4}"
  72.  
  73. // how many seconds until it kicks the player for taking too long to login
  74. #define SECONDS_TO_LOGIN 30
  75. #define NAME_CHECKER1 30
  76.  
  77. // default spawn point: Las Venturas (The High Roller)
  78. #define DEFAULT_POS_X -1974.8938
  79. #define DEFAULT_POS_Y 152.9418
  80. #define DEFAULT_POS_Z 25.6940
  81. #define DEFAULT_POS_A 270.1425
  82.  
  83. /*
  84. #define DEFAULT_POS_X 1958.3783
  85. #define DEFAULT_POS_Y 1343.1572
  86. #define DEFAULT_POS_Z 15.3746
  87. #define DEFAULT_POS_A 270.1425
  88.  
  89. -1974.8938, 152.9418, 27.6940
  90. */
  91.  
  92. // MySQL connection handle
  93. new MySQL: g_SQL;
  94.  
  95. // player data
  96. enum E_PLAYERS
  97. {
  98. ID,
  99. Name[MAX_PLAYER_NAME],
  100. 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
  101. Salt[17],
  102. Kills,
  103. Admin,
  104. Age,
  105. ADuty,
  106. Sex,
  107. Soldi,
  108. Deaths,
  109. Float:Vita,
  110. Float:Armatura,
  111. e_USER_SECURITY_QUESTION[MAX_SECURITY_QUESTION_SIZE],
  112. e_USER_SECURITY_ANSWER,
  113. PlayerEmail,
  114. Float: X_Pos,
  115. Float: Y_Pos,
  116. Float: Z_Pos,
  117. Float: A_Pos,
  118. Interior,
  119.  
  120. Cache: Cache_ID,
  121. bool: IsLoggedIn,
  122. LoginAttempts,
  123. LoginTimer
  124. };
  125. new Player[MAX_PLAYERS][E_PLAYERS];
  126.  
  127.  
  128. new g_MysqlRaceCheck[MAX_PLAYERS];
  129.  
  130. // dialog data
  131. enum
  132. {
  133. DIALOG_UNUSED,
  134. DIALOG_LOGIN,
  135. DIALOG_REGISTER,
  136. DIALOG_REGISTER_AGE,
  137. DIALOG_REGISTER_SEX,
  138. DIALOG_REGISTER_EMAIL,
  139. DIALOG_REGISTER_DOMANDASEC,
  140. DIALOG_REGISTER_RISPOSTASEC,
  141. DIALOG_PROVA
  142. };
  143.  
  144. // protocollo controllo nome RP
  145. stock RPnamecheck(playerid)
  146. {
  147. new pname[MAX_PLAYER_NAME],underline=0;
  148. GetPlayerName(playerid, pname, sizeof(pname));
  149. if(strfind(pname,"[",true) != (-1)) return 0;
  150. else if(strfind(pname,"]",true) != (-1)) return 0;
  151. else if(strfind(pname,"$",true) != (-1)) return 0;
  152. else if(strfind(pname,"(",true) != (-1)) return 0;
  153. else if(strfind(pname,")",true) != (-1)) return 0;
  154. else if(strfind(pname,"=",true) != (-1)) return 0;
  155. else if(strfind(pname,"@",true) != (-1)) return 0;
  156. else if(strfind(pname,"1",true) != (-1)) return 0;
  157. else if(strfind(pname,"2",true) != (-1)) return 0;
  158. else if(strfind(pname,"3",true) != (-1)) return 0;
  159. else if(strfind(pname,"4",true) != (-1)) return 0;
  160. else if(strfind(pname,"5",true) != (-1)) return 0;
  161. else if(strfind(pname,"6",true) != (-1)) return 0;
  162. else if(strfind(pname,"7",true) != (-1)) return 0;
  163. else if(strfind(pname,"8",true) != (-1)) return 0;
  164. else if(strfind(pname,"9",true) != (-1)) return 0;
  165. else if(strfind(pname,"fuck",true) != (-1)) return 0;
  166. else if(strfind(pname,"FUCK",true) != (-1)) return 0;
  167. else if(strfind(pname,"Boobies",true) != (-1)) return 0;
  168. else if(strfind(pname,"Tupac_Shakur",true) != (-1)) return 0;
  169. else if(strfind(pname,"Pussy",true) != (-1)) return 0;
  170. else if(strfind(pname,"Rape",true) != (-1)) return 0;
  171. else if(strfind(pname,"kill",true) != (-1)) return 0;
  172. else if(strfind(pname,"shit",true) != (-1)) return 0;
  173. else if(strfind(pname,"ass",true) != (-1)) return 0;
  174. else if(strfind(pname,"Jack_Black",true) != (-1)) return 0;
  175. else if(strfind(pname,"Max_Kenton",true) != (-1)) return 0;
  176. else if(strfind(pname,"Will_Smith",true) != (-1)) return 0;
  177. else if(strfind(pname,"Jaden_Smith",true) != (-1)) return 0;
  178. else if(strfind(pname,"Megan_Fox",true) != (-1)) return 0;
  179. else if(strfind(pname,"Charlie_Kenton",true) != (-1)) return 0;
  180. else if(strfind(pname,"Hugh_Hefner",true) != (-1)) return 0;
  181. else if(strfind(pname,"Paris_Hilton",true) != (-1)) return 0;
  182. else if(strfind(pname,"Marshall_Mathers",true) != (-1)) return 0;
  183. else if(strfind(pname,"Sheldon_Cooper",true) != (-1)) return 0;
  184. else if(strfind(pname,"Jet_Lee",true) != (-1)) return 0;
  185. else if(strfind(pname,"Jackie_Chan",true) != (-1)) return 0;
  186. else if(strfind(pname,"Chuck_Norris",true) != (-1)) return 0;
  187. else if(strfind(pname,"Peter_Parker",true) != (-1)) return 0;
  188. else if(strfind(pname,"Spider_Man",true) != (-1)) return 0;
  189. else if(strfind(pname,"Bat_Man",true) != (-1)) return 0;
  190. else if(strfind(pname,"Emma_Stone",true) != (-1)) return 0;
  191. else if(strfind(pname,"whore",true) != (-1)) return 0;
  192. else if(strfind(pname,"Hugh_Jackman",true) != (-1)) return 0;
  193. else if(strfind(pname,"Charles_Kenton",true) != (-1)) return 0;
  194. else if(strfind(pname,"Harry_Potter",true) != (-1)) return 0;
  195. else if(strfind(pname,"Chris_Hemsworth",true) != (-1)) return 0;
  196. else if(strfind(pname,"Penis",true) != (-1)) return 0;
  197. else if(strfind(pname,"_Dick",true) != (-1)) return 0;
  198. else if(strfind(pname,"Vagina",true) != (-1)) return 0;
  199. else if(strfind(pname,"Cock",true) != (-1)) return 0;
  200. else if(strfind(pname,"Rectum",true) != (-1)) return 0;
  201. else if(strfind(pname,"Sperm",true) != (-1)) return 0;
  202. else if(strfind(pname,"Rektum",true) != (-1)) return 0;
  203. else if(strfind(pname,"Pistol",true) != (-1)) return 0;
  204. else if(strfind(pname,"AK47",true) != (-1)) return 0;
  205. else if(strfind(pname,"Shotgun",true) != (-1)) return 0;
  206. else if(strfind(pname,"Cum",true) != (-1)) return 0;
  207. else if(strfind(pname,"Hitler",true) != (-1)) return 0;
  208. else if(strfind(pname,"Jesus",true) != (-1)) return 0;
  209. else if(strfind(pname,"God",true) != (-1)) return 0;
  210. else if(strfind(pname,"Shotgun",true) != (-1)) return 0;
  211. else if(strfind(pname,"Desert_Eagle",true) != (-1)) return 0;
  212. else if(strfind(pname,"fucker",true) != (-1)) return 0;
  213. else if(strfind(pname,"Retard",true) != (-1)) return 0;
  214. else if(strfind(pname,"Tarded",true) != (-1)) return 0;
  215. else if(strfind(pname,"fanny",true) != (-1)) return 0;
  216. else if(strfind(pname,"Daniel_Hardy",true) != (-1)) return 0;
  217. else if(strfind(pname,"abcdefghijklmnopqrstuvwxyz",true) != (-1)) return 0;
  218. new maxname = strlen(pname);
  219. for(new i=0; i<maxname; i++)
  220. {
  221. if(pname[i] == '_') underline ++;
  222. }
  223. if(underline != 1) return 0;
  224. pname[0] = toupper(pname[0]);
  225. for(new x=1; x<maxname; x++)
  226. {
  227. if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
  228. else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
  229. }
  230. SetPlayerName(playerid, "New_Name");
  231. SetPlayerName(playerid, pname);
  232. return 1;
  233. }
  234.  
  235. // forward
  236.  
  237.  
  238.  
  239. /*--------------------------------------------------------------|
  240. * Questa è la fine della sezione dei settaggi della GM |
  241. * Da qui in poi iniziano gli script
  242. * Non modificare dove indicato
  243. * Script GM 100% By: OuDayas
  244. * Versione attuale v 1.0
  245. * 2019
  246. *-------------------------------------------------------------*/
  247.  
  248. //-------------------------------------------
  249. main() {}
  250. public OnGameModeInit()
  251. {
  252. // Connessione al
  253. new MySQLOpt: option_id = mysql_init_options();
  254. mysql_set_option(option_id, AUTO_RECONNECT, true); // it automatically reconnects when loosing connection to mysql server
  255. g_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id); // AUTO_RECONNECT is enabled for this connection handle only
  256. if (g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0)
  257. {
  258. print("MySQL connection failed. Server is shutting down.");
  259. SendRconCommand("exit"); // close the server if there is no connection
  260. return 1;
  261. }
  262. print("MySQL connection is successful.");
  263.  
  264.  
  265. // text draws
  266. AdminInDuty = TextDrawCreate(102.606338, 313.833496, "ADMIN ON");
  267. TextDrawLetterSize(AdminInDuty, 0.506222, 1.518333);
  268. TextDrawAlignment(AdminInDuty, 3);
  269. TextDrawColor(AdminInDuty, -1);
  270. TextDrawUseBox(AdminInDuty, true);
  271. TextDrawBoxColor(AdminInDuty, 255);
  272. TextDrawSetShadow(AdminInDuty, 0);
  273. TextDrawSetOutline(AdminInDuty, 0);
  274. TextDrawBackgroundColor(AdminInDuty, 41215);
  275. TextDrawFont(AdminInDuty, 1);
  276. TextDrawSetProportional(AdminInDuty, 1);
  277.  
  278.  
  279.  
  280.  
  281. // if the table has been created, the "SetupPlayerTable" function does not have any purpose so you may remove it completely
  282. SetupPlayerTable();
  283. return 1;
  284. }
  285.  
  286. public OnGameModeExit()
  287. {
  288. // save all player data before closing connection
  289. 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
  290. {
  291. if (IsPlayerConnected(i))
  292. {
  293. // reason is set to 1 for normal 'Quit'
  294. OnPlayerDisconnect(i, 1);
  295. }
  296. }
  297.  
  298. mysql_close(g_SQL);
  299. return 1;
  300. }
  301.  
  302. // quando l'utente si connette al server
  303. public OnPlayerConnect(playerid)
  304. {
  305. if(!RPnamecheck(playerid))
  306. {
  307. SetTimerEx("KickTimerNameRP", 3000, 0, "d", playerid); // -1974.8938,152.9418,27.6940
  308. SetPlayerPos(playerid, -1974.8938,152.9418,27.6940); // 982.1890, -1624.2583, 14.9526
  309. SetPlayerFacingAngle(playerid, 90);
  310. new string[128], pname[MAX_PLAYER_NAME];
  311. GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  312. format(string, sizeof(string), "{FF0000}[INFO] Devi inserire un nome {00FF00}RP per entrare nel server");
  313. SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
  314. format(string, sizeof(string), "{AFAFAF}Il nome {FF0000}%s non è valido.{AFAFAF} (devi usare tipo {00FF00}Nome_Cognome{AFAFAF})", Player[playerid][Name]);
  315. SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
  316. }
  317. else if(RPnamecheck(playerid))
  318. {
  319. g_MysqlRaceCheck[playerid]++;
  320. // reset player data
  321. static const empty_player[E_PLAYERS];
  322. Player[playerid] = empty_player;
  323.  
  324. GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
  325.  
  326. // send a query to recieve all the stored player data from the table
  327. new query[103];
  328. mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
  329. mysql_tquery(g_SQL, query, "OnPlayerDataLoaded", "dd", playerid, g_MysqlRaceCheck[playerid]);
  330. }
  331. return 1;
  332. }
  333.  
  334. public OnPlayerDisconnect(playerid, reason)
  335. {
  336. g_MysqlRaceCheck[playerid]++;
  337.  
  338. UpdatePlayerData(playerid, reason);
  339.  
  340. // if the player was kicked (either wrong password or taking too long) during the login part, remove the data from the memory
  341. if (cache_is_valid(Player[playerid][Cache_ID]))
  342. {
  343. cache_delete(Player[playerid][Cache_ID]);
  344. Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
  345. }
  346.  
  347. // if the player was kicked before the time expires (30 seconds), kill the timer
  348. if (Player[playerid][LoginTimer])
  349. {
  350. KillTimer(Player[playerid][LoginTimer]);
  351. Player[playerid][LoginTimer] = 0;
  352. }
  353.  
  354. // sets "IsLoggedIn" to false when the player disconnects, it prevents from saving the player data twice when "gmx" is used
  355. Player[playerid][IsLoggedIn] = false;
  356. return 1;
  357. }
  358.  
  359. public OnPlayerSpawn(playerid)
  360. {
  361. // spawn the player to their last saved position
  362. // SetPlayerInterior(playerid, Player[playerid][Interior]);
  363. // SetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]);
  364. // SetPlayerFacingAngle(playerid, Player[playerid][A_Pos]);
  365. SetPlayerHealth(playerid, Player[playerid][Vita]);
  366. SetPlayerArmour(playerid, Player[playerid][Armatura]); // -1974.8938,152.9418,27.6940
  367. SetPlayerPos(playerid, -1974.8938,152.9418,25.6940); // -1962.4109, 138.0483, 27.6940
  368. SetCameraBehindPlayer(playerid);
  369. return 1;
  370. }
  371.  
  372. public OnPlayerDeath(playerid, killerid, reason)
  373. {
  374. UpdatePlayerDeaths(playerid);
  375. UpdatePlayerKills(killerid);
  376. return 1;
  377. }
  378.  
  379. //-------------------------------------------
  380. // dialoghi
  381. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  382. {
  383. new const SECURITY_QUESTIONS[][MAX_SECURITY_QUESTION_SIZE] =
  384. {
  385. "Domanda 1?",
  386. "Domanda 2?",
  387. "Domanda 3?"
  388. };
  389.  
  390. switch (dialogid)
  391. {
  392. case DIALOG_UNUSED: return 1; // Useful for dialogs that contain only information and we do nothing depending on whether they responded or not
  393.  
  394. case DIALOG_LOGIN:
  395. {
  396. if (!response)
  397. {
  398. Kick(playerid);
  399. return 1;
  400. }
  401.  
  402. new hashed_pass[65];
  403. SHA256_PassHash(inputtext, Player[playerid][Salt], hashed_pass, 65);
  404.  
  405. if (strcmp(hashed_pass, Player[playerid][Password]) == 0)
  406. {
  407. //correct password, spawn the player
  408. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Login con successo.", "Okay", "");
  409. // sets the specified cache as the active cache so we can retrieve the rest player data
  410. cache_set_active(Player[playerid][Cache_ID]);
  411. AssignPlayerData(playerid);
  412. // remove the active cache from memory and unsets the active cache as well
  413. cache_delete(Player[playerid][Cache_ID]);
  414. Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
  415.  
  416. KillTimer(Player[playerid][LoginTimer]);
  417. Player[playerid][LoginTimer] = 0;
  418. Player[playerid][IsLoggedIn] = true;
  419. // spawn the player to their last saved position after login
  420. 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);
  421. SpawnPlayer(playerid);
  422. }
  423. else
  424. {
  425. Player[playerid][LoginAttempts]++;
  426.  
  427. if (Player[playerid][LoginAttempts] >= 3)
  428. {
  429. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Hai superato i tentativi di accesso (3 tentativi).", "Okay", "");
  430. DelayedKick(playerid);
  431. }
  432. else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{FF0000}Password errata!\n{AFAFAF}Inserisci la password per entrare:", "Login", "Annulla");
  433. }
  434. }
  435. // Dialog - registrazione 1/6 password
  436. case DIALOG_REGISTER:
  437. {
  438. if (!response)
  439. {
  440. Kick(playerid);
  441. return 1;
  442. }
  443.  
  444. 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");
  445.  
  446. // 16 random characters from 33 to 126 (in ASCII) for the salt
  447. for (new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
  448. SHA256_PassHash(inputtext, Player[playerid][Salt], Player[playerid][Password], 65);
  449. new query[221];
  450. 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]);
  451. // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
  452. new string[128];
  453. format(string, sizeof(string), "{AFAFAF}[INFO:] Ricorda la tua password è: {f4b642}'%s'", inputtext);
  454. SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
  455. format(string, sizeof(string), "{AFAFAF}[INFO:] Puoi cambiarla in game con il comando {ff0000}/cambia -> PASSWORD");
  456. SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
  457. 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");
  458. }
  459. // Dialog - registrazione 2/6 età
  460. case DIALOG_REGISTER_AGE:
  461. {
  462. if (!response)
  463. {
  464. Kick(playerid);
  465. return 1;
  466. }
  467.  
  468. if (!strlen(inputtext))
  469. {
  470. 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");
  471. return 1;
  472. }
  473. else if (strlen(inputtext))
  474. {
  475. if (!IsNumeric(inputtext))
  476. {
  477. 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");
  478. return 1;
  479. }
  480. else if (IsNumeric(inputtext))
  481. {
  482. new eta = strval(inputtext);
  483. if(eta < 18 || eta > 75)
  484. {
  485. 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");
  486. }
  487. else
  488. {
  489. new query[1024];
  490. Player[playerid][Age] = strval(inputtext);
  491. //format(query, sizeof(query), "UPDATE `players` SET `age` = %d WHERE `id` = %d LIMIT 1", strval(inputtext), Player[playerid][ID]);
  492. 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]);
  493. new string[128];
  494. format(string, sizeof(string), "{AFAFAF}[INFO:] Hai %d anni.", strval(inputtext));
  495. SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
  496. ShowPlayerDialog(playerid, DIALOG_REGISTER_SEX, DIALOG_STYLE_LIST, "Seleziona il sesso", "{FF6666}Donna\n{0000cc}Uomo", "Continua", "");
  497. }
  498. }
  499. }
  500. }
  501. // Dialog - registrazione 3/6 sesso
  502. case DIALOG_REGISTER_SEX:
  503. {
  504. if (!response)
  505. {
  506. Kick(playerid);
  507. return 1;
  508. }
  509. switch(listitem)// Dialog: registrazione fase 3: sesso
  510. {
  511. case 0: // Registrazione sesso: selezionato: donna
  512. {
  513. Player[playerid][Sex] = 1; // 1 = donna
  514.  
  515. new query[1024];
  516. 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]);
  517. // format(query, sizeof(query), "UPDATE `players` SET `sex` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Sex], Player[playerid][ID]);
  518. // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
  519. new Messaggio[256];
  520. format(Messaggio, sizeof (Messaggio), "{AFAFAF}[INFO]: %s sei {FF6666}una donna", Player[playerid][Name]);
  521. SendClientMessage(playerid, COLOR_SYSTEM_INFO, Messaggio);
  522. 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");
  523.  
  524. PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
  525.  
  526. }
  527. case 1: // Registrazione sesso: selezionato: uomo
  528. {
  529. Player[playerid][Sex] = 2; // 2 = uomo
  530. new query[1024];
  531. 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]);
  532. //format(query, sizeof(query), "UPDATE `players` SET `sex` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Sex], Player[playerid][ID]);
  533. // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
  534. new Messaggio[256];
  535. format(Messaggio, sizeof (Messaggio), "[INFO]: %s sei {0000cc}un uomo", Player[playerid][Name]);
  536. SendClientMessage(playerid, COLOR_SYSTEM_INFO, Messaggio);
  537.  
  538. 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");
  539. PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
  540. //******
  541. }
  542. }
  543. }
  544. case DIALOG_REGISTER_EMAIL:
  545. {
  546. if (!response)
  547. {
  548. Kick(playerid);
  549. return 1;
  550. }
  551. else
  552. {
  553. if (strlen(inputtext) <= 5) 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");
  554. new query[1024];
  555. format(Player[playerid][PlayerEmail], 128, inputtext);
  556. 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]);
  557. // mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
  558.  
  559. new list[2 + (sizeof(SECURITY_QUESTIONS) * MAX_SECURITY_QUESTION_SIZE)];
  560. for (new i; i < sizeof(SECURITY_QUESTIONS); i++)
  561. {
  562. strcat(list, SECURITY_QUESTIONS[i]);
  563. strcat(list, "\n");
  564. }
  565. ShowPlayerDialog(playerid, DIALOG_REGISTER_DOMANDASEC, DIALOG_STYLE_LIST, "Registrazione - Domanda di sicurezza", list, "Continua", "Annulla");
  566.  
  567. }
  568. }
  569. case DIALOG_REGISTER_DOMANDASEC:
  570. {
  571. if (!response)
  572. {
  573. Kick(playerid);
  574. return 1;
  575. }
  576. else
  577. {
  578. format(Player[playerid][e_USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE, SECURITY_QUESTIONS[listitem]);
  579. new query[1024]; //221
  580. 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]);
  581. new string[128];
  582. 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]);
  583. ShowPlayerDialog(playerid, DIALOG_REGISTER_RISPOSTASEC, DIALOG_STYLE_INPUT, "Registrazione - Domanda di sicurezza [6/6]", string, "Continua", "Annuila");
  584. }
  585. }
  586. case DIALOG_REGISTER_RISPOSTASEC:
  587. {
  588. if (!response)
  589. {
  590. Kick(playerid);
  591. return 1;
  592. }
  593. else
  594. {
  595. new string[128];
  596. 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]);
  597.  
  598. if (strlen(inputtext) <= 2) return ShowPlayerDialog(playerid, DIALOG_REGISTER_RISPOSTASEC, DIALOG_STYLE_INPUT, "Registrazione - Domanda di sicurezza [6/6]", string, "Continua", "Annuila");
  599.  
  600. format(Player[playerid][e_USER_SECURITY_ANSWER], 128, inputtext);
  601. new query[1024];
  602. 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]);
  603. mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
  604. }
  605. }
  606. case DIALOG_PROVA:
  607. {
  608. GivePlayerMoney(playerid, strval(inputtext));
  609. return 1;
  610. }
  611.  
  612.  
  613.  
  614. default: return 0; // dialog ID was not found, search in other scripts
  615. }
  616. return 1;
  617. }
  618.  
  619. //-----------------------------------------------------
  620.  
  621.  
  622. stock check(string[],lol[])
  623. {
  624. for(new i = 0; i != strlen(string);++i)
  625. {
  626. if(!strcmp(lol,"uppercase"))
  627. {
  628. if(string[i] >= 'A' && string[i] <= 'Z'); //return printf("It has uppercase letters.");
  629. }
  630. else if(!strcmp(lol,"lowercase"))
  631. {
  632. if(string[i] >= 'a' && string[i] <= 'z'); //return printf("It has lowercase letters.");
  633. }
  634. else if(!strcmp(lol,"numbers"))
  635. {
  636. if(string[i] >= '0' && string[i] <= '9'); //return printf("It has numbers");
  637. }
  638. }
  639. return 0;
  640.  
  641. /*
  642. //usage...
  643. new blahblah[] = "abcdefkddkds2";
  644. check(blahblah,"numbers");
  645. new blahblah[] = "123232313FFSFFDSa";
  646. check(blahblah,"lowercase");
  647. new blahblah[] = "asdidsjaij123j21ij321A";
  648. check(blahblah,"uppercase");
  649.  
  650. */
  651. }
  652.  
  653.  
  654. // controllo se una string è numerica
  655. IsNumeric(const string[])
  656. {
  657. for (new i = 0, j = strlen(string); i < j; i++)
  658. {
  659. if (string[i] > '9' || string[i] < '0') return 0;
  660. }
  661. return 1;
  662. }
  663.  
  664. forward OnPlayerDataLoaded(playerid, race_check);
  665. public OnPlayerDataLoaded(playerid, race_check)
  666. { /* race condition check:
  667. player A connects -> SELECT query is fired -> this query takes very long
  668. while the query is still processing, player A with playerid 2 disconnects
  669. player B joins now with playerid 2 -> our laggy SELECT query is finally finished, but for the wrong player
  670. what do we do against it?
  671. we create a connection count for each playerid and increase it everytime the playerid connects or disconnects
  672. we also pass the current value of the connection count to our OnPlayerDataLoaded callback
  673. then we check if current connection count is the same as connection count we passed to the callback
  674. if yes, everything is okay, if not, we just kick the player
  675. */
  676. if (race_check != g_MysqlRaceCheck[playerid]) return Kick(playerid);
  677.  
  678. new string[115];
  679. if(cache_num_rows() > 0)// Giocatore registrato sul server
  680. {
  681. cache_get_value(0, "password", Player[playerid][Password], 65);
  682. cache_get_value(0, "salt", Player[playerid][Salt], 17);
  683. Player[playerid][Cache_ID] = cache_save();
  684.  
  685. format(string, sizeof string, "%s risulta registrato sul server.\nInserisci la password per entrare:", Player[playerid][Name]);
  686. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Annulla");
  687. Player[playerid][LoginTimer] = SetTimerEx("OnLoginTimeout", SECONDS_TO_LOGIN * 1000, false, "d", playerid);
  688. }
  689. else // Giocatore non registrato sul server
  690. {
  691. format(string, sizeof string, "Benvenuto %s,\nPer iniziare a registrarti su %s, inserisci una password", Player[playerid][Name], nomeserver);
  692. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrazione [1/6]", string, "Continua", "Annulla");
  693. }
  694. return 1;
  695. }
  696.  
  697. forward OnLoginTimeout(playerid);
  698. public OnLoginTimeout(playerid)
  699. {
  700. // reset the variable that stores the timerid
  701. Player[playerid][LoginTimer] = 0;
  702.  
  703. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Sei stato kickato dal server per aver impiegato troppo tempo nel loggarti.", "Okay", "");
  704. DelayedKick(playerid);
  705. return 1;
  706. }
  707.  
  708. // prova timer
  709. forward KickTimerNameRP(playerid);
  710. public KickTimerNameRP(playerid)
  711. {
  712. Kick(playerid);
  713. }
  714.  
  715. forward OnPlayerRegister(playerid);
  716. public OnPlayerRegister(playerid)
  717. {
  718. // retrieves the ID generated for an AUTO_INCREMENT column by the sent query
  719. Player[playerid][ID] = cache_insert_id();
  720. SetPlayerHealth(playerid, 100);
  721. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Registration", "Account successfully registered, you have been automatically logged in.", "Okay", "");
  722.  
  723. Player[playerid][IsLoggedIn] = true;
  724.  
  725. Player[playerid][X_Pos] = DEFAULT_POS_X;
  726. Player[playerid][Y_Pos] = DEFAULT_POS_Y;
  727. Player[playerid][Z_Pos] = DEFAULT_POS_Z;
  728. Player[playerid][A_Pos] = DEFAULT_POS_A;
  729. SetPlayerInterior(playerid, 0);
  730. SetSpawnInfo(playerid, NO_TEAM, 0, -1974.8938, 152.9418, 27.6940, Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0);
  731. /*
  732. -1974.8938, 152.9418, 27.6940
  733. */
  734. SpawnPlayer(playerid);
  735. return 1;
  736. }
  737.  
  738. forward _KickPlayerDelayed(playerid);
  739. public _KickPlayerDelayed(playerid)
  740. {
  741. Kick(playerid);
  742. return 1;
  743. }
  744.  
  745.  
  746. //-----------------------------------------------------
  747. // stocks
  748.  
  749. // Stock per mandare un messaggio agli admin
  750. stock SendMessageToAdmins(text[])
  751. {
  752. for(new i = 0; i < MAX_PLAYERS; i++)
  753. {
  754. if(Player[i][Admin] >= 1)
  755. {
  756. SendClientMessage(i, COLOR_SYSTEM_ADMIN, text);
  757. }
  758. }
  759. }
  760. CMD:report(playerid, params[]) {
  761. new id; // id player reportato
  762. new reason[128]; // Ragione del report
  763. if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[SERVER] - USAGE: /report [ID] [REASON]");
  764. new string[150], // stringa messaggio report
  765. sender[MAX_PLAYER_NAME], // Nome di chi manda il report
  766. receiver[MAX_PLAYER_NAME]; // Chi riceve il report
  767.  
  768. GetPlayerName(playerid, sender, sizeof(sender));
  769. GetPlayerName(id, receiver, sizeof(receiver));
  770.  
  771. format(string, sizeof(string), "[ADMIN]: %s(%d) ha reportato %s(%d)", sender, playerid, receiver, id);
  772. SendMessageToAdmins(string);
  773.  
  774. format(string, sizeof(string), "[ADMIN]: Motivo: %s", reason);
  775. SendMessageToAdmins(string);
  776.  
  777. SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, "[INFO]: Il tuo report è stato inviato.");
  778. return 1;
  779. }
  780.  
  781.  
  782.  
  783. //-----------------------------------------------------
  784.  
  785. AssignPlayerData(playerid)
  786. { // quando il player effettua il login
  787. cache_get_value_int(0, "id", Player[playerid][ID]);
  788. // lettura delle statistiche
  789. cache_get_value_int(0, "kills", Player[playerid][Kills]);
  790. cache_get_value_int(0, "soldi", Player[playerid][Soldi]);
  791. cache_get_value_int(0, "deaths", Player[playerid][Deaths]);
  792. cache_get_value_int(0, "admin", Player[playerid][Admin]);
  793. cache_get_value_int(0, "aduty", Player[playerid][ADuty]);
  794. cache_get_value_int(0, "sex", Player[playerid][Sex]);
  795. cache_get_value_int(0, "age", Player[playerid][Age]);
  796. cache_get_value_float(0, "x", Player[playerid][X_Pos]);
  797. cache_get_value_float(0, "y", Player[playerid][Y_Pos]);
  798. cache_get_value_float(0, "z", Player[playerid][Z_Pos]);
  799. cache_get_value_float(0, "angle", Player[playerid][A_Pos]);
  800. cache_get_value_float(0, "vita", Player[playerid][Vita]);
  801. cache_get_value_float(0, "armatura", Player[playerid][Armatura]);
  802. cache_get_value_int(0, "interior", Player[playerid][Interior]);
  803. cache_get_value_name(0, "domandasec", Player[playerid][e_USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE);
  804. cache_get_value_name(0, "rispostasec", Player[playerid][e_USER_SECURITY_ANSWER]);
  805. cache_get_value_name(0, "email", Player[playerid][PlayerEmail]);
  806. // setting statistiche
  807. GivePlayerMoney(playerid, Player[playerid][Soldi]);
  808. SetPlayerHealth(playerid, Player[playerid][Vita]);
  809. SetPlayerArmour(playerid, Player[playerid][Armatura]);
  810.  
  811. return 1;
  812. }
  813.  
  814. DelayedKick(playerid, time = 500)
  815. {
  816. SetTimerEx("_KickPlayerDelayed", time, false, "d", playerid);
  817. return 1;
  818. }
  819.  
  820. SetupPlayerTable()
  821. {
  822. 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`))");
  823. return 1;
  824. }
  825.  
  826. UpdatePlayerData(playerid, reason)
  827. { // quando un giocatore si disconnette
  828. if (Player[playerid][IsLoggedIn] == false) return 0;
  829.  
  830. // if the client crashed, it's not possible to get the player's position in OnPlayerDisconnect callback
  831. // 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)
  832. if (reason == 1)
  833. {
  834. GetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]);
  835. GetPlayerFacingAngle(playerid, Player[playerid][A_Pos]);
  836. }
  837.  
  838. if(Player[playerid][ADuty] == 1)
  839. {
  840. Player[playerid][ADuty] = 0;
  841. SetPlayerHealth(playerid, 100);
  842. SetPlayerArmour(playerid, 0);
  843. return 1;
  844. }
  845.  
  846. new query[1024];
  847. GetPlayerHealth(playerid, Player[playerid][Vita]);
  848. GetPlayerArmour(playerid, Player[playerid][Armatura]);
  849. mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `soldi` = %d,`armatura` = %f,`vita` = %f, `x` = %f, `y` = %f, `z` = %f, `angle` = %f, `interior` = %d WHERE `id` = %d LIMIT 1", GetPlayerMoney(playerid), Player[playerid][Armatura], Player[playerid][Vita], Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], GetPlayerInterior(playerid), Player[playerid][ID]);
  850. mysql_tquery(g_SQL, query);
  851. return 1;
  852. }
  853.  
  854. UpdatePlayerDeaths(playerid)
  855. {
  856. if (Player[playerid][IsLoggedIn] == false) return 0;
  857.  
  858. Player[playerid][Deaths]++;
  859.  
  860. new query[70];
  861. mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `deaths` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Deaths], Player[playerid][ID]);
  862. mysql_tquery(g_SQL, query);
  863. return 1;
  864. }
  865.  
  866. UpdatePlayerKills(killerid)
  867. {
  868. // we must check before if the killer wasn't valid (connected) player to avoid run time error 4
  869. if (killerid == INVALID_PLAYER_ID) return 0;
  870. if (Player[killerid][IsLoggedIn] == false) return 0;
  871.  
  872. Player[killerid][Kills]++;
  873.  
  874. new query[70];
  875. mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `kills` = %d WHERE `id` = %d LIMIT 1", Player[killerid][Kills], Player[killerid][ID]);
  876. mysql_tquery(g_SQL, query);
  877. return 1;
  878. }
  879. //-----------------------------------------------------------------------
  880. // comandi - zcmd
  881.  
  882. CMD:admin(playerid, params[])
  883. {
  884. if(Player[playerid][Admin] == 0)
  885. {
  886. SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "asd");
  887. return 1;
  888. }
  889. else if(Player[playerid][Admin] >= 1)
  890. {
  891. SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, "123");
  892. return 1;
  893. }
  894. return 1;
  895. }
  896.  
  897. CMD:aduty(playerid, params[])
  898. {
  899. if(Player[playerid][Admin] >= 1)
  900. {// Se è un membro dellos taff
  901. // se int è uguale a 0 (non in servizio) cambia l'int in 1 - entra in servizio
  902. if(Player[playerid][ADuty] == 0)
  903. {// entra in servizio
  904. TextDrawShowForPlayer(playerid,AdminInDuty);
  905. SetPlayerArmour(playerid, 10000);
  906. SetPlayerHealth(playerid, 10000);
  907. new ADutyString[64];
  908. format(ADutyString, sizeof(ADutyString), "[ADMIN]: L'admin %s è in servizio", Player[playerid][Name]);
  909. SendClientMessageToAll(COLOR_SYSTEM_ADMIN, ADutyString);
  910. Player[playerid][ADuty] = 1;
  911. return 1;
  912. }
  913. // se int è uguale a 1 (in servizio) cambia l'int in 0 - esce dal servizio
  914. if(Player[playerid][ADuty] == 1)
  915. {// esce dal servizio
  916. TextDrawHideForPlayer(playerid,AdminInDuty);
  917. SetPlayerArmour(playerid, Player[playerid][Armatura]);
  918. SetPlayerHealth(playerid, Player[playerid][Vita]);
  919. new ADutyString[64];
  920. format(ADutyString, sizeof(ADutyString), "[ADMIN]: L'admin %s non è più in servizio", Player[playerid][Name]);
  921. SendClientMessageToAll(COLOR_SYSTEM_ADMIN, ADutyString);
  922. Player[playerid][ADuty] = 0;
  923. return 1;
  924. }
  925. }
  926. else if(Player[playerid][Admin] < 1)
  927. {// se no è uno dello staff
  928. new string[128];
  929. format(string, sizeof(string), "[ERRORE]: Mi dispiace %s non sei autorizzato ad usare questo comando", Player[playerid][Name]);
  930. SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
  931. return 1;
  932. }
  933. return 1;
  934. }
  935.  
  936.  
  937. CMD:pm( playerid, params[])
  938. {
  939.  
  940. new
  941. TargetPlayer,
  942. Messaggio[128];
  943.  
  944. if (sscanf(params, "rs[128]", TargetPlayer, Messaggio))
  945. {
  946. return SendClientMessage(playerid, COLOR_INFO, "[INFO]: /pm (id/nome player) (messaggio)");
  947. }
  948. if (TargetPlayer == INVALID_PLAYER_ID )
  949. {
  950. return SendClientMessage(playerid, COLOR_RED, "[ERRORE]: Giocatore non trovato/non connesso al server!");
  951. }
  952. if(TargetPlayer == playerid)
  953. {
  954. return SendClientMessage(playerid, COLOR_RED, "[ERRORE]: Non puoi mandarti un messaggio da solo!");
  955. }
  956. new StringaMessaggio[128];
  957. new
  958. Mittente[MAX_PLAYER_NAME],
  959. Destinatario[MAX_PLAYER_NAME];
  960.  
  961. GetPlayerName(playerid, Mittente, MAX_PLAYER_NAME);
  962. GetPlayerName(TargetPlayer, Destinatario, MAX_PLAYER_NAME);
  963.  
  964. format(StringaMessaggio, sizeof(StringaMessaggio), "{FFFF00}[PM da %s]: {FFFFFF}%s", Mittente, Messaggio);
  965. SendClientMessage(TargetPlayer, COLOR_INFO, StringaMessaggio);
  966.  
  967. format(StringaMessaggio, sizeof(StringaMessaggio), "{FFFF00}[PM inviato a %s]: {FFFFFF}%s", Destinatario, Messaggio);
  968. SendClientMessage(playerid, COLOR_INFO, StringaMessaggio);
  969. return true;
  970. }
  971.  
  972.  
  973. public OnPlayerRequestClass(playerid,classid)
  974. {
  975. // SetPlayerPos(playerid, 982.1890, -1624.2583, 14.9526);
  976. // SetPlayerFacingAngle(playerid, 90);
  977. return 1;
  978. }
RAW Paste Data