Advertisement
DecaK

Untitled

Feb 4th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. new Motd[2][101][50];
  5. new folder[101], file[101];
  6.  
  7. public plugin_init() {
  8. register_plugin("Motd Manager", "3.0", "DecaK")
  9. register_clcmd("say", "say_hook")
  10. register_clcmd("say_team", "say_hook")
  11. ucitajpodatke();
  12. }
  13.  
  14. public plugin_precache() {
  15. new config[101];
  16. get_configsdir(config, charsmax(config))
  17. formatex(folder, charsmax(folder), "%s/motds/", config)
  18. formatex(file, charsmax(file), "%s/advertisements-motd.ini", config)
  19. formatex(config, charsmax(config), "%s/motds/default.txt", config)
  20. if(!dir_exists(folder))
  21. mkdir(folder)
  22. if(!file_exists(file)) {
  23. write_file(file, ";You can type a command and motd in this file")
  24. write_file(file, "^"/hosting^" ^"hosting.txt^"")
  25. }
  26. if(!file_exists(config))
  27. write_file(config, "GOLD Hosting Plug-in made by DecaK")
  28. }
  29.  
  30. public say_hook(id) {
  31. new sayed[192];
  32. read_args(sayed, charsmax(sayed));
  33. for(new i=0;i<sizeof Motd[];i++) {
  34. if(containi(sayed, Motd[0][i]) != -1) {
  35. new motd[150];
  36. formatex(motd, charsmax(motd), "%s%s", folder, Motd[1][i])
  37. show_motd(id, motd)
  38. return PLUGIN_HANDLED;
  39. }
  40. }
  41. return PLUGIN_CONTINUE;
  42. }
  43.  
  44. ucitajpodatke() {
  45. new line[101];
  46. formatex(line, charsmax(line), file)
  47. new f = fopen(line, "rt");
  48. if(!f) {
  49. write_file(line, "")
  50. return PLUGIN_HANDLED;
  51. }
  52. new i = 0;
  53. while(!feof(f)) {
  54. fgets(f, line, charsmax(line))
  55. if(line[0] == ';') continue;
  56. new motd[50], lokacija[50];
  57. parse(line, motd, charsmax(motd), lokacija, charsmax(lokacija))
  58. formatex(Motd[0][i], sizeof Motd[][], motd)
  59. formatex(Motd[1][i], sizeof Motd[][], lokacija)
  60. i++
  61. }
  62. fclose(f);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement