Guest User

Untitled

a guest
Jan 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.96 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <zcmd>
  4. #include <YSI\y_ini>
  5. #include <gl_common>
  6.  
  7. #define rosso 0xff0000ff
  8. #define blu 0x0000ffff
  9. #define verde 0x00ff00ff
  10. #define verdescuro 0x009500ff
  11. #define rossoscuro 0xa00000ff
  12. #define bluscuro 0x0000a0ff
  13. #define nero 0x000000ff
  14. #define bianco 0xffffffff
  15. #define giallo 0xffff00ff
  16. #define arancione 0xffb100ff
  17. #define viola 0x974598ff
  18. #define azzurro 0x97c7ffff
  19. #define verdeacqua 0x00ffffff
  20. #define fuxia 0x90559bff
  21. #define marrone 0x905500ff
  22. #define rosachiaro 0xff92cc59
  23. #define rosascuro 0xff92ccff
  24. #define msg_rosso "{ff0000}"
  25. #define msg_blu "{0096ff}"
  26. #define msg_verde "{00a600}"
  27. #define msg_verdescuro "{009500}"
  28. #define msg_rossoscuro "{a00000}"
  29. #define msg_bluscuro "{0000a0}"
  30. #define msg_nero "{000000}"
  31. #define msg_bianco "{ffffff}"
  32. #define msg_giallo "{ffff00}"
  33. #define msg_arancione "{ffb100}"
  34. #define msg_viola "{974598}"
  35. #define msg_azzurro "{97c7ff}"
  36. #define msg_verdeacqua "{00ffff}"
  37. #define msg_fuxia "{90559b}"
  38. #define msg_marrone "{905500}"
  39. #define msg_rosachiaro "{ff92cc}"
  40. #define msg_rosascuro "{ff92cc}"
  41. #define msg_dialog "{e6e6e6}"
  42.  
  43. #define Server_Name "Freeroam"
  44. #define Format_Account(%0) format(PLAYER_INFO[%0][ACCOUNT], 128, "Utenti/%s.ini", PLAYER_INFO[%0][NAME])
  45.  
  46. #define MENU_REGISTER 1
  47. #define MENU_LOGIN 2
  48.  
  49. #define MAX_TENTATIVI_LOGIN 3
  50.  
  51. enum E_PLAYER
  52. {
  53. ADMIN,
  54. ACCOUNT[128],
  55. NAME[24],
  56. PASSWORD[20],
  57. SCORE,
  58. MONEY,
  59. LAST_LOGIN[24]
  60. };
  61.  
  62. new
  63. PLAYER_INFO[MAX_PLAYERS][E_PLAYER],
  64. mess[128]
  65. ;
  66.  
  67. main()
  68. {
  69. print("\n----------------------------------");
  70. print(" Blank Gamemode by your name here");
  71. print("----------------------------------\n");
  72. }
  73.  
  74. public OnGameModeInit()
  75. {
  76. // Don't use these lines if it's a filterscript
  77. SetGameModeText("FreeRoam");
  78. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  79. return 1;
  80. }
  81.  
  82. public OnGameModeExit()
  83. {
  84. return 1;
  85. }
  86.  
  87. public OnPlayerRequestClass(playerid, classid)
  88. {
  89. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  90. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  91. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  92. return 1;
  93. }
  94.  
  95. public OnPlayerConnect(playerid)
  96. {
  97. GetPlayerName(playerid, PLAYER_INFO[playerid][NAME], 24);
  98. Format_Account(playerid);
  99. INI_ParseFile(PLAYER_INFO[playerid][ACCOUNT], "INI_Parse_Player_Last_Login", .bExtra = true, .extra = playerid);
  100. if(!fexist(PLAYER_INFO[playerid][ACCOUNT]))
  101. {
  102. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per la "msg_verde"Registrazione"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  103. ShowPlayerDialog(playerid, MENU_REGISTER, DIALOG_STYLE_INPUT, ""msg_verde"Registrazione", mess, "Conferma", "Annulla");
  104. format(mess, 128, "Ciao "msg_blu"%s"msg_bianco", benvenuto su "msg_verde""Server_Name""msg_bianco".", PLAYER_INFO[playerid][NAME]);
  105. SendClientMessage(playerid, -1, mess);
  106. SendClientMessage(playerid, -1, "Il tuo Account non risulta Registrato. Esegui la "msg_verde"Registrazione "msg_bianco"per cominciare a giocare.");
  107. }
  108. else
  109. {
  110. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per il "msg_verde"Login"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  111. ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_INPUT, ""msg_verde"Login", mess, "Conferma", "Annulla");
  112. format(mess, 128, "Ciao "msg_blu"%s"msg_bianco", benvenuto su "msg_verde""Server_Name""msg_bianco".", PLAYER_INFO[playerid][NAME]);
  113. SendClientMessage(playerid, -1, mess);
  114. format(mess, 128, "Il tuo ultimo Login risale al: "msg_verde"%s"msg_bianco".", PLAYER_INFO[playerid][LAST_LOGIN]);
  115. SendClientMessage(playerid, -1, mess);
  116. }
  117. SetPVarInt(playerid, "Tentativi_Last_Login", MAX_TENTATIVI_LOGIN);
  118. return 1;
  119. }
  120.  
  121. public OnPlayerDisconnect(playerid, reason)
  122. {
  123. return 1;
  124. }
  125.  
  126. public OnPlayerSpawn(playerid)
  127. {
  128. return 1;
  129. }
  130.  
  131. public OnPlayerDeath(playerid, killerid, reason)
  132. {
  133. return 1;
  134. }
  135.  
  136. public OnVehicleSpawn(vehicleid)
  137. {
  138. return 1;
  139. }
  140.  
  141. public OnVehicleDeath(vehicleid, killerid)
  142. {
  143. return 1;
  144. }
  145.  
  146. public OnPlayerText(playerid, text[])
  147. {
  148. return 1;
  149. }
  150.  
  151. CMD:setadmin(playerid, params[])
  152. {
  153. if(!IsPlayerAdmin(playerid))
  154. {
  155. SendErrorMessage(playerid, "Non puoi utilizzare questo comando.");
  156. return 1;
  157. }
  158. new
  159. pid,
  160. level
  161. ;
  162. if(sscanf(params, "ri", pid, level))
  163. {
  164. SendUseMessage(playerid, "/setadmin <playerid/nome> <livello>");
  165. return 1;
  166. }
  167. return 1;
  168. }
  169.  
  170. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  171. {
  172. return 1;
  173. }
  174.  
  175. public OnPlayerExitVehicle(playerid, vehicleid)
  176. {
  177. return 1;
  178. }
  179.  
  180. public OnPlayerStateChange(playerid, newstate, oldstate)
  181. {
  182. return 1;
  183. }
  184.  
  185. public OnPlayerEnterCheckpoint(playerid)
  186. {
  187. return 1;
  188. }
  189.  
  190. public OnPlayerLeaveCheckpoint(playerid)
  191. {
  192. return 1;
  193. }
  194.  
  195. public OnPlayerEnterRaceCheckpoint(playerid)
  196. {
  197. return 1;
  198. }
  199.  
  200. public OnPlayerLeaveRaceCheckpoint(playerid)
  201. {
  202. return 1;
  203. }
  204.  
  205. public OnRconCommand(cmd[])
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnPlayerRequestSpawn(playerid)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnObjectMoved(objectid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnPlayerObjectMoved(playerid, objectid)
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnPlayerPickUpPickup(playerid, pickupid)
  226. {
  227. return 1;
  228. }
  229.  
  230. public OnVehicleMod(playerid, vehicleid, componentid)
  231. {
  232. return 1;
  233. }
  234.  
  235. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  236. {
  237. return 1;
  238. }
  239.  
  240. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  241. {
  242. return 1;
  243. }
  244.  
  245. public OnPlayerSelectedMenuRow(playerid, row)
  246. {
  247. return 1;
  248. }
  249.  
  250. public OnPlayerExitedMenu(playerid)
  251. {
  252. return 1;
  253. }
  254.  
  255. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  256. {
  257. return 1;
  258. }
  259.  
  260. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  261. {
  262. return 1;
  263. }
  264.  
  265. public OnRconLoginAttempt(ip[], password[], success)
  266. {
  267. return 1;
  268. }
  269.  
  270. public OnPlayerUpdate(playerid)
  271. {
  272. return 1;
  273. }
  274.  
  275. public OnPlayerStreamIn(playerid, forplayerid)
  276. {
  277. return 1;
  278. }
  279.  
  280. public OnPlayerStreamOut(playerid, forplayerid)
  281. {
  282. return 1;
  283. }
  284.  
  285. public OnVehicleStreamIn(vehicleid, forplayerid)
  286. {
  287. return 1;
  288. }
  289.  
  290. public OnVehicleStreamOut(vehicleid, forplayerid)
  291. {
  292. return 1;
  293. }
  294.  
  295. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  296. {
  297. switch(dialogid)
  298. {
  299. case MENU_REGISTER:
  300. {
  301. if(response)
  302. {
  303. if(strlen(inputtext) == 0)
  304. {
  305. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per la "msg_verde"Registrazione"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  306. ShowPlayerDialog(playerid, MENU_REGISTER, DIALOG_STYLE_INPUT, ""msg_verde"Registrazione", mess, "Conferma", "Annulla");
  307. SendErrorMessage(playerid, "Devi inserire una Password.");
  308. return 1;
  309. }
  310. if(strlen(inputtext) < 3)
  311. {
  312. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per la "msg_verde"Registrazione"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  313. ShowPlayerDialog(playerid, MENU_REGISTER, DIALOG_STYLE_INPUT, ""msg_verde"Registrazione", mess, "Conferma", "Annulla");
  314. SendErrorMessage(playerid, "Inserisci più di 3 caratteri.");
  315. return 1;
  316. }
  317. if(strlen(inputtext) > 20)
  318. {
  319. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per la "msg_verde"Registrazione"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  320. ShowPlayerDialog(playerid, MENU_REGISTER, DIALOG_STYLE_INPUT, ""msg_verde"Registrazione", mess, "Conferma", "Annulla");
  321. SendErrorMessage(playerid, "Puoi inserire massimo 20 caratteri.");
  322. return 1;
  323. }
  324. new
  325. year,
  326. month,
  327. day,
  328. hour,
  329. minuts,
  330. seconds,
  331. ip[24]
  332. ;
  333. getdate(year, month, day);
  334. gettime(hour, minuts, seconds);
  335. GetPlayerIp(playerid, ip, sizeof(ip));
  336. format(mess, 128, "%d/%d/%d - %02d:%02d:%02d", day, month, year, hour, minuts, seconds);
  337. new
  338. INI: account = INI_Open(PLAYER_INFO[playerid][ACCOUNT])
  339. ;
  340. INI_WriteString(account, "Password", inputtext);
  341. INI_WriteInt(account, "Admin", 0);
  342. INI_WriteString(account, "Data_Registrazione", mess);
  343. INI_WriteString(account, "Ultimo_Login", mess);
  344. INI_WriteString(account, "IP_Registrazione", ip);
  345. INI_WriteString(account, "Ultimo_IP", ip);
  346. INI_WriteInt(account, "Soldi", 0);
  347. INI_WriteInt(account, "Punti", 0);
  348. INI_Close(account);
  349. format(PLAYER_INFO[playerid][PASSWORD], 20, inputtext);
  350. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per il "msg_verde"Login"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  351. ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_INPUT, ""msg_verde"Login", mess, "Conferma", "Annulla");
  352. }
  353. else
  354. {
  355. SendErrorMessage(playerid, "Registrazione obbligatoria. Sei stato Kickato.");
  356. Kick(playerid);
  357. }
  358. }
  359.  
  360. case MENU_LOGIN:
  361. {
  362. if(response)
  363. {
  364. if(strlen(inputtext) == 0)
  365. {
  366. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per il "msg_verde"Login"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  367. ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_INPUT, ""msg_verde"Login", mess, "Conferma", "Annulla");
  368. SendErrorMessage(playerid, "Devi inserire una Password.");
  369. return 1;
  370. }
  371. if(strlen(inputtext) < 3)
  372. {
  373. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per il "msg_verde"Login"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  374. ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_INPUT, ""msg_verde"Login", mess, "Conferma", "Annulla");
  375. SendErrorMessage(playerid, "Inserisci più di 3 caratteri.");
  376. return 1;
  377. }
  378. if(strlen(inputtext) > 20)
  379. {
  380. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per il "msg_verde"Login"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  381. ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_INPUT, ""msg_verde"Login", mess, "Conferma", "Annulla");
  382. SendErrorMessage(playerid, "Puoi inserire massimo 20 caratteri.");
  383. return 1;
  384. }
  385. INI_ParseFile(PLAYER_INFO[playerid][ACCOUNT], "INI_Parse_Player_Password", .bExtra = true, .extra = playerid);
  386. Format_Account(playerid);
  387. if(strcmp(PLAYER_INFO[playerid][PASSWORD], inputtext, false) != 0)
  388. {
  389. SetPVarInt(playerid, "Tentativi_Last_Login", GetPVarInt(playerid, "Tentativi_Last_Login") - 1);
  390. if(GetPVarInt(playerid, "Tentativi_Last_Login") == 0)
  391. {
  392. SendErrorMessage(playerid, "Hai sprecato tutti i tentativi a disposizione.");
  393. return Kick(playerid);
  394. }
  395. format(mess, 128, ""msg_dialog"Benvenuto su "Server_Name", "msg_blu"%s"msg_dialog".\nDigita una Password per il "msg_verde"Login"msg_dialog".", PLAYER_INFO[playerid][NAME]);
  396. ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_INPUT, ""msg_verde"Login", mess, "Conferma", "Annulla");
  397. format(mess, 128, "Password errata. Ti rimangono "msg_rosso"%d "msg_bianco"tentativi.", GetPVarInt(playerid, "Tentativi_Last_Login"));
  398. SendErrorMessage(playerid, mess);
  399. return 1;
  400. }
  401. new
  402. ip[24],
  403. year,
  404. month,
  405. day,
  406. hour,
  407. minuts,
  408. seconds
  409. ;
  410. GetPlayerIp(playerid, ip, 24);
  411. gettime(hour, minuts, seconds);
  412. getdate(year, month, day);
  413. format(mess, 128, "%d/%d/%d - %02d:%02d:%02d", day, month, year, hour, minuts, seconds);
  414. new
  415. INI: account = INI_Open(PLAYER_INFO[playerid][ACCOUNT])
  416. ;
  417. INI_WriteString(account, "Ultimo_Login", mess);
  418. INI_WriteString(account, "Ultimo_IP", ip);
  419. INI_Close(account);
  420. LoadData(playerid);
  421. SetTimerEx("Spawn_Player", 55, false, "d", playerid);
  422. }
  423. else
  424. {
  425. SendErrorMessage(playerid, "Login obbligatorio. Sei stato Kickato.");
  426. Kick(playerid);
  427. }
  428. }
  429. }
  430. return 1;
  431. }
  432.  
  433. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  434. {
  435. return 1;
  436. }
  437.  
  438. public Spawn_Player(playerid)
  439. {
  440. SpawnPlayer(playerid);
  441. SetCameraBehindPlayer(playerid);
  442. return 1;
  443. }
  444.  
  445. /*__________[PUBLICS]__________*/
  446.  
  447. public INI_Parse_Player_Password(playerid, name[], value[])
  448. {
  449. INI_String("Password", PLAYER_INFO[playerid][PASSWORD], 20);
  450. return 1;
  451. }
  452.  
  453. public INI_Parse_Player_Account(playerid, name[], value[])
  454. {
  455. INI_Int("Admin", PLAYER_INFO[playerid][ADMIN]);
  456. INI_Int("Score", PLAYER_INFO[playerid][SCORE]);
  457. INI_Int("Money", PLAYER_INFO[playerid][MONEY]);
  458. return 1;
  459. }
  460.  
  461. public INI_Parse_Player_Last_Login(playerid, name[], value[])
  462. {
  463. INI_String("Ultimo_Login", PLAYER_INFO[playerid][LAST_LOGIN], 24);
  464. return 1;
  465. }
  466.  
  467. /*__________[STOCKS]__________*/
  468.  
  469. stock SendInfoMessage(playerid, const messaggio[])
  470. {
  471. PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
  472. format(mess, 128, "{FF9900}INFO{FFFFFF}: %s", messaggio);
  473. SendClientMessage(playerid, -1, mess);
  474. return 1;
  475. }
  476.  
  477. stock SendErrorMessage(playerid, const messaggio[])
  478. {
  479. PlayerPlaySound(playerid, 1055, 0.0, 0.0, 0.0);
  480. format(mess, 128, "{FF0000}ERRORE{FFFFFF}: %s", messaggio);
  481. SendClientMessage(playerid, -1, mess);
  482. return 1;
  483. }
  484.  
  485. stock SendUseMessage(playerid, const messaggio[])
  486. {
  487. PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
  488. format(mess, 128, ""msg_blu"USO"msg_bianco": %s", messaggio);
  489. SendClientMessage(playerid, -1, mess);
  490. return 1;
  491. }
  492.  
  493. stock LoadData(playerid)
  494. {
  495. SetPlayerScore(playerid, PLAYER_INFO[playerid][SCORE]);
  496. GivePlayerMoney(playerid, PLAYER_INFO[playerid][MONEY]);
  497. return 1;
  498. }
  499.  
  500. /*__________[FORWARDS]__________*/
  501.  
  502. forward INI_Parse_Player_Password(playerid, name[], value[]);
  503. forward INI_Parse_Player_Account(playerid, name[], value[]);
  504. forward INI_Parse_Player_Last_Login(playerid, name[], value[]);
  505. forward Spawn_Player(playerid);
Add Comment
Please, Sign In to add comment