Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <csgo_colors>
  3.  
  4. StringMap Stweap;
  5. KeyValues kfg;
  6. bool us;
  7. Handle tim;
  8.  
  9. public Plugin myinfo =
  10. {
  11. name = "Реклама",
  12. author = "Pheonix (˙·٠●Феникс●٠·˙)",
  13. version = "1.2",
  14. url = "http://zizt.ru/"
  15. };
  16.  
  17. enum Rtupe
  18. {
  19. V = 0,
  20. C,
  21. H,
  22. S
  23. }
  24.  
  25. public void OnPluginStart()
  26. {
  27. if(GetEngineVersion() != Engine_CSGO) SetFailState("[Реклама] - плагин только для сервера CSGO");
  28. KFG_load();
  29. RegAdminCmd("sm_reklama_reload", Reload_cfg, ADMFLAG_ROOT);
  30. }
  31.  
  32. public Action Reload_cfg(int iClient, int args)
  33. {
  34. KFG_load();
  35. return Plugin_Handled;
  36. }
  37.  
  38. void KFG_load()
  39. {
  40. if(kfg) delete kfg;
  41. if(Stweap) delete Stweap;
  42. if(tim) delete tim;
  43. kfg = new KeyValues("Реклама");
  44. static char path[128], h[1024], buf[64];
  45. if(!path[0]) BuildPath(Path_SM, path, 128, "configs/reklama.ini");
  46. if(!kfg.ImportFromFile(path)) SetFailState("[Реклама] - Файл конфигураций не найден");
  47. else
  48. {
  49. kfg.Rewind();
  50. tim = CreateTimer(kfg.GetFloat("time"), rec, _, TIMER_REPEAT);
  51. kfg.JumpToKey("map");
  52. kfg.GotoFirstSubKey(false);
  53. Stweap = new StringMap();
  54. do
  55. {
  56. kfg.GetSectionName(h, 1024);
  57. kfg.GetString("", buf, 64);
  58. Stweap.SetString(h, buf);
  59. }
  60. while (kfg.GotoNextKey(false));
  61. kfg.Rewind();
  62. kfg.JumpToKey("text");
  63. kfg.GotoFirstSubKey();
  64. do
  65. {
  66. if(kfg.GetSectionName(h, 1024))
  67. {
  68. kfg.GetString("V", h, 1024);
  69. if(h[0])
  70. {
  71. Replese_constant(h, V);
  72. kfg.SetString("V", h);
  73. }
  74. kfg.GetString("C", h, 1024);
  75. if(h[0])
  76. {
  77. Replese_constant(h, C);
  78. kfg.SetString("C", h);
  79. }
  80. kfg.GetString("H", h, 1024);
  81. if(h[0])
  82. {
  83. Replese_constant(h, H);
  84. kfg.SetString("H", h);
  85. }
  86. kfg.GetString("S", h, 1024);
  87. if(h[0])
  88. {
  89. Replese_constant(h, S);
  90. kfg.SetString("S", h);
  91. }
  92. }
  93. }
  94. while kfg.GotoNextKey();
  95. us = false;
  96. }
  97. }
  98.  
  99. public Action rec(Handle timer)
  100. {
  101. kvup();
  102. static char rkl[1024];
  103. rkl[0]='\0';
  104. kfg.GetString("V", rkl, 1024);
  105. if(rkl[0])
  106. {
  107. Replese_st(rkl);
  108. VotePrintAll(rkl);
  109. }
  110. rkl[0]='\0';
  111. kfg.GetString("C", rkl, 1024);
  112. if(rkl[0])
  113. {
  114. Replese_st(rkl);
  115. PrintCenterTextAll(rkl);
  116. }
  117. rkl[0]='\0';
  118. kfg.GetString("H", rkl, 1024);
  119. if(rkl[0])
  120. {
  121. Replese_st(rkl);
  122. PrintHintTextToAll(rkl);
  123. }
  124. rkl[0]='\0';
  125. kfg.GetString("S", rkl, 1024);
  126. if(rkl[0])
  127. {
  128. Replese_st(rkl);
  129. CGOPrintToChatAll(rkl);
  130. }
  131. return Plugin_Continue;
  132. }
  133.  
  134. void Replese_st(char[] rkl)
  135. {
  136. static char sText[64];
  137. if(StrContains(rkl, "{PL}") != -1)
  138. {
  139. IntToString(GetClientCount(), sText, 64);//PL
  140. ReplaceString(rkl, 1024, "{PL}", sText);
  141. }
  142. if(StrContains(rkl, "{MAP}") != -1)
  143. {
  144. GetCurrentMap(sText, 64);//MAP
  145. Stweap.GetString(sText, sText, 64);
  146. ReplaceString(rkl, 1024, "{MAP}", sText);
  147. }
  148. if(StrContains(rkl, "{TIME}") != -1)
  149. {
  150. FormatTime(sText, 64, "%H:%M:%S");//TIME
  151. ReplaceString(rkl, 1024, "{TIME}", sText);
  152. }
  153. if (StrContains(rkl, "{TIMELEFT}") != -1)
  154. {
  155. int timeleft;
  156. if (GetMapTimeLeft(timeleft) && timeleft > 0)
  157. {
  158. Format(sText, 64, "%d:%02d", timeleft / 60, timeleft % 60);
  159. ReplaceString(rkl, 1024, "{TIMELEFT}", sText);
  160. }
  161. else ReplaceString(rkl, 1024, "{TIMELEFT}", "0");
  162. }
  163. if(StrContains(rkl, "{DATE}") != -1)
  164. {
  165. FormatTime(sText, 64, "%d/%m/%Y");
  166. ReplaceString(rkl, 1024, "{DATE}", sText);
  167. }
  168. }
  169.  
  170. void Replese_constant(char[] rkl, Rtupe tupe)
  171. {
  172. ReplaceString(rkl, 1024, "\\n", "\n");
  173. static char sText[3][64];
  174. if(!sText[0][0])
  175. {
  176. int ip = FindConVar("hostip").IntValue;
  177. FormatEx(sText[0], 64, "%d.%d.%d.%d", ip >>> 24 & 255, ip >>> 16 & 255, ip >>> 8 & 255, ip & 255); //IP
  178. GetConVarString(FindConVar("hostport"), sText[1], 64); //PORT
  179. IntToString(RoundToZero(1.0/GetTickInterval()), sText[2], 64);//TIC
  180. }
  181. ReplaceString(rkl, 1024, "{IP}", sText[0]);
  182. ReplaceString(rkl, 1024, "{PORT}", sText[1]);
  183. ReplaceString(rkl, 1024, "{TIC}", sText[2]);
  184. switch (tupe)
  185. {
  186. case H: CGOReplaceColorHsay(rkl, 1024);
  187. case S: CGOReplaceColorSay(rkl, 1024);
  188. }
  189. }
  190.  
  191. void VotePrintAll(const char[] tx)
  192. {
  193. Protobuf v = view_as<Protobuf>(StartMessageAll("VotePass", USERMSG_RELIABLE));
  194. v.SetInt("team", -1);
  195. v.SetString("disp_str", "#SFUI_Scoreboard_NormalPlayer");
  196. v.SetString("details_str", tx);
  197. v.SetInt("vote_type", 0);
  198. EndMessage();
  199. }
  200.  
  201. void kvup()
  202. {
  203. if(!us)
  204. {
  205. kfg.Rewind();
  206. kfg.JumpToKey("text");
  207. kfg.GotoFirstSubKey();
  208. us = true;
  209. return;
  210. }
  211. if(kfg.GotoNextKey()) return;
  212. else
  213. {
  214. kfg.Rewind();
  215. kfg.JumpToKey("text");
  216. kfg.GotoFirstSubKey();
  217. return;
  218. }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement