MuhammadZeeshan

warn and unwarn cmds

Dec 12th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. else if ( cmd == "!warn" )
  2. {
  3. if ( level < 3 ) EchoNotice1( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  4. else if ( !text ) EchoNotice1(user, ICOL_RED+ "Error - Syntax: /" + cmd + " <Nick/ID> <Reason> " );
  5. else
  6. {
  7. local plr =FindPlayer(GetTok( text, " ", 1 ));
  8. local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
  9. if(plr)
  10. {
  11. if(reason)
  12. {
  13. local q = QuerySQL( db, "SELECT * FROM Warning WHERE Name ='" + plr.Name + "'");
  14. if ( !GetSQLColumnData( q, 0 ) )
  15. {
  16. QuerySQL( db, "INSERT INTO Warning (Name, Totalwarns) values ( '" + plr.Name + "', 1 )" );
  17. Message( RED+"Admin "+user+" has warned "+plr.Name+". Reason: "+ reason +". Warns: "+RED+"[ 1/3 ]");
  18. EchoMessage1( ICOL_RED+"Admin "+user+" has warned "+plr.Name+". Reason: "+ reason +". Warns: [ 1/3 ]");
  19. }
  20. else
  21. {
  22. local warntotal = GetSQLColumnData(q, 1)+1;
  23. QuerySQL( db, "UPDATE Warning SET Totalwarns='" + warntotal + "' WHERE Name='" + plr.Name + "'")
  24. Message( RED+"Admin "+user+" has warned "+plr.Name+". Reason: "+ reason +". Warns: [ " + warntotal + "/" + "3 ]");
  25. EchoMessage1( ICOL_RED+"Admin "+user+" has warned "+plr.Name+". Reason: "+ reason +". Warns: [ " + warntotal + "/" + "3 ]");
  26.  
  27. if(GetSQLColumnData(q, 1)==2)
  28. {
  29. QuerySQL( db, "DELETE FROM Warning WHERE Name='" + plr.Name + "'")
  30. Message( RED+"Auto-Banned: " + plr.Name + ". Reason: Exceeded the number of warn limits.");
  31. EchoMessage1( ICOL_RED+"Auto-Banned: " + plr.Name + ". Reason: Exceeded the number of warn limits.");
  32. Ban( plr, "3d", "Exceeded the number of warn limits", "Server" );
  33. }
  34.  
  35. }
  36. FreeSQLQuery( q );
  37.  
  38. }
  39. else EchoNotice1(user, ICOL_RED+ "Syntax: " + cmd + " <Nick/ID> <Reason> " );
  40. }
  41. else EchoNotice1(user, ICOL_RED+ "Unknown player." );
  42. }
  43. }
  44.  
  45. else if ( cmd == "!unwarn" )
  46. {
  47. if ( level < 3 ) EchoNotice1( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
  48. else if ( !text ) EchoNotice1( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID>");
  49. else
  50. {
  51. local plr = FindPlayer(GetTok( text, " ", 1 ));
  52. if(plr)
  53. {
  54. local q = QuerySQL( db, "SELECT * FROM Warning WHERE Name ='" + plr.Name + "'");
  55. if ( !GetSQLColumnData( q, 0 ) ) EchoNotice1( user, ICOL_RED + "Error - " + plr.Name + " didn't get any warns.");
  56. else if ( GetSQLColumnData( q, 0 ) == "0" ) EchoNotice1( user, ICOL_RED + "Error - " + plr.Name + " didn't get any warns.");
  57. else
  58. {
  59. local warntotal = "0";
  60. QuerySQL( db, "UPDATE Warning SET Totalwarns='" + warntotal + "' WHERE Name='" + plr.Name + "'")
  61. Message( RED+"Admin "+user+" has unwarned "+plr.Name+".");
  62. EchoMessage1( ICOL_RED+"Admin "+user+" has unwarned "+plr.Name+".");
  63.  
  64. }
  65. FreeSQLQuery( q );
  66.  
  67.  
  68. }
  69. else EchoNotice1( user, ICOL_RED + "Error - Unknown Player");
  70. }
  71. }
Add Comment
Please, Sign In to add comment