MuhammadZeeshan

ban & warn cmds

Dec 11th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. else if ( cmd == "ban")
  2. {
  3. if ( status[ player.ID ].Registered == false ) ErrorMessage( "[#FFFFFF]You need to be a part of our community to use this command.", player );
  4. else if ( status[ player.ID ].Logged == false ) ErrorMessage( "[#FFFFFF]You need to be identified to use this command.", player );
  5. else if ( GetLevel( player ) < 5 ) MessagePlayer("[Error] You don't have access to use this Command.", player );
  6. else if ( !text ) ErrorMessage( "Syntax: /" + cmd + " <playername> <h/d/m> <Reason>", player );
  7. else if ( IsNoob( player, cmd ) ) return 0;
  8. else
  9. {
  10. local args = split( text, " " );
  11. local plr = GetPlayer(args[0]), duration = args[1], reason = GetTok( text, " ", 3, NumTok( text, " " ) );
  12. if ( !plr ) ErrorMessage( "Invalid player", player );
  13. else if (!duration) ErrorMessage( "Syntax: /" + cmd + " <playername> <h/d/m> <Reason> ", player );
  14. else if(!reason) ErrorMessage( "Syntax: /" + cmd + " <playername> <h/d/m> <Reason> ", player );
  15. else
  16. {
  17. Ban( plr, duration, reason, player );
  18. }
  19. }
  20. }
  21.  
  22. else if ( cmd == "warn" )
  23. {
  24. if( GetLevel( player ) < 5 ) MessagePlayer("[Error] You don't have access to use this Command.", player );
  25. else if ( !text ) ErrorMessage( "Error - Syntax: /" + cmd + " <Nick/ID> <Reason> ", player );
  26. else if ( IsNoob( player, cmd ) ) return 0;
  27. else
  28. {
  29. local plr =FindPlayer(GetTok( text, " ", 1 ));
  30. local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
  31. if(plr)
  32. {
  33. if(reason)
  34. {
  35. local q = QuerySQL( db, "SELECT * FROM Warning WHERE Name ='" + plr.Name + "'");
  36. if ( !GetSQLColumnData( q, 0 ) )
  37. {
  38. QuerySQL( db, "INSERT INTO Warning (Name, Totalwarns) values ( '" + plr.Name + "', 1 )" );
  39. ServerMessage( WHITE+"Admin "+RED+""+player.Name+" "+WHITE+"has warned "+RED+""+plr.Name+". "+WHITE+"Reason: "+RED+""+ reason +". "+WHITE+"Warns: "+RED+"[ 1/3 ]");
  40. }
  41. else
  42. {
  43. local warntotal = GetSQLColumnData(q, 1)+1;
  44. QuerySQL( db, "UPDATE Warning SET Totalwarns='" + warntotal + "' WHERE Name='" + plr.Name + "'")
  45. ServerMessage( WHITE+"Admin "+RED+""+player.Name+" "+WHITE+"has warned "+RED+""+plr.Name+". "+WHITE+"Reason: "+RED+""+ reason +". "+WHITE+"Warns: "+RED+"[ " + warntotal + "/" + "3 ]");
  46.  
  47. if(GetSQLColumnData(q, 1)==2)
  48. {
  49. QuerySQL( db, "DELETE FROM Warning WHERE Name='" + plr.Name + "'")
  50. ServerMessage( WHITE+"Auto-Banned: "+RED+"" + plr.Name + ". "+WHITE+"Reason: "+RED+"Exceeded the number of warn limits.");
  51. Ban( plr, "3d", "Exceeded the number of warn limits", "Auto" );
  52. }
  53.  
  54. }
  55. FreeSQLQuery( q );
  56.  
  57. }
  58. else ErrorMessage( "Syntax: " + cmd + " <Nick/ID> <Reason> ", player );
  59. }
  60. else ErrorMessage( "Unknown player.", player );
  61. }
  62. }
Add Comment
Please, Sign In to add comment