CrazyChoco

HELP D:

Aug 4th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. #include <a_samp>
  2. #include <a_sampdb>
  3. #include <upa>
  4. #define FILTERSCRIPT
  5. #include <zcmd>
  6.  
  7. //COLOR
  8. #define PINK 0xFF22EE00
  9.  
  10. new
  11. DB: dbBans;
  12.  
  13. forward tempBanPlayer(playerid, iTime, szBannedBy[], szReason[], szIP[]);
  14.  
  15. public OnFilterScriptInit() {
  16. dbBans = db_open("tempban.db");
  17. return 1;
  18. }
  19.  
  20. public OnFilterScriptExit() {
  21. db_close(dbBans);
  22. return 1;
  23. }
  24.  
  25. public OnPlayerConnect(playerid) {
  26. new
  27. szPlayerName[MAX_PLAYER_NAME],
  28. szQuery[93],
  29. szIP[19];
  30.  
  31. GetPlayerIp(playerid, szIP, sizeof(szIP));
  32. GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
  33.  
  34. format(szQuery, sizeof(szQuery), "SELECT banlength FROM bans WHERE ip = '%s' OR name = '%s'", szIP, DB_Escape(szPlayerName));
  35.  
  36. new
  37. DBResult: qHandle = db_query(dbBans, szQuery);
  38.  
  39. if(db_num_rows(qHandle) > 0) {
  40. new
  41. szDump[32],
  42. iDump,
  43. szMessage[64];
  44.  
  45. db_get_field_assoc(qHandle, "banlength", szDump, sizeof(szDump));
  46. iDump = strval(szDump);
  47.  
  48. if(iDump-gettime() < 0) {
  49. format(szMessage, sizeof(szMessage), "{FF00C3}You ban has expired!!!!!!!!!!!!!!!!!");
  50. SendClientMessage(playerid, PINK, szMessage);
  51.  
  52. format(szQuery, sizeof(szQuery), "DELETE FROM bans WHERE name = '%s'", DB_Escape(szPlayerName));
  53. db_free_result(db_query(dbBans, szQuery));
  54. } else {
  55. format(szMessage, sizeof(szMessage), "{FF00C3}In Order to be unbanned, you must wait %d seconds.", iDump-gettime());
  56. format(szMessage, sizeof(szMessage), "{FF0000}Days Left:%d", iDump-gettime()); // FUCKED D: - Same func for each.. Ofc it's not going to work
  57. format(szMessage, sizeof(szMessage), "{FF0000}Weeks Left:%d", iDump-gettime()); // FUCKED D: - i know Was reading aobut somethink like this
  58. SendClientMessage(playerid, PINK, "{14DBF5}You have been temp banned from Metropolis Roleplay.");
  59. SendClientMessage(playerid, PINK, szMessage);
  60. Kick(playerid);
  61. }
  62. }
  63. db_free_result(qHandle);
  64. return 1;
  65. }
  66.  
  67. public tempBanPlayer(playerid, iTime, szBannedBy[], szReason[], szIP[])
  68. {
  69. new
  70. szPlayerNameBanned[MAX_PLAYER_NAME],
  71. szQuery[270];
  72.  
  73. GetPlayerName(playerid, szPlayerNameBanned, MAX_PLAYER_NAME);
  74.  
  75. format(szQuery, sizeof(szQuery), "INSERT INTO bans (name, ip, reason, banlength, bannedby) VALUES('%s', '%s', '%s', %d, '%s')", DB_Escape(szPlayerNameBanned), DB_Escape(szIP), DB_Escape(szReason), iTime, DB_Escape(szBannedBy));
  76. db_free_result(db_query(dbBans, szQuery));
  77. Kick(playerid);
  78. return 1;
  79. }
  80.  
  81. CMD:temp(playerid, params[]) {
  82. new
  83. iDays,
  84. iFinalCalculation,
  85. iHours,
  86. iWeeks,
  87. szReason[32],
  88. iMinutes,
  89. szIP[19],
  90. szPlayerName[MAX_PLAYER_NAME],
  91. iTarget;
  92.  
  93. if(!IsPlayerAdmin(playerid) && GetPVarInt(playerid, "Admin") <= 0)
  94. return SendClientMessage(playerid, PINK, "ERROR: You must login to provide this command, else there is probberly a bug D:");
  95.  
  96. if(sscanf(params, "uddds", iTarget, iWeeks, iDays, iHours, iMinutes, szReason))
  97. return SendClientMessage(playerid, PINK, "{FF0000}Warning: {FFFFFF}/temp (Playerid) (weeks) (days (min) (REason)");
  98.  
  99. iFinalCalculation = gettime() + mktime(iHours, iMinutes, 0, iDays);
  100.  
  101. if(gettime() == iFinalCalculation)
  102. return SendClientMessage(playerid, PINK, "ERROR: YOu have not set an correct unban time");
  103.  
  104. GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
  105. GetPlayerIp(iTarget, szIP, sizeof(szIP));
  106.  
  107. tempBanPlayer(iTarget, iFinalCalculation, szPlayerName, szReason, szIP);
  108.  
  109. return 1;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment