DBLog.pwn 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #include <YSI\y_hooks>
  2. new DB:db_iHandle;
  3. hook OnGameModeInit() {
  4. db_iHandle = db_open("logs.db");
  5. return 1;
  6. }
  7. hook OnGameModeExit() {
  8. db_close(db_iHandle);
  9. }
  10. /*
  11. This can be used for:
  12. -Admin
  13. -Admin Aution
  14. -Admin Give
  15. -Admin Pay
  16. -Auction
  17. -Ban
  18. -Backpack
  19. -Business Edit
  20. -Business
  21. -CLEO
  22. -Contracts
  23. -Credits
  24. -Crime
  25. -Dynamic Door Edit
  26. -Dealership
  27. -Dynamic Map Icon Edit
  28. -Dynamic Vehicle
  29. -Dynamic Vehicle Spawn
  30. -Edit Group
  31. -Faction
  32. -Flag Move
  33. -Flags
  34. -Garage Edit
  35. -Gate Edit
  36. -Gifts
  37. -Government
  38. -Group
  39. -Hack
  40. -House Edit
  41. -House Safe
  42. -Kick
  43. -Licenses
  44. -Login Credits
  45. -Mail
  46. -Micro
  47. -Moderator
  48. -Mute
  49. -Priority Ad
  50. -Password
  51. -Pay
  52. -Plant
  53. -Player Vehicle
  54. -Pay N' Spray
  55. -Poker
  56. -Rapid Fire
  57. -RP Special
  58. -Sell Credits
  59. -Set VIP
  60. -Shpo Confirmed Orders
  61. -Shop
  62. -Shop Orders
  63. -s0biet
  64. -Speedcam
  65. -Stats
  66. -Text Label Edit
  67. -Toys
  68. -Toy Edit
  69. -Toy Delete
  70. -Undercover
  71. -VIP Name-changes
  72. -VIP Remove
  73. -Voucher
  74. */
  75. //DBLog(iPlayerID, iTargetID = INVALID_PLAYER_ID, szLogTable[], szLogText[]) {
  76. DBLog(iPlayerID, iTargetID = INVALID_PLAYER_ID, szLogTable[], szLogText[]) {
  77. format(szMiscArray, sizeof(szMiscArray), "INSERT INTO `%s` (`Timestamp`,`PlayerID`,`TargetID`,`LogText`,`PlayerIP`,`TargetIP`) VALUES ('%d','%d','%d','%s','%s','%s')", szLogTable, gettime(), PlayerInfo[iPlayerID][pId], PlayerInfo[iTargetID][pId], szLogText, PlayerInfo[iPlayerID][pIP], PlayerInfo[iTargetID][pIP]);
  78. db_free_result(db_query(db_iHandle, szMiscArray));
  79. printf("%s",szMiscArray);
  80. return 1;
  81. }
  82. ChatDBLog(iPlayerID, szLogTable[], szLogText[]) {
  83. format(szMiscArray, sizeof(szMiscArray), "INSERT INTO `%s` (`Timestamp`,`PlayerID`,`LogText`,`PlayerIP`) VALUES ('%d','%d','%s','%s')", szLogTable, gettime(), PlayerInfo[iPlayerID][pId], szLogText, PlayerInfo[iPlayerID][pIP]);
  84. db_free_result(db_query(db_iHandle, szMiscArray));
  85. printf("%s",szMiscArray);
  86. return 1;
  87. }
  88. CasinoDBLog(iPlayerID, game[], amount, prize, num1, num2, num3) {
  89. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "INSERT INTO `cp_casino_log` (`Timestamp`, `PlayerID`, `game`, `amount`,`prize`,`num1`,`num2`,`num3`,`PlayerIP`) VALUES ('%d','%d','%s','%d','%d','%d','%d','%d','%s')", gettime(), PlayerInfo[iPlayerID][pId], game, amount, prize, num1, num2, num3, PlayerInfo[iPlayerID][pIP]);
  90. mysql_tquery(MainPipeline, szMiscArray, "OnQueryFinish", "i", SENDDATA_THREAD);
  91. //db_free_result(db_query(db_iHandle, szMiscArray));
  92. printf("%s",szMiscArray);
  93. return 1;
  94. }
  95. /*
  96. PropertyDBLog(iPlayerID, iTargetID = INVALID_PLAYER_ID, PropertyID, szLogTable[], szLogText[]) {
  97. format(szMiscArray, sizeof(szMiscArray), "INSERT INTO `%s` (`Timestamp`,`PlayerID`,`PropertyID`,`LogText`,`PlayerIP`) VALUES ('%d','%d','%d','%s','%s')", szLogTable, gettime(), PlayerInfo[iPlayerID][pId], PropertyID, szLogText, PlayerInfo[iPlayerID][pIP]);
  98. db_free_result(db_query(db_iHandle, szMiscArray));
  99. printf("%s",szMiscArray);
  100. return 1;
  101. }
  102. */
  103. /*
  104. Function: GroupDBLog
  105. Parameters:
  106. -iPlayerID - The player who's executing the item to be logged.
  107. -iTargetID - The player who's affected by the item being executed.
  108. -iGroupID - The GroupID that will be affected (please note this can be a group, business, etc - use table specf.)
  109. -szLogTable - The name of the table you wish to log to (this is case sensitive).
  110. -szLogText - The text you wish to log.
  111. */
  112. /*
  113. GroupDBLog(iPlayerID, iGroupID, szLogText) {
  114. format(szMiscArray, sizeof(szMiscArray), "INSERT INTO `cp_log_group` (`Timestamp`,`GroupID`,`PlayerID`,`LogText`,`PlayerIP`) VALUES ('%d','%d','%d','%s','%s')", gettime(), iGroupID, PlayerInfo[iPlayerID][pId], szLogText, PlayerInfo[iPlayerID][pIP]);
  115. db_free_result(db_query(db_iHandle, szMiscArray));
  116. printf("%s",szMiscArray);
  117. return 1;
  118. }
  119. */
  120. /*
  121. Function: ConectionDBLog
  122. Parameters:
  123. -iPlayerID - The player who's connection you wish to log.
  124. */
  125. ConnectionDBLog(iPlayerID) {
  126. format(szMiscArray, sizeof(szMiscArray), "INSERT INTO `Connections` (`Timestamp`,`PlayerID`,`PlayerIP`) VALUES ('%d', '%d', '%s')", gettime(), PlayerInfo[iPlayerID][pId], PlayerInfo[iPlayerID][pIP]);
  127. db_free_result(db_query(db_iHandle, szMiscArray));
  128. return 1;
  129. }