Advertisement
Guest User

Untitled

a guest
Jun 13th, 2011
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.39 KB | None | 0 0
  1.  
  2.  
  3.  
  4. //=======================Includes
  5.  
  6. #include <a_samp>
  7. #include <dini>
  8. #include <dudb>
  9.  
  10. #pragma unused ret_memcpy
  11.  
  12. #define REGISTER_DIALOG 1200
  13. #define LOGIN_DIALOG 1300
  14. #define righe 5035
  15. #define aggiornamento "12/06/2010"
  16. #define versione "0.1"
  17. //=======================Colori
  18.  
  19. #define BLU_CHIARO 0x00BFFFAA
  20.  
  21. //============================New
  22.  
  23. enum pInfo
  24. {
  25. pAdmin,
  26. pSoldi,
  27. pLivello,
  28. pKills,
  29. pDeaths,
  30. pRegistrato,
  31. }
  32.  
  33. new PlayerInfo[MAX_PLAYERS][pInfo];
  34. new pFile[64], Ip[16];
  35. new nome[24];
  36. new stringa[500];
  37. new Avvisi[MAX_PLAYERS] = 0;
  38. new Count[MAX_PLAYERS];
  39. new Tempo[MAX_PLAYERS];
  40.  
  41. //============================Bool
  42.  
  43. new bool: Loggato[MAX_PLAYERS];
  44.  
  45. main()
  46. {
  47. print("\n-------------GameMode Caricata-------------");
  48. print(" Nome GameMode: FreeMode Server");
  49. print(" A");
  50. print(" Versione: 0.1");
  51. print(" a");
  52. print(" d");
  53. print("------------------------------------------\n");
  54. }
  55.  
  56.  
  57. public OnGameModeInit()
  58. {
  59. // Don't use these lines if it's a filterscript
  60. SetGameModeText("FreeMode v0.1");
  61. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  62. return 1;
  63. }
  64.  
  65. public OnGameModeExit()
  66. {
  67. return 1;
  68. }
  69.  
  70. public OnPlayerRequestClass(playerid, classid)
  71. {
  72. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  73. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  74. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  75. return 1;
  76. }
  77.  
  78. public OnPlayerConnect(playerid)
  79. {
  80. //============================Messaggio Iniziale
  81. new ora, minuti;
  82. gettime(ora, minuti);
  83. SetPlayerTime(playerid, ora, minuti);
  84. SetTimerEx("Telecamera", 100, false, "d", playerid);
  85. GetPlayerIp(playerid, Ip, 16);
  86. GetPlayerName(playerid, nome, 24);
  87. SendClientMessage(playerid, BLU_CHIARO, "{00FF00}__________________________{FFFFFF}__________________________{FF4444}__________________________");
  88. SendClientMessage(playerid, BLU_CHIARO, "");
  89. format(stringa, sizeof stringa, "{FFFFFF}Benvenuto {FFFF00}%s{FFFFFF}, {FFFFFF}ti sei connesso alle {FFFF00}%02d{FFFFFF}:{FFFF00}%02d {FFFFFF}con Ip: {FFFF00}%s", nome, ora, minuti, Ip);
  90. SendClientMessage(playerid, BLU_CHIARO, stringa);
  91. SendClientMessage(playerid, BLU_CHIARO, "{FFFFFF}Gamemode scriptata interamente da {FFFF00}Anthony Boss{FFFFFF}:");
  92. format(stringa, sizeof stringa, "{FFFFFF}Numero di righe: {FFFF00}%d{FFFFFF} Aggiornamento: {FFFF00}%s{FFFFFF} Versione: {FFFF00}%s{FFFFFF}", righe, aggiornamento, versione);
  93. SendClientMessage(playerid, BLU_CHIARO, stringa);
  94. SendClientMessage(playerid, BLU_CHIARO, "{00FF00}__________________________{FFFFFF}__________________________{FF4444}__________________________");
  95. PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
  96. GameTextForPlayer(playerid, "~g~Benvenuto!", 6000, 1);
  97.  
  98. //============================File Dini
  99. format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
  100. if(!fexist(pFile))
  101. {
  102. GetPlayerName(playerid, nome, 24);
  103. format(stringa, sizeof(stringa), "{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\n{FFFFFF}Non sei registrato.\nPer giocare è necessario registrare il proprio account.\nRegistrandoti, accetti le regole del Server.\n\nInserisci una {FF4444}password{FFFFFF} per registrarti.", nome);
  104. ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Registrati", "Chiudi");
  105. }
  106. else if(fexist(pFile))
  107. {
  108. GetPlayerName(playerid, nome, 24);
  109. format(stringa, sizeof(stringa), "{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nIl tuo Account risulta registrato.\n\n{FFFFFF}Inserisci la {FF4444}password{FFFFFF} per fare il Login.", nome);
  110. ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
  111. format(stringa, sizeof(stringa), "** {00BFFF}%s{FFFFFF}è entrato sul server.", nome);
  112. SendClientMessageToAll(BLU_CHIARO, stringa);
  113. }
  114. return 1;
  115. }
  116.  
  117. public OnPlayerDisconnect(playerid, reason)
  118. {
  119. new nome[24];
  120. GetPlayerName(playerid, nome, 24);
  121. format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
  122. if(dini_Exists(pFile))
  123. {
  124. Tempo[playerid] = Count[playerid] - GetTickCount();
  125. new str[32];
  126. if(!dini_Isset(pFile, "Tempo")) format(str, 32, "%02d:%02d:%02d", floatround(Tempo[playerid]/3600000, floatround_floor), floatfract(Tempo[playerid]/3600000)*60, floatfract(Tempo[playerid]/60000)*60), dini_Set(pFile, "Tempo", str);
  127. else
  128. {
  129. new string[32];
  130. new time[3];
  131. string = dini_Get(pFile, "Tempo");
  132. format(str, 32, "%02d, %02d, %02d", floatround(Tempo[playerid]/3600000, floatround_floor) + strval(format(time, 3, "%s%s", string[0], string[1])), (floatfract(Tempo[playerid]/3600000)*60) + strval(format(time, 3, "%s%s", string[3], string[4])) , (floatfract(Tempo[playerid]/60000)*60) + strval(format(time, 3, "%s%s", string[6], string[7])));
  133. dini_Set(pFile, "Tempo", str);
  134. }
  135. }
  136. SalvaAccount(playerid);
  137. Avvisi[playerid] = 0;
  138. return 1;
  139. }
  140.  
  141. public OnPlayerSpawn(playerid)
  142. {
  143. return 1;
  144. }
  145.  
  146. public OnPlayerDeath(playerid, killerid, reason)
  147. {
  148. return 1;
  149. }
  150.  
  151. public OnVehicleSpawn(vehicleid)
  152. {
  153. return 1;
  154. }
  155.  
  156. public OnVehicleDeath(vehicleid, killerid)
  157. {
  158. return 1;
  159. }
  160.  
  161. public OnPlayerText(playerid, text[])
  162. {
  163. return 1;
  164. }
  165.  
  166. public OnPlayerCommandText(playerid, cmdtext[])
  167. {
  168. return 1;
  169. }
  170.  
  171. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  172. {
  173. return 1;
  174. }
  175.  
  176. public OnPlayerExitVehicle(playerid, vehicleid)
  177. {
  178. return 1;
  179. }
  180.  
  181. public OnPlayerStateChange(playerid, newstate, oldstate)
  182. {
  183. return 1;
  184. }
  185.  
  186. public OnPlayerEnterCheckpoint(playerid)
  187. {
  188. return 1;
  189. }
  190.  
  191. public OnPlayerLeaveCheckpoint(playerid)
  192. {
  193. return 1;
  194. }
  195.  
  196. public OnPlayerEnterRaceCheckpoint(playerid)
  197. {
  198. return 1;
  199. }
  200.  
  201. public OnPlayerLeaveRaceCheckpoint(playerid)
  202. {
  203. return 1;
  204. }
  205.  
  206. public OnRconCommand(cmd[])
  207. {
  208. return 1;
  209. }
  210.  
  211. public OnPlayerRequestSpawn(playerid)
  212. {
  213. return 1;
  214. }
  215.  
  216. public OnObjectMoved(objectid)
  217. {
  218. return 1;
  219. }
  220.  
  221. public OnPlayerObjectMoved(playerid, objectid)
  222. {
  223. return 1;
  224. }
  225.  
  226. public OnPlayerPickUpPickup(playerid, pickupid)
  227. {
  228. return 1;
  229. }
  230.  
  231. public OnVehicleMod(playerid, vehicleid, componentid)
  232. {
  233. return 1;
  234. }
  235.  
  236. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  237. {
  238. return 1;
  239. }
  240.  
  241. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  242. {
  243. return 1;
  244. }
  245.  
  246. public OnPlayerSelectedMenuRow(playerid, row)
  247. {
  248. return 1;
  249. }
  250.  
  251. public OnPlayerExitedMenu(playerid)
  252. {
  253. return 1;
  254. }
  255.  
  256. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  257. {
  258. return 1;
  259. }
  260.  
  261. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  262. {
  263. return 1;
  264. }
  265.  
  266. public OnRconLoginAttempt(ip[], password[], success)
  267. {
  268. return 1;
  269. }
  270.  
  271. public OnPlayerUpdate(playerid)
  272. {
  273. return 1;
  274. }
  275.  
  276. public OnPlayerStreamIn(playerid, forplayerid)
  277. {
  278. return 1;
  279. }
  280.  
  281. public OnPlayerStreamOut(playerid, forplayerid)
  282. {
  283. return 1;
  284. }
  285.  
  286. public OnVehicleStreamIn(vehicleid, forplayerid)
  287. {
  288. return 1;
  289. }
  290.  
  291. public OnVehicleStreamOut(vehicleid, forplayerid)
  292. {
  293. return 1;
  294. }
  295.  
  296. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  297. {
  298. /*=================================Registrazione*/
  299. if(dialogid == REGISTER_DIALOG)
  300. {
  301. if(response)
  302. {
  303. GetPlayerName(playerid, nome, 24);
  304. if(!strlen(inputtext))
  305. {
  306. format(stringa, sizeof(stringa), "{FF4444}Errore:{FFFFFF} Inserisci una password.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\n{FFFFFF}Non sei registrato.\nPer giocare è necessario registrare il proprio account.\nRegistrandoti, accetti le regole del Server.\n\nInserisci una {FF4444}password{FFFFFF} per registrarti.", nome);
  307. ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Registrati", "Chiudi");
  308. return 0;
  309. }
  310. if(strfind(inputtext, "=", true) == 0)
  311. {
  312. format(stringa, sizeof(stringa), "{FF4444}Errore:{FFFFFF} Non puoi utilizzare {FF4444}={FFFFFF} come password.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\n{FFFFFF}Non sei registrato.\nPer giocare è necessario registrare il proprio account.\nRegistrandoti, accetti le regole del Server.\n\nInserisci una {FF4444}password{FFFFFF} per registrarti.", nome);
  313. ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Registrati", "Chiudi");
  314. return 0;
  315. }
  316. format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
  317. dini_Create(pFile);
  318. dini_Set(pFile, "Password", inputtext);
  319. dini_IntSet(pFile, "Soldi", 0);
  320. dini_IntSet(pFile, "Kills", 0);
  321. dini_IntSet(pFile, "Deaths", 0);
  322. dini_IntSet(pFile, "Admin", 0);
  323. dini_IntSet(pFile, "Livello", 0);
  324. dini_IntSet(pFile, "Registrato", 0);
  325. format(stringa, sizeof(stringa), "{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nHai registrato con successo un Account.\nOra esegui il Login per inizare a giocare.\n\n{FFFFFF}Inserisci la password del tuo Account.", nome);
  326. ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
  327. SendClientMessage(playerid, BLU_CHIARO, "* {FFFFFF}Hai creato con successo un account. Ora esegui il Login.");
  328. }
  329. else if(!response)
  330. {
  331. SendClientMessage(playerid, BLU_CHIARO, "{00FF00}[Info:] {FFFFFF}Sei stato kickato. Motivo: {FF66FF}Registrazione obbligatoria{FFFFFF}.");
  332. GetPlayerName(playerid, nome, 24);
  333. format(stringa, sizeof(stringa), "{00FF00}[Info:]{FFFFFF}%s{00BFFF} è stato kickato dal Server. Motivo: {FFFFFF}Registrazione obbligatoria{00BFFF}.", nome);
  334. SendClientMessageToAll(BLU_CHIARO, stringa);
  335. Kick(playerid);
  336. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  337. }
  338. }
  339.  
  340. /*===============================Login*/
  341. if(dialogid == LOGIN_DIALOG)
  342. {
  343. if(response)
  344. {
  345. GetPlayerName(playerid, nome, 24);
  346. if(!strlen(inputtext))
  347. {
  348. format(stringa, sizeof stringa, "{FF4444}Errore:{FFFFFF} Inserisci una password.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nIl tuo Account risulta registrato.\n\n{FFFFFF}Inserisci la password del tuo Account.", nome);
  349. ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
  350. return 0;
  351. }
  352. if(!strcmp(inputtext, dini_Get(pFile, "Password"), false))
  353. {
  354. format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
  355. Loggato[playerid] = true;
  356. ResetPlayerMoney(playerid);
  357. Count[playerid] = GetTickCount();
  358. GivePlayerMoney(playerid, dini_Int(pFile, "Soldi"));
  359. PlayerInfo[playerid][pKills] = dini_Int(pFile, "Kills");
  360. PlayerInfo[playerid][pDeaths] = dini_Int(pFile, "Deaths");
  361. PlayerInfo[playerid][pLivello] = dini_Int(pFile, "Livello");
  362. PlayerInfo[playerid][pAdmin] = dini_Int(pFile, "Admin");
  363. PlayerInfo[playerid][pRegistrato] = 1;
  364. Count[playerid] = GetTickCount();
  365. format(stringa, sizeof(stringa), "* {FFFFFF}Benvenuto {33AA33}%s{FFFFFF}, i tuoi dati sono stati caricati con successo..", nome);
  366. SendClientMessage(playerid, BLU_CHIARO, stringa);
  367. return 1;
  368. }
  369. else
  370. {
  371. format(stringa, sizeof(stringa), "{FF4444}[Errore:]{FFFFFF} Password errata, al terzo tentativo sbagliato, verrai {FF4444}kickato{FFFFFF}.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nIl tuo Account risulta registrato.\n\n{FFFFFF}Inserisci la password del tuo Account.", nome);
  372. ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
  373. Avvisi[playerid] ++;
  374. if(Avvisi[playerid] == 3)
  375. {
  376. SendClientMessage(playerid, BLU_CHIARO, "{00FF00}[Info:] {FFFFFF}Sei stato kickato. Motivo: {FF66FF}Tentativi Login falliti{FFFFFF}.");
  377. format(stringa, sizeof(stringa), "{00FF00}[Info:]{FFFFFF}%s{00BFFF} è stato kickato dal Server. Motivo: {FFFFFF}Tentativi Login falliti{00BFFF}.", nome);
  378. SendClientMessageToAll(BLU_CHIARO, stringa);
  379. Kick(playerid);
  380. }
  381. return 0;
  382. }
  383. }
  384. else if(!response)
  385. {
  386. GetPlayerName(playerid, nome, 24);
  387. SendClientMessage(playerid, BLU_CHIARO, "{00FF00}[Info:] {FFFFFF}Sei stato kickato. Motivo: {FF66FF}Login obbligatorio{FFFFFF}.");
  388. format(stringa, sizeof(stringa), "{00FF00}[Info:] {FFFFFF}%s{00BFFF} è stato kickato dal Server. Motivo: {FFFFFF}Login obbligatorio{00BFFF}.", nome);
  389. SendClientMessageToAll(BLU_CHIARO, stringa);
  390. Kick(playerid);
  391. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  392. }
  393. }
  394. return 1;
  395. }
  396.  
  397. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  398. {
  399. return 1;
  400. }
  401.  
  402. //Strtok
  403. stock strrest(const string[], &index)
  404. {
  405. new length = strlen(string);
  406. while ((index < length) && (string[index] <= ' '))
  407. {
  408. index++;
  409. }
  410. new offset = index;
  411. new result[128];
  412. while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
  413. {
  414. result[index - offset] = string[index];
  415. index++;
  416. }
  417. result[index - offset] = EOS;
  418. return result;
  419. }
  420.  
  421. //Salva Account
  422. SalvaAccount(playerid)
  423. {
  424. GetPlayerName(playerid, nome, 24);
  425. format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
  426. dini_IntSet(pFile, "Soldi", GetPlayerMoney(playerid));
  427. dini_IntSet(pFile, "Kills", PlayerInfo[playerid][pKills]);
  428. dini_IntSet(pFile, "Deaths", PlayerInfo[playerid][pDeaths]);
  429. dini_IntSet(pFile, "Admin", PlayerInfo[playerid][pAdmin]);
  430. dini_IntSet(pFile, "Livello", PlayerInfo[playerid][pLivello]);
  431. dini_IntSet(pFile, "Registrato", PlayerInfo[playerid][pRegistrato]);
  432. Loggato[playerid] = false;
  433. return 1;
  434. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement