Advertisement
xTurbox

T-RCON by Turbo

Jan 28th, 2016
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.97 KB | None | 0 0
  1. /*==============================================
  2.         INCLUDES
  3. ================================================*/
  4. #include <a_samp>
  5. #include <zcmd>
  6. /*==============================================
  7.         OPTIONS(and other defines)
  8. ================================================*/
  9. #define trcpass "changeme"
  10.  
  11. #define USE_03zR2_Above     true //change to false if your server version is below 0.3z-R2
  12.  
  13. #define DIALOG_TRCON_LOGIN  874
  14. #define DIALOG_TRCON        542
  15. #define DIALOG_INPUT        643
  16. /*==============================================
  17.         GLOBAL VARIABLES
  18. ================================================*/
  19. new bool:TrcAdmin[MAX_PLAYERS];
  20. new inputdialog[MAX_PLAYERS];
  21.  
  22. #define Tversion "(v1.0)"
  23. /*==============================================
  24.         CALLBACKS
  25. ================================================*/
  26. public OnFilterScriptInit()
  27. {
  28.     print("==========================================");
  29.     printf("          T-RCON %s",Tversion);
  30.     print("     (Easy RCON system)");
  31.     print("          by Turbo");
  32.     print("     Succesfully loaded");
  33.     print("======================================");
  34.     return 1;
  35. }
  36. public OnFilterScriptExit()
  37. {
  38.     print("====================================");
  39.     printf("          T-RCON %s",Tversion);
  40.     print("     (Easy RCON system)");
  41.     print("          by Turbo");
  42.     print("     Succesfully un-loaded");
  43.     print("=====================================");
  44.     return 1;
  45. }
  46. public OnPlayerConnect(playerid)
  47. {
  48.     ResetVariables(playerid);
  49.     return 1;
  50. }
  51. public OnPlayerDisconnect(playerid, reason)
  52. {
  53.     ResetVariables(playerid);
  54.     return 1;
  55. }
  56. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  57. {
  58.     if(dialogid == DIALOG_TRCON_LOGIN)
  59.     {
  60.         if(!response) return 1;
  61.         if(!strcmp(inputtext, trcpass))
  62.         {
  63.             TrcAdmin[playerid] = true;
  64.             SendClientMessage(playerid, -1, "Login success! :D");
  65.         }
  66.         else
  67.         {
  68.             SendClientMessage(playerid, -1, "invaild pass :P");
  69.         }
  70.         return 1;
  71.     }
  72.     if(dialogid == DIALOG_TRCON)
  73.     {
  74.         if(!response) return 1;
  75.         switch(listitem)
  76.         {
  77.             case 0: SendRconCommand("gmx");
  78.             case 1: SendRconCommand("reloadbans");
  79.             case 2: SendRconCommand("exit");
  80.             case 3:
  81.             {
  82.                 inputdialog[playerid] = 1;
  83.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the new hostname", "change", "cancel");
  84.                 return 1;
  85.             }
  86.             case 4:
  87.             {
  88.                 inputdialog[playerid] = 2;
  89.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the text to say(as admin)", "Say", "cancel");
  90.                 return 1;
  91.             }
  92.             case 5:
  93.             {
  94.                 inputdialog[playerid] = 3;
  95.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the desired password\nNOTE: type '0' if you want to remove the server password", "Confirm", "cancel");
  96.                 return 1;
  97.             }
  98.             case 6:
  99.             {
  100.                 inputdialog[playerid] = 4;
  101.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the new GameMode Text\nDisplayed in client under the GameMode", "Change", "cancel");
  102.                 return 1;
  103.             }
  104.             case 7:
  105.             {
  106.                 inputdialog[playerid] = 5;
  107.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the Weather ID", "Change", "cancel");
  108.                 return 1;
  109.             }
  110.             case 8:
  111.             {
  112.                 inputdialog[playerid] = 6;
  113.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the Gravity\n deafult Gravity = 0.008 ", "Change", "cancel");
  114.                 return 1;
  115.             }
  116.             case 9:
  117.             {
  118.                 inputdialog[playerid] = 7;
  119.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the new rcon password ", "Change", "cancel");
  120.                 return 1;
  121.             }
  122.             case 10:
  123.             {
  124.                 inputdialog[playerid] = 8;
  125.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the new Web Url", "Change", "cancel");
  126.                 return 1;
  127.             }
  128.             case 11:
  129.             {
  130.                 inputdialog[playerid] = 17;
  131.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the new Map Name", "Change", "cancel");
  132.                 return 1;
  133.             }
  134.             case 12:
  135.             {
  136.                 inputdialog[playerid] = 9;
  137.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the name of the fs(filterscript) to load", "Load", "cancel");
  138.                 return 1;
  139.             }
  140.             case 13:
  141.             {
  142.                 inputdialog[playerid] = 10;
  143.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the name of the filterscript to un-load", "un-load", "cancel");
  144.                 return 1;
  145.             }
  146.             case 14:
  147.             {
  148.                 inputdialog[playerid] = 11;
  149.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input name of the filterscript to reload", "reload", "cancel");
  150.                 return 1;
  151.             }
  152.             case 15: SendRconCommand("reloadlogs");
  153.             case 16:
  154.             {
  155.                 inputdialog[playerid] = 12;
  156.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the ID(of the player) to Kick", "Kick", "cancel");
  157.                 return 1;
  158.             }
  159.             case 17:
  160.             {
  161.                 inputdialog[playerid] = 13;
  162.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the ID(of the player) to Ban", "Ban", "cancel");
  163.                 return 1;
  164.             }
  165.             case 18:
  166.             {
  167.                 inputdialog[playerid] = 14;
  168.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the ip to Ban", "Ban", "cancel");
  169.                 return 1;
  170.             }
  171.             case 19:
  172.             {
  173.                 inputdialog[playerid] = 15;
  174.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the ip to Un-Ban", "UnBan", "cancel");
  175.                 return 1;
  176.             }
  177.             case 20:
  178.             {
  179.                 inputdialog[playerid] = 16;
  180.                 ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT,"T-RCON","Input the new Language(shown in the client)", "change", "cancel");
  181.                 return 1;
  182.             }
  183.         }
  184.         return 1;
  185.     }
  186.     if(dialogid == DIALOG_INPUT)
  187.     {
  188.         new string[128];
  189.         if(!response) return 1;
  190.         switch(inputdialog[playerid])
  191.         {
  192.             case 1:
  193.             {
  194.                 format(string, sizeof(string),"hostname %s",inputtext);
  195.                 SendRconCommand(string);
  196.  
  197.             }
  198.             case 2:
  199.             {
  200.                 format(string, sizeof(string),"say %s",inputtext);
  201.                 SendRconCommand(string);
  202.             }
  203.             case 3:
  204.             {
  205.                 format(string, sizeof(string),"password %s",inputtext);
  206.                 SendRconCommand(string);
  207.             }
  208.             case 4:
  209.             {
  210.                 format(string, sizeof(string),"gamemodetext %s",inputtext);
  211.                 SendRconCommand(string);
  212.             }
  213.             case 5:
  214.             {
  215.                 format(string, sizeof(string),"weather %s",inputtext);
  216.                 SendRconCommand(string);
  217.             }
  218.             case 6:
  219.             {
  220.                 format(string, sizeof(string),"gravity %s",inputtext);
  221.                 SendRconCommand(string);
  222.             }
  223.             case 7:
  224.             {
  225.                 format(string, sizeof(string),"rcon_password %s",inputtext);
  226.                 SendRconCommand(string);
  227.             }
  228.             case 8:
  229.             {
  230.                 format(string, sizeof(string),"weburl %s",inputtext);
  231.                 SendRconCommand(string);
  232.             }
  233.             case 9:
  234.             {
  235.                 format(string, sizeof(string),"loadfs %s",inputtext);
  236.                 SendRconCommand(string);
  237.             }
  238.             case 10:
  239.             {
  240.                 format(string, sizeof(string),"unloadfs %s",inputtext);
  241.                 SendRconCommand(string);
  242.             }
  243.             case 11:
  244.             {
  245.                 format(string, sizeof(string),"reloadfs %s",inputtext);
  246.                 SendRconCommand(string);
  247.             }
  248.             case 12:
  249.             {
  250.                 format(string, sizeof(string),"kick %s",inputtext);
  251.                 SendRconCommand(string);
  252.             }
  253.             case 13:
  254.             {
  255.                 format(string, sizeof(string),"ban %s",inputtext);
  256.                 SendRconCommand(string);
  257.             }
  258.             case 14:
  259.             {
  260.                 format(string, sizeof(string),"banip %s",inputtext);
  261.                 SendRconCommand(string);
  262.             }
  263.             case 15:
  264.             {
  265.                 format(string, sizeof(string),"unbanip %s",inputtext);
  266.                 SendRconCommand(string);
  267.             }
  268.             case 16:
  269.             {
  270.                 format(string, sizeof(string),"language %s",inputtext);
  271.                 SendRconCommand(string);
  272.             }
  273.             case 17:
  274.             {
  275.                 format(string, sizeof(string),"mapname %s",inputtext);
  276.                 SendRconCommand(string);
  277.             }
  278.         }
  279.         return 1;
  280.     }
  281.     return 0;
  282. }
  283.  
  284. /*==============================================
  285.         COMMANDS
  286. ================================================*/
  287. CMD:trcon(playerid,params[])
  288. {
  289.     new finalstring[300];
  290.     if(TrcAdmin[playerid] == false) return 0;
  291.     strcat(finalstring,"GMX(restart server)\nReload Bans\nShut Down(server)\nHostName(change hostname)\nSay(talk as admin)\nPassword(change/make/remove server password)\nGameMode Text\nWeather\nGravity\nRCON password(NOT T-RCON)\nWeb Url");
  292.     strcat(finalstring, "\nMap Name\nLoadfs\nUnloadfs\nReloadfs\nReload Log\nKick\nBan\nBan Ip\nUn-ban ip");
  293.     #if USE_03zR2_Above == true
  294.     strcat(finalstring,"\nLanguage");//more to be added in the next version
  295.     #endif
  296.     ShowPlayerDialog(playerid,DIALOG_TRCON, DIALOG_STYLE_LIST, "T-RCON",finalstring, "Select", "Close");
  297.     return 1;
  298. }
  299. CMD:trclogin(playerid,params[])
  300. {
  301.     if(TrcAdmin[playerid] == true) return SendClientMessage(playerid, -1, "{00FF00}ERROR: {FFFF00}You are already a logged in. You can use /trcon");
  302.     ShowPlayerDialog(playerid,DIALOG_TRCON_LOGIN,DIALOG_STYLE_PASSWORD ,"T-RCON Login", "Please enter the T-RCON password\nto use T-RCON","Confirm", "Exit");
  303.     return 1;
  304. }
  305.  
  306.  
  307. /*==============================================
  308.         FUNCTIONS
  309. ================================================*/
  310. stock ResetVariables(playerid)
  311. {
  312.     TrcAdmin[playerid] = false;
  313.     inputdialog[playerid] = 0;
  314. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement