MicroKyrr

[BIOS]Marcel Logging Script

Jan 27th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.58 KB | None | 0 0
  1. //Log Filterscript by [Bios]Marcel
  2.  
  3. //INCLUDES
  4. #include <a_samp>
  5. #include <Directory>
  6. #include <Dini>
  7. #include <a_http>
  8. #include <zcmd>
  9. #include <sscanf2>
  10.  
  11. //PUBLIC VARIABLES
  12. new VERSION[8] = "1.3.0.4"; //DO NOT CHANGE THIS, IT TELLS U IF THERE IS A NEWER VERSION!
  13. new
  14. savetime = 0,
  15. PositionLogging,
  16. ChatLogging,
  17. CommandLogging,
  18. ShootingLogging,
  19. DeathLogging,
  20. ConnectLogging,
  21. DisconnectLogging,
  22. InteriorLogging,
  23. RconLoginLogging,
  24. CarEnterLogging,
  25. CarExitLogging,
  26. RconCommandLogging,
  27. SaveMode,
  28. Timer[MAX_PLAYERS],
  29. gPath[70],
  30. File[16]="Logs/Config.cfg";
  31.  
  32. //DEFINES
  33. #define LOGMENU 1
  34. #define LOGCONFIG 2
  35. #define SAVEMODE2_CHOOSEPLAYER 3
  36. #define SAVEMODE3_CLEAN 4
  37. #define SAVEMODE4_CHOOSE 5
  38. #define S4_CLEAN_POSITION 6
  39. #define S4_CLEAN_CHAT 7
  40. #define S4_CLEAN_COMMAND 8
  41. #define S4_CLEAN_SHOOTING 9
  42. #define S4_CLEAN_DEATH 10
  43. #define S4_CLEAN_CONNECT 11
  44. #define S4_CLEAN_DISCONNECT 12
  45. #define S4_CLEAN_INTERIOR 13
  46. #define S4_CLEAN_RCONLOGIN 14
  47. #define S4_CLEAN_CARENTER 15
  48. #define S4_CLEAN_CAREXIT 16
  49. #define S4_CLEAN_RCONCOMMAND 17
  50. #define POSLOGINT 18
  51. #define SAVEMODE1_CHOOSEPLAYER 19
  52. #define SAVEMODE1_CHOOSELOG 20
  53.  
  54. #define CULPRIT 1
  55. #define VICTIM 2
  56.  
  57. //PUBLICS (default)
  58. public OnFilterScriptInit()
  59. {
  60. printf("[Logging System] Log Filterscript loaded.");
  61. checkVersion();
  62. DirCreate("Logs");
  63. if(fexist("Logs/LogConfig.cfg"))
  64. {
  65. dini_Create(File);
  66. dini_IntSet(File,"PositionLogging",dini_Int("Logs/LogConfig.cfg","PositionLogging"));
  67. dini_IntSet(File,"ChatLogging",dini_Int("Logs/LogConfig.cfg","ChatLogging"));
  68. dini_IntSet(File,"CommandLogging",dini_Int("Logs/LogConfig.cfg","CommandLogging"));
  69. dini_IntSet(File,"ShootingLogging",dini_Int("Logs/LogConfig.cfg","ShootingLogging"));
  70. dini_IntSet(File,"DeathLogging",dini_Int("Logs/LogConfig.cfg","DeathLogging"));
  71. dini_IntSet(File,"ConnectLogging",dini_Int("Logs/LogConfig.cfg","ConnectLogging"));
  72. dini_IntSet(File,"DisconnectLogging",dini_Int("Logs/LogConfig.cfg","DisconnectLogging"));
  73. dini_IntSet(File,"InteriorLogging",dini_Int("Logs/LogConfig.cfg","InteriorLogging"));
  74. dini_IntSet(File,"RconLoginLogging",dini_Int("Logs/LogConfig.cfg","RconLoginLogging"));
  75. dini_IntSet(File,"CarEnterLogging",dini_Int("Logs/LogConfig.cfg","CarEnterLogging"));
  76. dini_IntSet(File,"CarExitLogging",dini_Int("Logs/LogConfig.cfg","CarExitLogging"));
  77. dini_IntSet(File,"RconCommandLogging",dini_Int("Logs/LogConfig.cfg","RconCommandLogging"));
  78. dini_IntSet(File,"SaveMode",dini_Int("Logs/LogConfig.cfg","SaveMode"));
  79. dini_Set(File,"LogFilesPerX","no");
  80. dini_IntSet(File,"PositionLogInterval",dini_Int("Logs/LogConfig.cfg","PositionLogInterval"));
  81. }
  82. if(dini_Create(File))
  83. {
  84. dini_IntSet(File,"PositionLogging",1);
  85. dini_IntSet(File,"ChatLogging",1);
  86. dini_IntSet(File,"CommandLogging",1);
  87. dini_IntSet(File,"ShootingLogging",1);
  88. dini_IntSet(File,"DeathLogging",1);
  89. dini_IntSet(File,"ConnectLogging",1);
  90. dini_IntSet(File,"DisconnectLogging",1);
  91. dini_IntSet(File,"InteriorLogging",1);
  92. dini_IntSet(File,"RconLoginLogging",1);
  93. dini_IntSet(File,"CarEnterLogging",1);
  94. dini_IntSet(File,"CarExitLogging",1);
  95. dini_IntSet(File,"RconCommandLogging",1);
  96. dini_IntSet(File,"SaveMode",1);
  97. dini_Set(File,"LogFilesPerX","no");
  98. dini_IntSet(File,"PositionLogInterval",1500);
  99. }
  100. LoadCFG();
  101. if((SaveMode > 4) || (SaveMode < 1))
  102. {
  103. dini_IntSet(File,"SaveMode",1);
  104. print("[Logging System]The SaveMode was automatically set to 1 since it wasn't in range of 1 and 4.");
  105. }
  106. if(SaveMode == 4)
  107. {
  108. dini_Create("Logs/Chat.log");
  109. dini_Create("Logs/Command.log");
  110. dini_Create("Logs/Connect.log");
  111. dini_Create("Logs/Death.log");
  112. dini_Create("Logs/Disconnect.log");
  113. dini_Create("Logs/Interior.log");
  114. dini_Create("Logs/CarEnter.log");
  115. dini_Create("Logs/CarExit.log");
  116. dini_Create("Logs/Shooting.log");
  117. dini_Create("Logs/RconLogin.log");
  118. dini_Create("Logs/Position.log");
  119. }
  120. if(RconCommandLogging)
  121. {
  122. if(SaveMode != 3)
  123. {
  124. dini_Create("Logs/RconCommand.log");
  125. }
  126. }
  127. return 1;
  128. }
  129.  
  130. public OnRconLoginAttempt(ip[], password[], success)
  131. {
  132. if(RconLoginLogging)
  133. {
  134. new IP[16];
  135. if(!success)
  136. {
  137. for(new i=0; i<MAX_PLAYERS; i++)
  138. {
  139. GetPlayerIp(i, IP, 16);
  140. if(!strcmp(ip, IP, true))
  141. {
  142. RconAttemptLog(i,false,ip,password);
  143. break;
  144. }
  145. }
  146. }
  147. else
  148. {
  149. for(new i=0; i<MAX_PLAYERS; i++)
  150. {
  151. GetPlayerIp(i, IP, 16);
  152. if(!strcmp(ip, IP, true))
  153. {
  154. RconAttemptLog(i,true,ip,password);
  155. break;
  156. }
  157. }
  158. }
  159. }
  160. return 1;
  161. }
  162. public OnRconCommand(cmd[])
  163. {
  164. RCommand(cmd);
  165. return 1;
  166. }
  167.  
  168. public OnPlayerSpawn(playerid)
  169. {
  170. if(PositionLogging)
  171. {
  172. Timer[playerid] = SetTimerEx("LogLoc",dini_Int(File,"PosiotionLogInterval"),true,"i",playerid);
  173. }
  174. return 1;
  175. }
  176.  
  177. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  178. {
  179. if(ShootingLogging)
  180. {
  181. ShootingLog(playerid,issuerid,amount,weaponid,CULPRIT);
  182. ShootingLog(issuerid,playerid,amount,weaponid,VICTIM);
  183. }
  184. return 1;
  185. }
  186.  
  187. public OnPlayerConnect(playerid)
  188. {
  189. if(SaveMode == 1)
  190. {
  191. new path[80];
  192. format(path,80,"Logs/%s",getName(playerid));
  193. DirCreate(path);
  194. }
  195. else if(SaveMode == 2)
  196. {
  197. new path[80];
  198. format(path,80,"Logs/%s.log",getName(playerid));
  199. dini_Create(path);
  200. }
  201. if(ConnectLogging)
  202. {
  203. ConnectLog(playerid);
  204. }
  205. return 1;
  206. }
  207.  
  208. public OnPlayerDisconnect(playerid, reason)
  209. {
  210. if(DisconnectLogging)
  211. {
  212. DisconnectLog(playerid, reason);
  213. }
  214. KillTimer(Timer[playerid]);
  215. return 1;
  216. }
  217.  
  218. public OnPlayerDeath(playerid, killerid, reason)
  219. {
  220. if(DeathLogging)
  221. {
  222. if(killerid != INVALID_PLAYER_ID)
  223. {
  224. DeathLog(playerid,killerid,reason,VICTIM);
  225. DeathLog(killerid,playerid,reason,CULPRIT);
  226. }
  227. else
  228. {
  229. DeathLog(playerid,-1,reason,0);
  230. }
  231. }
  232.  
  233. }
  234.  
  235. public OnPlayerText(playerid, text[])
  236. {
  237. if(ChatLogging)
  238. {
  239. ChatLog(playerid, text);
  240. }
  241. return 1;
  242. }
  243.  
  244. public OnPlayerCommandText(playerid, cmdtext[])
  245. {
  246. if(CommandLogging)
  247. {
  248. CommandLog(playerid, cmdtext);
  249. }
  250. return 0;
  251. }
  252.  
  253. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  254. {
  255. if(CarEnterLogging)
  256. {
  257. SetTimerEx("LogCar",3000,false,"i",playerid);
  258. }
  259. return 1;
  260. }
  261.  
  262. public OnPlayerExitVehicle(playerid, vehicleid)
  263. {
  264. if(CarExitLogging)
  265. {
  266. OutLog(playerid,GetPlayerVehicleSeat(playerid),vehicleid,GetVehicleModel(vehicleid));
  267. }
  268. return 1;
  269. }
  270.  
  271. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  272. {
  273. if(dialogid == LOGMENU)
  274. {
  275. if(response)
  276. {
  277. if(listitem == 0)
  278. {
  279. Log_Config(playerid);
  280. }
  281. else
  282. {
  283. if(savetime != 0)
  284. {
  285. Log_Config(playerid);
  286. }
  287. else
  288. {
  289. SendClientMessage(playerid,-1,"[Logging System] You can't use this function since you are using the function to save logfiles hourly/daily/monthly/yearly.CreateActor (Will be added in alter patches)");
  290. }
  291. }
  292. }
  293. }
  294. else if(dialogid == SAVEMODE1_CHOOSEPLAYER)
  295. {
  296. if(response)
  297. {
  298. new path[70];
  299. format(path,70,"Logs/%s",inputtext);
  300. if(CheckPath(path))
  301. {
  302. gPath = path;
  303. ShowPlayerDialog(playerid,SAVEMODE1_CHOOSELOG,DIALOG_STYLE_LIST,"Log clean (Step 2)","Position log\nChat log\nCommand log\nShooting log\nDeath log\nConnect log\nDisconnect log\nInterior log\n Rcon login log\nCarEnter log\nCarExit log","Confirm","Back");
  304. }
  305. }
  306. else
  307. {
  308. Log_Clean(playerid);
  309. }
  310. }
  311. else if(dialogid == SAVEMODE1_CHOOSELOG)
  312. {
  313. if(response)
  314. {
  315. new path[75];
  316. if(listitem == 0)
  317. {
  318. format(path,75,"%s/Position.log",gPath);
  319. fremove(path);
  320. dini_Create(path);
  321. }
  322. else if(listitem == 1)
  323. {
  324. format(path,75,"%s/Chat.log",gPath);
  325. fremove(path);
  326. dini_Create(path);
  327. }
  328. else if(listitem == 2)
  329. {
  330. format(path,75,"%s/Command.log",gPath);
  331. fremove(path);
  332. dini_Create(path);
  333. }
  334. else if(listitem == 3)
  335. {
  336. format(path,75,"%s/Shooting.log",gPath);
  337. fremove(path);
  338. dini_Create(path);
  339. }
  340. else if(listitem == 4)
  341. {
  342. format(path,75,"%s/Death.log",gPath);
  343. fremove(path);
  344. dini_Create(path);
  345. }
  346. else if(listitem == 5)
  347. {
  348. format(path,75,"%s/Connect.log",gPath);
  349. fremove(path);
  350. dini_Create(path);
  351. }
  352. else if(listitem == 6)
  353. {
  354. format(path,75,"%s/Disconnecct.log",gPath);
  355. fremove(path);
  356. dini_Create(path);
  357. }
  358. else if(listitem == 7)
  359. {
  360. format(path,75,"%s/Interior.log",gPath);
  361. fremove(path);
  362. dini_Create(path);
  363. }
  364. else if(listitem == 8)
  365. {
  366. format(path,75,"%s/RconLogin.log",gPath);
  367. fremove(path);
  368. dini_Create(path);
  369. }
  370. else if(listitem == 9)
  371. {
  372. format(path,75,"%s/CarEnter.log",gPath);
  373. fremove(path);
  374. dini_Create(path);
  375. }
  376. else if(listitem == 10)
  377. {
  378. format(path,75,"%s/CarExit.log",gPath);
  379. fremove(path);
  380. dini_Create(path);
  381. }
  382. }
  383. else
  384. {
  385. ShowPlayerDialog(playerid,SAVEMODE1_CHOOSEPLAYER,DIALOG_STYLE_INPUT,"Log clean","Choose a player to delete his logfiles(You will choose the specific log afterwards)","Confirm","Back");
  386. }
  387. }
  388. else if(dialogid == SAVEMODE2_CHOOSEPLAYER)
  389. {
  390. if(response)
  391. {
  392. new path[70];
  393. format(path,70,"Logs/%s.log",inputtext);
  394. if(!fexist(path))
  395. {
  396. ShowPlayerDialog(playerid,SAVEMODE2_CHOOSEPLAYER,DIALOG_STYLE_INPUT,"Log clean","Which Player File should be cleaned?\n(The Full Playername not PlayerID)","Confirm","Back");
  397. GameTextForPlayer(playerid,"Invalid Playername! (Watch out for case sensitive)",3000,5);
  398. }
  399. else
  400. {
  401. fremove(path);
  402. dini_Create(path);
  403. new string2[70];
  404. format(string2,70,"%s's Log was cleaned successful.",inputtext);
  405. GameTextForPlayer(playerid,string2,3000,5);
  406. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  407. }
  408. }
  409. else
  410. {
  411. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  412. }
  413. }
  414. else if(dialogid == SAVEMODE3_CLEAN)
  415. {
  416. if(response)
  417. {
  418. fremove("Logs/Log.log");
  419. dini_Create("Logs/Log.log");
  420. GameTextForPlayer(playerid,"log cleaned successful.",3000,5);
  421. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  422. }
  423. else
  424. {
  425. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  426. }
  427. }
  428. else if(dialogid == S4_CLEAN_CHAT)
  429. {
  430. if(response)
  431. {
  432. fremove("Logs/Chat.log");
  433. dini_Create("Logs/Chat.log");
  434. GameTextForPlayer(playerid,"Chat log cleaned successful.",3000,5);
  435. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  436. }
  437. else
  438. {
  439. getLogSizes(playerid);
  440. }
  441. }
  442. else if(dialogid == S4_CLEAN_COMMAND)
  443. {
  444. if(response)
  445. {
  446. fremove("Logs/Command.log");
  447. dini_Create("Logs/Command.log");
  448. GameTextForPlayer(playerid,"Command log cleaned successful.",3000,5);
  449. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  450. }
  451. else
  452. {
  453. getLogSizes(playerid);
  454. }
  455. }
  456. else if(dialogid == S4_CLEAN_SHOOTING)
  457. {
  458. if(response)
  459. {
  460. fremove("Logs/Shooting.log");
  461. dini_Create("Logs/Shooting.log");
  462. GameTextForPlayer(playerid,"Shooting log cleaned successful.",3000,5);
  463. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  464. }
  465. else
  466. {
  467. getLogSizes(playerid);
  468. }
  469. }
  470. else if(dialogid == S4_CLEAN_DEATH)
  471. {
  472. if(response)
  473. {
  474. fremove("Logs/Death.log");
  475. dini_Create("Logs/Death.log");
  476. GameTextForPlayer(playerid,"Death log cleaned successful.",3000,5);
  477. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  478. }
  479. else
  480. {
  481. getLogSizes(playerid);
  482. }
  483. }
  484. else if(dialogid == S4_CLEAN_CONNECT)
  485. {
  486. if(response)
  487. {
  488. fremove("Logs/Connect.log");
  489. dini_Create("Logs/Connect.log");
  490. GameTextForPlayer(playerid,"Connect log cleaned successful.",3000,5);
  491. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  492. }
  493. else
  494. {
  495. getLogSizes(playerid);
  496. }
  497. }
  498. else if(dialogid == S4_CLEAN_DISCONNECT)
  499. {
  500. if(response)
  501. {
  502. fremove("Logs/Disconnect.log");
  503. dini_Create("Logs/Disconnect.log");
  504. GameTextForPlayer(playerid,"Disconnect log cleaned successful.",3000,5);
  505. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  506. }
  507. else
  508. {
  509. getLogSizes(playerid);
  510. }
  511. }
  512. else if(dialogid == S4_CLEAN_POSITION)
  513. {
  514. if(response)
  515. {
  516. fremove("Logs/Position.log");
  517. dini_Create("Logs/Position.log");
  518. GameTextForPlayer(playerid,"Interior log cleaned successful.",3000,5);
  519. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  520. }
  521. else
  522. {
  523. getLogSizes(playerid);
  524. }
  525. }
  526. else if(dialogid == S4_CLEAN_INTERIOR)
  527. {
  528. if(response)
  529. {
  530. fremove("Logs/Interior.log");
  531. dini_Create("Logs/Interior.log");
  532. GameTextForPlayer(playerid,"Interior log cleaned successful.",3000,5);
  533. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  534. }
  535. else
  536. {
  537. getLogSizes(playerid);
  538. }
  539. }
  540. else if(dialogid == S4_CLEAN_RCONLOGIN)
  541. {
  542. if(response)
  543. {
  544. fremove("Logs/RconLogin.log");
  545. dini_Create("Logs/RconLogin.log");
  546. GameTextForPlayer(playerid,"RconLogin log cleaned successful.",3000,5);
  547. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  548. }
  549. else
  550. {
  551. getLogSizes(playerid);
  552. }
  553. }
  554. else if(dialogid == S4_CLEAN_CARENTER)
  555. {
  556. if(response)
  557. {
  558. fremove("Logs/CarEnter.log");
  559. dini_Create("Logs/CarEnter.log");
  560. GameTextForPlayer(playerid,"CarEnter log cleaned successful.",3000,5);
  561. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  562. }
  563. else
  564. {
  565. getLogSizes(playerid);
  566. }
  567. }
  568. else if(dialogid == S4_CLEAN_CAREXIT)
  569. {
  570. if(response)
  571. {
  572. fremove("Logs/CarExit.log");
  573. dini_Create("Logs/CarExit.log");
  574. GameTextForPlayer(playerid,"CarExit log cleaned successful.",3000,5);
  575. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  576. }
  577. else
  578. {
  579. getLogSizes(playerid);
  580. }
  581. }
  582. else if(dialogid == S4_CLEAN_RCONCOMMAND)
  583. {
  584. if(response)
  585. {
  586. fremove("Logs/RconCommand.log");
  587. dini_Create("Logs/RconCommand.log");
  588. GameTextForPlayer(playerid,"RconCommand log cleaned successful.",3000,5);
  589. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  590. }
  591. else
  592. {
  593. getLogSizes(playerid);
  594. }
  595. }
  596. else if(dialogid == SAVEMODE4_CHOOSE)
  597. {
  598. if(response)
  599. {
  600. if(listitem == 0)
  601. {
  602. cleanLog(playerid,0);
  603. }
  604. else if(listitem == 1)
  605. {
  606. cleanLog(playerid,1);
  607. }
  608. else if(listitem == 2)
  609. {
  610. cleanLog(playerid,2);
  611. }
  612. else if(listitem == 3)
  613. {
  614. cleanLog(playerid,3);
  615. }
  616. else if(listitem == 4)
  617. {
  618. cleanLog(playerid,4);
  619. }
  620. else if(listitem == 5)
  621. {
  622. cleanLog(playerid,5);
  623. }
  624. else if(listitem == 6)
  625. {
  626. cleanLog(playerid,6);
  627. }
  628. else if(listitem == 7)
  629. {
  630. cleanLog(playerid,7);
  631. }
  632. else if(listitem == 8)
  633. {
  634. cleanLog(playerid,8);
  635. }
  636. else if(listitem == 9)
  637. {
  638. cleanLog(playerid,9);
  639. }
  640. else if(listitem == 10)
  641. {
  642. cleanLog(playerid,10);
  643. }
  644. else
  645. {
  646. cleanLog(playerid,11);
  647. }
  648. }
  649. }
  650. else if(dialogid == LOGCONFIG)
  651. {
  652. if(response)
  653. {
  654. if(listitem == 0)
  655. {
  656. if(PositionLogging)
  657. {
  658. PositionLogging = 0;
  659. dini_IntSet(File,"PositionLogging",0);
  660. Log_Config(playerid);
  661. }
  662. else
  663. {
  664. PositionLogging = 1;
  665. dini_IntSet(File,"PositionLogging",1);
  666. Log_Config(playerid);
  667. }
  668. }
  669. else if(listitem == 1)
  670. {
  671. if(ChatLogging)
  672. {
  673. ChatLogging = 0;
  674. dini_IntSet(File,"ChatLogging",0);
  675. Log_Config(playerid);
  676. }
  677. else
  678. {
  679. ChatLogging = 1;
  680. dini_IntSet(File,"ChatLogging",1);
  681. Log_Config(playerid);
  682. }
  683. }
  684. else if(listitem == 2)
  685. {
  686. if(CommandLogging)
  687. {
  688. CommandLogging = 0;
  689. dini_IntSet(File,"CommandLogging",0);
  690. Log_Config(playerid);
  691. }
  692. else
  693. {
  694. CommandLogging = 1;
  695. dini_IntSet(File,"CommandLogging",1);
  696. Log_Config(playerid);
  697. }
  698. }
  699. else if(listitem == 3)
  700. {
  701. if(ShootingLogging)
  702. {
  703. ShootingLogging = 0;
  704. dini_IntSet(File,"ShootingLogging",0);
  705. Log_Config(playerid);
  706. }
  707. else
  708. {
  709. ShootingLogging = 1;
  710. dini_IntSet(File,"ShootingLogging",1);
  711. Log_Config(playerid);
  712. }
  713. }
  714. else if(listitem == 4)
  715. {
  716. if(DeathLogging)
  717. {
  718. DeathLogging = 0;
  719. dini_IntSet(File,"DeathLogging",0);
  720. Log_Config(playerid);
  721. }
  722. else
  723. {
  724. DeathLogging = 1;
  725. dini_IntSet(File,"DeathLogging",1);
  726. Log_Config(playerid);
  727. }
  728. }
  729. else if(listitem == 5)
  730. {
  731. if(ConnectLogging)
  732. {
  733. ConnectLogging = 0;
  734. dini_IntSet(File,"ConnectLogging",0);
  735. Log_Config(playerid);
  736. }
  737. else
  738. {
  739. ConnectLogging = 1;
  740. dini_IntSet(File,"ConnectLogging",1);
  741. Log_Config(playerid);
  742. }
  743. }
  744. else if(listitem == 6)
  745. {
  746. if(DisconnectLogging)
  747. {
  748. DisconnectLogging = 0;
  749. dini_IntSet(File,"DisconnectLogging",0);
  750. Log_Config(playerid);
  751. }
  752. else
  753. {
  754. DisconnectLogging = 1;
  755. dini_IntSet(File,"DisconnectLogging",1);
  756. Log_Config(playerid);
  757. }
  758. }
  759. else if(listitem == 7)
  760. {
  761. if(InteriorLogging)
  762. {
  763. InteriorLogging = 0;
  764. dini_IntSet(File,"InteriorLogging",0);
  765. Log_Config(playerid);
  766. }
  767. else
  768. {
  769. InteriorLogging = 1;
  770. dini_IntSet(File,"InteriorLogging",1);
  771. Log_Config(playerid);
  772. }
  773. }
  774. else if(listitem == 8)
  775. {
  776. if(RconLoginLogging)
  777. {
  778. RconLoginLogging = 0;
  779. dini_IntSet(File,"RconLoginLogging",0);
  780. Log_Config(playerid);
  781. }
  782. else
  783. {
  784. RconLoginLogging = 1;
  785. dini_IntSet(File,"RconLoginLogging",1);
  786. Log_Config(playerid);
  787. }
  788. }
  789. else if(listitem == 9)
  790. {
  791. if(CarEnterLogging)
  792. {
  793. CarEnterLogging = 0;
  794. dini_IntSet(File,"CarEnterLogging",0);
  795. Log_Config(playerid);
  796. }
  797. else
  798. {
  799. CarEnterLogging = 1;
  800. dini_IntSet(File,"CarEnterLogging",1);
  801. Log_Config(playerid);
  802. }
  803. }
  804. else if(listitem == 10)
  805. {
  806. if(CarExitLogging)
  807. {
  808. CarExitLogging = 0;
  809. dini_IntSet(File,"CarExitLogging",0);
  810. Log_Config(playerid);
  811. }
  812. else
  813. {
  814. CarExitLogging = 1;
  815. dini_IntSet(File,"CarExitLogging",1);
  816. Log_Config(playerid);
  817. }
  818. }
  819. else if(listitem == 11)
  820. {
  821. if(RconCommandLogging)
  822. {
  823. RconCommandLogging = 0;
  824. dini_IntSet(File,"RconCommandLogging",0);
  825. Log_Config(playerid);
  826. }
  827. else
  828. {
  829. RconCommandLogging = 1;
  830. dini_IntSet(File,"RconCommandLogging",1);
  831. Log_Config(playerid);
  832. }
  833. }
  834. else if(listitem == 12)
  835. {
  836. SaveMode++;
  837. if(SaveMode == 5)
  838. {
  839. SaveMode = 1;
  840. }
  841. dini_IntSet(File,"SaveMode",SaveMode);
  842. Log_Config(playerid);
  843. }
  844. else if(listitem == 13)
  845. {
  846. if(SaveMode == 1)
  847. savetime++;
  848. if(savetime == 5)
  849. {
  850. savetime = 0;
  851. }
  852. dini_IntSet(File,"LogFilesPerX",savetime);
  853. Log_Config(playerid);
  854. }
  855. else if(listitem == 14)
  856. {
  857. ShowPlayerDialog(playerid,POSLOGINT,DIALOG_STYLE_INPUT,"Position Log Interval","Enter a Interval for the player position logging.\nIf u enter a too low interval it may cause problems.\nThe format is milliseconds.","Select","Back");
  858. }
  859. else if(listitem == 16)
  860. {
  861. PositionLogging = 0;
  862. dini_IntSet(File,"PositionLogging",0);
  863. ChatLogging = 0;
  864. dini_IntSet(File,"ChatLogging",0);
  865. ConnectLogging = 0;
  866. dini_IntSet(File,"ConnectLogging",0);
  867. DisconnectLogging = 0;
  868. dini_IntSet(File,"DisconnectLogging",0);
  869. ShootingLogging = 0;
  870. dini_IntSet(File,"ShootingLogging",0);
  871. DeathLogging = 0;
  872. dini_IntSet(File,"DeathLogging",0);
  873. RconLoginLogging = 0;
  874. dini_IntSet(File,"RconLoginLogging",0);
  875. InteriorLogging = 0;
  876. dini_IntSet(File,"InteriorLogging",0);
  877. CarEnterLogging = 0;
  878. dini_IntSet(File,"CarEnterLogging",0);
  879. CarExitLogging = 0;
  880. dini_IntSet(File,"CarExitLogging",0);
  881. CommandLogging = 0;
  882. dini_IntSet(File,"CommandLogging",0);
  883. RconCommandLogging = 0;
  884. dini_IntSet(File,"RconCommandLogging",0);
  885. Log_Config(playerid);
  886. }
  887. else if(listitem == 17)
  888. {
  889. PositionLogging = 1;
  890. dini_IntSet(File,"PositionLogging",1);
  891. ChatLogging = 1;
  892. dini_IntSet(File,"ChatLogging",1);
  893. ConnectLogging = 1;
  894. dini_IntSet(File,"ConnectLogging",1);
  895. DisconnectLogging = 1;
  896. dini_IntSet(File,"DisconnectLogging",1);
  897. ShootingLogging = 1;
  898. dini_IntSet(File,"ShootingLogging",1);
  899. DeathLogging = 1;
  900. dini_IntSet(File,"DeathLogging",1);
  901. RconLoginLogging = 1;
  902. dini_IntSet(File,"RconLoginLogging",1);
  903. InteriorLogging = 1;
  904. dini_IntSet(File,"InteriorLogging",1);
  905. CarEnterLogging = 1;
  906. dini_IntSet(File,"CarEnterLogging",1);
  907. CarExitLogging = 1;
  908. dini_IntSet(File,"CarExitLogging",1);
  909. CommandLogging = 1;
  910. dini_IntSet(File,"CommandLogging",1);
  911. RconCommandLogging = 1;
  912. dini_IntSet(File,"RconCommandLogging",1);
  913. Log_Config(playerid);
  914. }
  915. }
  916. }
  917. else if(dialogid == POSLOGINT)
  918. {
  919. if(response)
  920. {
  921. if(isNumeric(inputtext))
  922. {
  923. dini_IntSet(File,"PositionLogInterval",strval(inputtext));
  924. } else {
  925. ShowPlayerDialog(playerid,POSLOGINT,DIALOG_STYLE_INPUT,"Position Log Interval","The text that u entered was no number.\n\nEnter a Interval for the player position logging.\nIf u enter a too low interval it may cause problems.\nThe format is milliseconds.","Select","Back");
  926. }
  927. }
  928. else
  929. {
  930. Log_Config(playerid);
  931. }
  932. }
  933. return 1;
  934. }
  935.  
  936. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  937. {
  938. if(InteriorLogging)
  939. {
  940. InteriorLog(playerid,newinteriorid,oldinteriorid);
  941. }
  942. return 1;
  943. }
  944.  
  945. //STOCKS
  946. stock checkVersion()
  947. {
  948. HTTP(1,HTTP_GET,"dl.dropboxusercontent.com/u/89362253/versions/samplog/version.txt","","MyHttpResponse");
  949. }
  950.  
  951. stock LoadCFG()
  952. {
  953. PositionLogging = dini_Int(File,"PositionLogging");
  954. ChatLogging = dini_Int(File,"ChatLogging");
  955. CommandLogging = dini_Int(File,"CommandLogging");
  956. ShootingLogging = dini_Int(File,"ShootingLogging");
  957. DeathLogging = dini_Int(File,"DeathLogging");
  958. ConnectLogging = dini_Int(File,"ConnectLogging");
  959. DisconnectLogging = dini_Int(File,"DisconnectLogging");
  960. InteriorLogging = dini_Int(File,"InteriorLogging");
  961. RconLoginLogging = dini_Int(File,"RconLoginLogging");
  962. CarEnterLogging = dini_Int(File,"CarEnterLogging");
  963. CarExitLogging = dini_Int(File,"CarExitLogging");
  964. RconCommandLogging = dini_Int(File,"RconCommandLogging");
  965. SaveMode = dini_Int(File,"SaveMode");
  966. savetime = dini_Int(File,"LogFilesPerX");
  967. return 1;
  968. }
  969. stock getDateAndTime()
  970. {
  971. new fyear, fmonth, fday,
  972. fhour, fminute, fsecond,date[32];
  973. getdate(fyear, fmonth, fday);
  974. gettime(fhour, fminute, fsecond);
  975. format(date, 32,"[%02d/%02d/%04d %02d:%02d:%02d]", fday, fmonth, fyear, fhour, fminute, fsecond);
  976. return date;
  977. }
  978. stock getTimeInfo()
  979. {
  980. new fyear, fmonth, fday,
  981. fhour, date[32];
  982. getdate(fyear, fmonth, fday);
  983. gettime(fhour);
  984. switch(savetime)
  985. {
  986. case 0: date = "";
  987. case 1: format(date, 32,"-%02d-%02d-%04d_%02d", fday, fmonth, fyear, fhour);
  988. case 2: format(date, 32,"-%02d-%02d-%04d", fday, fmonth, fyear);
  989. case 3: format(date, 32,"-%02d-%04d", fmonth, fyear);
  990. case 4: format(date, 32,"-%04d", fyear);
  991. }
  992. return date;
  993. }
  994. stock isNumeric(const string[])
  995. {
  996. for (new i = 0, j = strlen(string); i < j; i++)
  997. {
  998. if (string[i] > '9' || string[i] < '0') return 0;
  999. }
  1000. return 1;
  1001. }
  1002. stock getName(playerid)
  1003. {
  1004. new name[MAX_PLAYER_NAME];
  1005. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  1006. return name;
  1007. }
  1008.  
  1009. stock ChatLog(playerid, text[])
  1010. {
  1011. new path[80];
  1012. switch(SaveMode)
  1013. {
  1014. case 1: format(path,80,"Logs/%s/Chat%s.log",getName(playerid),getTimeInfo());
  1015. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1016. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1017. case 4: format(path,80,"Logs/Chat%s.log",getTimeInfo());
  1018. }
  1019. new
  1020. File:lFile = fopen(path, io_append),
  1021. logData[220];
  1022. format(logData, 220,"%s %s: %s \r\n", getDateAndTime(), getName(playerid), text);
  1023. fwrite(lFile, logData);
  1024. fclose(lFile);
  1025. return 1;
  1026. }
  1027. stock ConnectLog(playerid)
  1028. {
  1029. new path[80];
  1030. switch(SaveMode)
  1031. {
  1032. case 1: format(path,80,"Logs/%s/Connect%s.log",getName(playerid),getTimeInfo());
  1033. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1034. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1035. case 4: format(path,80,"Logs/Connect%s.log",getTimeInfo());
  1036. }
  1037. new
  1038. File:lFile = fopen(path, io_append),
  1039. logData[100],ip[16];
  1040. GetPlayerIp(playerid,ip,16);
  1041. format(logData, 100,"%s %s connected with IP: %s \r\n",getDateAndTime(), getName(playerid), ip);
  1042. fwrite(lFile, logData);
  1043. fclose(lFile);
  1044. return 1;
  1045. }
  1046. stock DisconnectLog(playerid, reason)
  1047. {
  1048. new path[80];
  1049. switch(SaveMode)
  1050. {
  1051. case 1: format(path,80,"Logs/%s/Disconnect%s.log",getName(playerid),getTimeInfo());
  1052. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1053. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1054. case 4: format(path,80,"Logs/Disconnect%s.log",getTimeInfo());
  1055. }
  1056. new
  1057. File:lFile = fopen(path, io_append),
  1058. logData[100],ip[16],string[14];
  1059. GetPlayerIp(playerid,ip,16);
  1060. switch(reason)
  1061. {
  1062. case 0: string = "Timed out";
  1063. case 1: string = "Leaving";
  1064. case 2: string = "Kicked/Banned";
  1065. }
  1066. format(logData, 100,"%s %s (IP:%s) disconnected, reason: %s \r\n", getDateAndTime(), getName(playerid), ip, string);
  1067. fwrite(lFile, logData);
  1068. fclose(lFile);
  1069. return 1;
  1070. }
  1071. stock CommandLog(playerid, cmdtext[])
  1072. {
  1073. new path[80];
  1074. switch(SaveMode)
  1075. {
  1076. case 1: format(path,80,"Logs/%s/Command%s.log",getName(playerid),getTimeInfo());
  1077. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1078. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1079. case 4: format(path,80,"Logs/Command%s.log",getTimeInfo());
  1080. }
  1081. new
  1082. File:lFile = fopen(path, io_append),
  1083. logData[200];
  1084. format(logData, 200,"%s %s: %s \r\n", getDateAndTime(), getName(playerid), cmdtext);
  1085. fwrite(lFile, logData);
  1086. fclose(lFile);
  1087. return 1;
  1088. }
  1089. stock DeathLog(playerid,killerid,reason,victimcase)
  1090. {
  1091. new path[80];
  1092. switch(SaveMode)
  1093. {
  1094. case 1: format(path,80,"Logs/%s/Death%s.log",getName(playerid),getTimeInfo());
  1095. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1096. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1097. case 4: format(path,80,"Logs/Death%s.log",getTimeInfo());
  1098. }
  1099. new
  1100. File:lFile = fopen(path, io_append),
  1101. logData[200];
  1102. if(killerid != INVALID_PLAYER_ID)
  1103. {
  1104. if(victimcase == VICTIM)
  1105. {
  1106. format(logData, 200,"%s %s was killed by: %s, weapon: %s \r\n", getDateAndTime(), getName(playerid), getName(killerid), reason);
  1107. }
  1108. else if(victimcase == CULPRIT)
  1109. {
  1110. format(logData, 200,"%s %s has killed %s, weapon: %s \r\n",getDateAndTime(), getName(killerid), getName(playerid), reason);
  1111. }
  1112. }
  1113. else
  1114. {
  1115. format(logData, 200,"%s %s died, reason: %s \r\n", getDateAndTime(), getName(playerid), reason);
  1116. }
  1117. fwrite(lFile, logData);
  1118. fclose(lFile);
  1119. return 1;
  1120. }
  1121. stock ShootingLog(playerid,damagedid,Float:amount,weaponid,victimcase)
  1122. {
  1123. new path[80];
  1124. switch(SaveMode)
  1125. {
  1126. case 1: format(path,80,"Logs/%s/Shooting%s.log",getName(playerid),getTimeInfo());
  1127. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1128. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1129. case 4: format(path,80,"Logs/Shooting%s.log",getTimeInfo());
  1130. }
  1131. new
  1132. File:lFile = fopen(path, io_append),
  1133. logData[200];
  1134. if(victimcase == CULPRIT)
  1135. {
  1136. format(logData, 200,"%s %s ---> %s %f %i \r\n", getDateAndTime(), getName(playerid), getName(damagedid), Float:amount, weaponid);
  1137. }
  1138. else if(victimcase == VICTIM)
  1139. {
  1140. format(logData, 200,"%s %s ---> %s %f %i \r\n", getDateAndTime(), getName(damagedid), getName(playerid), Float:amount, weaponid);
  1141. }
  1142. fwrite(lFile, logData);
  1143. fclose(lFile);
  1144. return 1;
  1145. }
  1146. stock InteriorLog(playerid,int1,int2)
  1147. {
  1148. new path[80];
  1149. switch(SaveMode)
  1150. {
  1151. case 1: format(path,80,"Logs/%s/Interior%s.log",getName(playerid),getTimeInfo());
  1152. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1153. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1154. case 4: format(path,80,"Logs/Interior%s.log",getTimeInfo());
  1155. }
  1156. new
  1157. File:lFile = fopen(path, io_append),
  1158. logData[200];
  1159. format(logData, 200,"%s %s's new interior: %i, old interior: %i \r\n", getDateAndTime(), getName(playerid), int1,int2);
  1160. fwrite(lFile, logData);
  1161. fclose(lFile);
  1162. return 1;
  1163. }
  1164. stock OutLog(playerid, seat, vehicleid, modelid)
  1165. {
  1166. new path[80];
  1167. switch(SaveMode)
  1168. {
  1169. case 1: format(path,80,"Logs/%s/CarExit%s.log",getName(playerid),getTimeInfo());
  1170. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1171. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1172. case 4: format(path,80,"Logs/CarExit%s.log",getTimeInfo());
  1173. }
  1174. new seatstr[10];
  1175. switch(seat)
  1176. {
  1177. case 0: {seatstr = "Driver";}
  1178. default: {seatstr = "Passenger";}
  1179. }
  1180. new
  1181. File:lFile = fopen(path, io_append),
  1182. logData[200];
  1183. format(logData, 200,"%s %s exited a vehicle, he/she was a %s, VehicleID: %i, ModelID: %i \r\n", getDateAndTime(), getName(playerid), seatstr, vehicleid, modelid);
  1184. fwrite(lFile, logData);
  1185. fclose(lFile);
  1186. return 1;
  1187. }
  1188. stock RconAttemptLog(playerid,bool:success, ip[],password[])
  1189. {
  1190. new path[80];
  1191. switch(SaveMode)
  1192. {
  1193. case 1: format(path,80,"Logs/%s/RconLogin%s.log",getName(playerid),getTimeInfo());
  1194. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1195. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1196. case 4: format(path,80,"Logs/RconLogin%s.log",getTimeInfo());
  1197. }
  1198. new
  1199. File:lFile = fopen(path, io_append),
  1200. logData[200];
  1201. if(success == false)
  1202. {
  1203. format(logData, 200,"%s %s (IP:%s) has failed to login as RCON, password: %s\r\n",getDateAndTime(), getName(playerid), ip, password);
  1204. }
  1205. else
  1206. {
  1207. format(logData, 200,"%s %s (IP:%s) has logged in as RCON \r\n", getDateAndTime(), getName(playerid), ip);
  1208. }
  1209. fwrite(lFile, logData);
  1210. fclose(lFile);
  1211. return 1;
  1212. }
  1213. stock RCommand(cmd[])
  1214. {
  1215. new path[21];
  1216. if(SaveMode == 3)
  1217. {
  1218. format(path,80,"Logs/Log%s.log",getTimeInfo());
  1219. }
  1220. else
  1221. {
  1222. format(path,80,"Logs/RconCommand%s.log",getTimeInfo());
  1223. }
  1224. new
  1225. File:lFile = fopen(path, io_append),
  1226. logData[200];
  1227. format(logData, 200,"%s /rcon %s \r\n",getDateAndTime(), cmd);
  1228. fwrite(lFile, logData);
  1229. fclose(lFile);
  1230. return 1;
  1231. }
  1232.  
  1233. stock InLog(playerid, seat, vehicleid, modelid)
  1234. {
  1235. new path[80];
  1236. switch(SaveMode)
  1237. {
  1238. case 1: format(path,80,"Logs/%s/CarEnter%s.log",getName(playerid),getTimeInfo());
  1239. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1240. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1241. case 4: format(path,80,"Logs/CarEnter%s.log",getTimeInfo());
  1242. }
  1243. new
  1244. File:lFile = fopen(path, io_append),
  1245. logData[200],seatstr[10];
  1246. switch(seat)
  1247. {
  1248. case 0: {seatstr = "Driver";}
  1249. default: {seatstr = "Passenger";}
  1250. }
  1251. format(logData, 200,"%s %s entered a vehicle, he was a %s, VehicleID: %i, ModelID: %i \r\n",getDateAndTime(), getName(playerid), seatstr, vehicleid, modelid);
  1252. fwrite(lFile, logData);
  1253. fclose(lFile);
  1254. return 1;
  1255. }
  1256. stock LogPlayerLocation(playerid,Float:X,Float:Y,Float:Z)
  1257. {
  1258. new path[80];
  1259. switch(SaveMode)
  1260. {
  1261. case 1: format(path,80,"Logs/%s/Position%s.log",getName(playerid),getTimeInfo());
  1262. case 2: format(path,80,"Logs/%s%s.log",getName(playerid),getTimeInfo());
  1263. case 3: format(path,80,"Logs/Log%s.log",getTimeInfo());
  1264. case 4: format(path,80,"Logs/Position%s.log",getTimeInfo());
  1265. }
  1266. new
  1267. File:lFile = fopen(path, io_append),
  1268. logData[200];
  1269. format(logData, 200,"%s %s's Location X: %f | Y: %f | Z: %f\r\n",getDateAndTime(), getName(playerid), X,Y,Z);
  1270. fwrite(lFile, logData);
  1271. fclose(lFile);
  1272. return 1;
  1273. }
  1274.  
  1275. stock Log_Config(playerid)
  1276. {
  1277. new string[370];
  1278. new strlc[14][38];
  1279. switch(PositionLogging)
  1280. {
  1281. case 0:{strlc[0]="PositionLogging[]";}
  1282. case 1:{strlc[0]="PositionLogging[X]";}
  1283. }
  1284. switch(ChatLogging)
  1285. {
  1286. case 0:{strlc[1]="ChatLogging[]";}
  1287. case 1:{strlc[1]="ChatLogging[X]";}
  1288. }
  1289. switch(CommandLogging)
  1290. {
  1291. case 0:{strlc[2]="CommandLogging[]";}
  1292. case 1:{strlc[2]="CommandLogging[X]";}
  1293. }
  1294. switch(ShootingLogging)
  1295. {
  1296. case 0:{strlc[3]="ShootingLogging[]";}
  1297. case 1:{strlc[3]="ShootingLogging[X]";}
  1298. }
  1299. switch(DeathLogging)
  1300. {
  1301. case 0:{strlc[4]="DeathLogging[]";}
  1302. case 1:{strlc[4]="DeathLogging[X]";}
  1303. }
  1304. switch(ConnectLogging)
  1305. {
  1306. case 0:{strlc[5]="ConnectLogging[]";}
  1307. case 1:{strlc[5]="ConnectLogging[X]";}
  1308. }
  1309. switch(DisconnectLogging)
  1310. {
  1311. case 0:{strlc[6]="DisconnectLogging[]";}
  1312. case 1:{strlc[6]="DisconnectLogging[X]";}
  1313. }
  1314. switch(InteriorLogging)
  1315. {
  1316. case 0:{strlc[7]="InteriorLogging[]";}
  1317. case 1:{strlc[7]="InteriorLogging[X]";}
  1318. }
  1319. switch(RconLoginLogging)
  1320. {
  1321. case 0:{strlc[8]="RconLoginLogging[]";}
  1322. case 1:{strlc[8]="RconLoginLogging[X]";}
  1323. }
  1324. switch(CarEnterLogging)
  1325. {
  1326. case 0:{strlc[9]="CarEnterLogging[]";}
  1327. case 1:{strlc[9]="CarEnterLogging[X]";}
  1328. }
  1329. switch(CarExitLogging)
  1330. {
  1331. case 0:{strlc[10]="CarExitLogging[]";}
  1332. case 1:{strlc[10]="CarExitLogging[X]";}
  1333. }
  1334. switch(RconCommandLogging)
  1335. {
  1336. case 0:{strlc[11]="RconCommandLogging[]";}
  1337. case 1:{strlc[11]="RconCommandLogging[X]";}
  1338. }
  1339. switch(SaveMode)
  1340. {
  1341. case 1:{strlc[12]="SaveMode 1[X] 2[ ] 3[ ] 4[ ]";}
  1342. case 2:{strlc[12]="SaveMode 1[ ] 2[X] 3[ ] 4[ ]";}
  1343. case 3:{strlc[12]="SaveMode 1[ ] 2[ ] 3[X] 4[ ]";}
  1344. case 4:{strlc[12]="SaveMode 1[ ] 2[ ] 3[ ] 4[X]";}
  1345. }
  1346. switch(savetime)
  1347. {
  1348. case 0:{strlc[13]="Save logfiles per (Function disabled)";}
  1349. case 1:{strlc[13]="Save logfiles per hour";}
  1350. case 2:{strlc[13]="Save logfiles per day";}
  1351. case 3:{strlc[13]="Save logfiles per month";}
  1352. case 4:{strlc[13]="Save logfiles per year";}
  1353. }
  1354.  
  1355. format(string,370,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\nPositionLogInterval\n \nDisable All\nEnable All",strlc[0],strlc[1],strlc[2],strlc[3],strlc[4],strlc[5],strlc[6],strlc[7],strlc[8],strlc[9],strlc[10],strlc[11],strlc[12],strlc[13]);
  1356. ShowPlayerDialog(playerid,LOGCONFIG,DIALOG_STYLE_LIST,"Log Config",string,"Confirm","Back");
  1357. return 1;
  1358. }
  1359. stock Log_Clean(playerid)
  1360. {
  1361. if(SaveMode == 1)
  1362. {
  1363. ShowPlayerDialog(playerid,SAVEMODE1_CHOOSEPLAYER,DIALOG_STYLE_INPUT,"Log clean","Choose a player to delete his logfiles(You will choose the specific log afterwards)","Confirm","Back");
  1364. }
  1365. else if(SaveMode == 2)
  1366. {
  1367. ShowPlayerDialog(playerid,SAVEMODE2_CHOOSEPLAYER,DIALOG_STYLE_INPUT,"Log clean","Which players file should be cleaned?\n(The full playername, not the player id)","Confirm","Back");
  1368. }
  1369. else if(SaveMode == 3)
  1370. {
  1371. new msg[200];
  1372. format(msg,200,"Are you sure that you want to clean the log file? (Size: %i)",flength(fopen("Logs/Log.log")));
  1373. ShowPlayerDialog(playerid,SAVEMODE3_CLEAN,DIALOG_STYLE_MSGBOX,"Log clean",msg,"Confirm","Back");
  1374. }
  1375. else
  1376. {
  1377. getLogSizes(playerid);
  1378. }
  1379. return 1;
  1380. }
  1381. stock getLogSizes(playerid)
  1382. {
  1383. new alog[12][60],abig[1200];
  1384. format(alog[0],60,"PositionLog(Size:%i)",flength(fopen("Logs/Position.log")));
  1385. format(alog[1],60,"ChatLog(Size:%i)",flength(fopen("Logs/Chat.log")));
  1386. format(alog[2],60,"CommandLog(Size:%i)",flength(fopen("Logs/Command.log")));
  1387. format(alog[3],60,"ShootingLog(Size:%i)",flength(fopen("Logs/Shooting.log")));
  1388. format(alog[4],60,"DeathLog(Size:%i)",flength(fopen("Logs/Death.log")));
  1389. format(alog[5],60,"ConnectLog(Size:%i)",flength(fopen("Logs/Connect.log")));
  1390. format(alog[6],60,"DisconnectLog(Size:%i)",flength(fopen("Logs/Disconnect.log")));
  1391. format(alog[7],60,"InteriorLog(Size:%i)",flength(fopen("Logs/Interior.log")));
  1392. format(alog[8],60,"RconLoginLog(Size:%i)",flength(fopen("Logs/RconLogin.log")));
  1393. format(alog[9],60,"CarEnterLog(Size:%i)",flength(fopen("Logs/CarEnter.log")));
  1394. format(alog[10],60,"CarExitLog(Size:%i)",flength(fopen("Logs/CarExit.log")));
  1395. format(alog[11],60,"RconCommandLog(Size:%i)",flength(fopen("Logs/RconCommand.log")));
  1396. format(abig,1200,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",alog[0],alog[1],alog[2],alog[3],alog[4],alog[5],alog[6],alog[7],alog[8],alog[9],alog[10],alog[11]);
  1397. ShowPlayerDialog(playerid,SAVEMODE4_CHOOSE,DIALOG_STYLE_LIST,"Log clean",abig,"Confirm","Back");
  1398. return 1;
  1399. }
  1400. stock cleanLog(playerid,logid)
  1401. {
  1402. new logcl[125];
  1403. switch(logid)
  1404. {
  1405. case 0: {format(logcl,125,"Are you sure that you want to clean the Position Log file(Size:%i)",flength(fopen("Logs/Position.log"))); ShowPlayerDialog(playerid,S4_CLEAN_POSITION,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1406. case 1: {format(logcl,125,"Are you sure that you want to clean the Chat Log file(Size:%i)",flength(fopen("Logs/Chat.log"))); ShowPlayerDialog(playerid,S4_CLEAN_CHAT,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1407. case 2: {format(logcl,125,"Are you sure that you want to clean the Command Log file(Size:%i)",flength(fopen("Logs/Command.log"))); ShowPlayerDialog(playerid,S4_CLEAN_COMMAND,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1408. case 3: {format(logcl,125,"Are you sure that you want to clean the Shooting Log file(Size:%i)",flength(fopen("Logs/Shooting.log"))); ShowPlayerDialog(playerid,S4_CLEAN_SHOOTING,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1409. case 4: {format(logcl,125,"Are you sure that you want to clean the Death Log file(Size:%i)",flength(fopen("Logs/Death.log"))); ShowPlayerDialog(playerid,S4_CLEAN_DEATH,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1410. case 5: {format(logcl,125,"Are you sure that you want to clean the Connect Log file(Size:%i)",flength(fopen("Logs/Connect.log"))); ShowPlayerDialog(playerid,S4_CLEAN_CONNECT,DIALOG_STYLE_LIST,"Log clean",logcl[5],"Confirm","Back");}
  1411. case 6: {format(logcl,125,"Are you sure that you want to clean the Disconnect Log file(Size:%i)",flength(fopen("Logs/Disconnect.log"))); ShowPlayerDialog(playerid,S4_CLEAN_DISCONNECT,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1412. case 7: {format(logcl,125,"Are you sure that you want to clean the Interior Log file(Size:%i)",flength(fopen("Logs/Interior.log"))); ShowPlayerDialog(playerid,S4_CLEAN_INTERIOR,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1413. case 8: {format(logcl,125,"Are you sure that you want to clean the RconLogin Log file(Size:%i)",flength(fopen("Logs/RconLogin.log"))); ShowPlayerDialog(playerid,S4_CLEAN_RCONLOGIN,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1414. case 9: {format(logcl,125,"Are you sure that you want to clean the CarEnter Log file(Size:%i)",flength(fopen("Logs/CarEnter.log"))); ShowPlayerDialog(playerid,S4_CLEAN_CARENTER,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1415. case 10: {format(logcl,125,"Are you sure that you want to clean the CarExit Log file(Size:%i)",flength(fopen("Logs/CarExit.log"))); ShowPlayerDialog(playerid,S4_CLEAN_CAREXIT,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1416. case 11: {format(logcl,125,"Are you sure that you want to clean the RconCommand Log file(Size:%i)",flength(fopen("Logs/RconCommand.log"))); ShowPlayerDialog(playerid,S4_CLEAN_RCONCOMMAND,DIALOG_STYLE_LIST,"Log clean",logcl,"Confirm","Back");}
  1417. }
  1418. return 1;
  1419. }
  1420. //PUBLICS (non-default)
  1421. forward LogLoc(playerid);
  1422. public LogLoc(playerid)
  1423. {
  1424. new Float:X,Float:Y,Float:Z;
  1425. GetPlayerPos(playerid,X,Y,Z);
  1426. LogPlayerLocation(playerid,X,Y,Z);
  1427. return 1;
  1428. }
  1429. forward LogCar(playerid);
  1430. public LogCar(playerid)
  1431. {
  1432. InLog(playerid,GetPlayerVehicleSeat(playerid),GetPlayerVehicleID(playerid),GetVehicleModel(GetPlayerVehicleID(playerid)));
  1433. return 1;
  1434. }
  1435. forward MyHttpResponse(index, response_code, data[]);
  1436. public MyHttpResponse(index, response_code, data[])
  1437. {
  1438. if(!strcmp(data, VERSION, true))
  1439. {
  1440. print("[Logging System] The Logging filterscript needs an update.");
  1441. printf("[Logging System] Latest Version: %s", data);
  1442. printf("[Logging System] Your Version: %s", VERSION);
  1443. print("[Logging System] Downloadlink: https://dl.dropboxusercontent.com/u/89362253/Log.zip");
  1444. }
  1445. else
  1446. {
  1447. print("[Logging System] The Logging system is up to date.");
  1448. }
  1449. return 1;
  1450. }
  1451.  
  1452. //COMMANDS
  1453. CMD:logmenu(playerid,params[])
  1454. {
  1455. if(IsPlayerAdmin(playerid))
  1456. {
  1457. ShowPlayerDialog(playerid,LOGMENU,DIALOG_STYLE_LIST,"Logmenu","Configure logs\nClean logs","Confirm","Back");
  1458. }
  1459. return 1;
  1460. }
  1461.  
  1462. CMD:logenable(playerid,params[])
  1463. {
  1464. if(IsPlayerAdmin(playerid))
  1465. {
  1466. new log;
  1467. if(sscanf(params,"i",log)) return SendClientMessage(playerid,-1,"[Logging System] Usage: /logenable [log] \n1 = RconCommandLogging\n2 = ChatLogging\n3 = CommandLogging\n4 = ShootingLogging\n5 = PositionLogging\n6 = DeathLogging\n7 = ConnectLogging\n8 = DisconnectLogging\n9 = RconLoginLogging\n10 = InteriorLogging\n11 = CarEnterLogging\n12 = CarExitLogging");
  1468. switch(log)
  1469. {
  1470. case 1: {RconCommandLogging = 1; dini_IntSet(File,"RconCommandLogging",1); SendClientMessage(playerid,-1,"[Logging System] Rcon command logging diabled.");}
  1471. case 2: {ChatLogging = 1; dini_IntSet(File,"ChatLogging",1); SendClientMessage(playerid,-1,"[Logging System] Chat logging diabled.");}
  1472. case 3: {CommandLogging = 1; dini_IntSet(File,"CommandLogging",1); SendClientMessage(playerid,-1,"[Logging System] Command logging diabled.");}
  1473. case 4: {ShootingLogging = 1; dini_IntSet(File,"ShootingLogging",1); SendClientMessage(playerid,-1,"[Logging System] Shooting command logging diabled.");}
  1474. case 5: {PositionLogging = 1; dini_IntSet(File,"PositionLogging",1); SendClientMessage(playerid,-1,"[Logging System] Position command logging diabled.");}
  1475. case 6: {RconLoginLogging = 1; dini_IntSet(File,"RconLoginLogging",1); SendClientMessage(playerid,-1,"[Logging System] Rcon login logging diabled.");}
  1476. case 7: {DeathLogging = 1; dini_IntSet(File,"DeathLogging",1); SendClientMessage(playerid,-1,"[Logging System] Death logging diabled.");}
  1477. case 8: {ConnectLogging = 1; dini_IntSet(File,"ConnectLogging",1); SendClientMessage(playerid,-1,"[Logging System] Connect command logging diabled.");}
  1478. case 9: {DisconnectLogging = 1; dini_IntSet(File,"DisconnectLogging",1); SendClientMessage(playerid,-1,"[Logging System] Disconnect command logging diabled.");}
  1479. case 10: {InteriorLogging = 1; dini_IntSet(File,"InteriorLogging",1); SendClientMessage(playerid,-1,"[Logging System] Interior logging diabled.");}
  1480. case 11: {CarEnterLogging = 1; dini_IntSet(File,"CarEnterLogging",1); SendClientMessage(playerid,-1,"[Logging System] Car enter logging diabled.");}
  1481. case 12: {CarExitLogging = 1; dini_IntSet(File,"CarExitLogging",1); SendClientMessage(playerid,-1,"[Logging System] Car exit logging diabled.");}
  1482. default: {SendClientMessage(playerid, -1, "[Logging System] Your input was incorrect, try again.");}
  1483. }
  1484. }
  1485. return 1;
  1486. }
  1487. CMD:logdisable(playerid,params[])
  1488. {
  1489. if(IsPlayerAdmin(playerid))
  1490. {
  1491. new log;
  1492. if(sscanf(params,"i",log)) return SendClientMessage(playerid,-1,"[Logging System] Usage: /logdisable [log] \n1 = RconCommandLogging\n2 = ChatLogging\n3 = CommandLogging\n4 = ShootingLogging\n5 = PositionLogging\n6 = DeathLogging\n7 = ConnectLogging\n8 = DisconnectLogging\n9 = RconLoginLogging\n10 = InteriorLogging\n11 = CarEnterLogging\n12 = CarExitLogging");
  1493. switch(log)
  1494. {
  1495. case 1: {RconCommandLogging = 0; dini_IntSet(File,"RconCommandLogging",0); SendClientMessage(playerid,-1,"[Logging System] Rcon command logging diabled.");}
  1496. case 2: {ChatLogging = 0; dini_IntSet(File,"ChatLogging",0); SendClientMessage(playerid,-1,"[Logging System] Chat logging diabled.");}
  1497. case 3: {CommandLogging = 0; dini_IntSet(File,"CommandLogging",0); SendClientMessage(playerid,-1,"[Logging System] Command logging diabled.");}
  1498. case 4: {ShootingLogging = 0; dini_IntSet(File,"ShootingLogging",0); SendClientMessage(playerid,-1,"[Logging System] Shooting command logging diabled.");}
  1499. case 5: {PositionLogging = 0; dini_IntSet(File,"PositionLogging",0); SendClientMessage(playerid,-1,"[Logging System] Position command logging diabled.");}
  1500. case 6: {RconLoginLogging = 0; dini_IntSet(File,"RconLoginLogging",0); SendClientMessage(playerid,-1,"[Logging System] Rcon login logging diabled.");}
  1501. case 7: {DeathLogging = 0; dini_IntSet(File,"DeathLogging",0); SendClientMessage(playerid,-1,"[Logging System] Death logging diabled.");}
  1502. case 8: {ConnectLogging = 0; dini_IntSet(File,"ConnectLogging",0); SendClientMessage(playerid,-1,"[Logging System] Connect command logging diabled.");}
  1503. case 9: {DisconnectLogging = 0; dini_IntSet(File,"DisconnectLogging",0); SendClientMessage(playerid,-1,"[Logging System] Disconnect command logging diabled.");}
  1504. case 10: {InteriorLogging = 0; dini_IntSet(File,"InteriorLogging",0); SendClientMessage(playerid,-1,"[Logging System] Interior logging diabled.");}
  1505. case 11: {CarEnterLogging = 0; dini_IntSet(File,"CarEnterLogging",0); SendClientMessage(playerid,-1,"[Logging System] Car enter logging diabled.");}
  1506. case 12: {CarExitLogging = 0; dini_IntSet(File,"CarExitLogging",0); SendClientMessage(playerid,-1,"[Logging System] Car exit logging diabled.");}
  1507. default: {SendClientMessage(playerid, -1, "[Logging System] Your input was incorrect, try again.");}
  1508. }
  1509. }
  1510. return 1;
  1511. }
Advertisement
Add Comment
Please, Sign In to add comment