hlmod.hu
https://hlmod.hu/

RTV ColorChat
https://hlmod.hu/viewtopic.php?f=9&t=22329
Oldal: 1 / 1

Szerző:  asdafaka [2015.10.06. 20:24 ]
Hozzászólás témája:  RTV ColorChat

Sziasztok!
Próbálkoztam, egy olyannal hogy 1 RTV plugint megcsinálok úgy hogy print_chat-ról át teszem
ColorChat-á..
na igen de az a gond h megcsináltam és 4 hibát észlelt
AMX Mod X Compiler 1.8.3-manual
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

Modified for http://www.Freakz.ro / amx.freakz.ro

amxmodx-13449-rtv (2).sma(90) : error 029: invalid expression, assumed zero
amxmodx-13449-rtv (2).sma(90) : warning 217: loose indentation
amxmodx-13449-rtv (2).sma(90) : warning 215: expression has no effect
amxmodx-13449-rtv (2).sma(90) : error 001: expected token: ";", but found ")"
amxmodx-13449-rtv (2).sma(90) : error 029: invalid expression, assumed zero
amxmodx-13449-rtv (2).sma(90) : fatal error 107: too many error messages on one line

Compilation aborted.
4 Errors.
Done.



SMA Forráskód: [ Mindet kijelol ]
  1. /*
  2. * Made by DA
  3. *
  4. * Description:
  5. * This plugin allows the players on your server to vote for a mapvoting.
  6. * The players can say in the chat "/rockthevote", "rockthevote" or "rtv" to vote for the vote.
  7. * The maps will be automaticle loaded from the maps.ini (if it exists) or from the mapcycle.txt.
  8. *
  9. *
  10. * Installation:
  11. * 1. Download the rockthevote_custom.sma and compile it on your local machine.
  12. * 2. Put the rockthevote_custom.amxx in your plugins folder.
  13. * 3. Add at the end from the plugins.ini this line: rockthevote_custom.amxx
  14. * 4. Open your amxx.cfg (mod/addons/amxmodx/configs/) and add the cvar's.
  15. * 5. Restart or change the map from your server.
  16. *
  17. *
  18. * CVAR's:
  19. * amx_timevote number - Default 5 - After 5 MINUTES (Default) is rockthevote allowed.
  20. * amx_howmanypercentage float - Default 0.30 - When 30% (Default) of the players said rockthevote then comes the mapvote.
  21. * amx_howmanyvotes number - Default 8 - When 8 (default) players said rockthevote then comes the mapvote.
  22. * amx_rocktime time - Default 10 - After 10 (default) seconds the voting is over and the server change the map.
  23. *
  24. *
  25. * Credits:
  26. * Deagles - The main idea
  27. * arkshine - Some code
  28. * X-olent - Percentage idea
  29. *
  30. */
  31.  
  32. #include <amxmodx>
  33. #include <amxmisc>
  34. #include <colorchat>
  35.  
  36. #define PLUGIN "RockTheVote"
  37. #define AUTHOR "DA"
  38. #define VERSION "1.8"
  39.  
  40. #define MAX_MAPS 5
  41. #define MAX_MAP_LENGTH 64
  42. #define MAPSINI "maps.ini"
  43.  
  44. new rtv[33], howmanyvotes, task_time, keycount[MAX_MAPS], s_Maps[MAX_MAPS][MAX_MAP_LENGTH], count;
  45. new presskeys, howmanyvotesperc, timevote, directmapchange, bool:NextRoundChangeMap = false, nextmap[MAX_MAP_LENGTH];
  46.  
  47. public plugin_init()
  48. {
  49. register_plugin(PLUGIN, VERSION, AUTHOR);
  50. register_dictionary("mapchooser.txt");
  51. register_dictionary("common.txt");
  52. register_clcmd("say", "rockthevote");
  53. register_menu("Chose your Map", 1023, "gonna_chose");
  54. howmanyvotes = register_cvar("amx_howmanyvotes", "8");
  55. howmanyvotesperc = register_cvar("amx_howmanypercentage", "0.30");
  56. task_time = register_cvar("amx_rocktime", "10.0");
  57. timevote = register_cvar("amx_timevote", "5");
  58. directmapchange = register_cvar( "amx_directmapchange", "0" );
  59.  
  60. register_logevent ( "RoundStart", 2, "1=Round_Start" );
  61.  
  62. for (new i=0; i < MAX_MAPS+2; i++)
  63. presskeys = presskeys | (1<<i)
  64. }
  65.  
  66. public client_disconnect(id)
  67. {
  68. if (rtv[id-1] == id)
  69. {
  70. rtv[id-1] = 0;
  71. count--;
  72. }
  73. }
  74.  
  75. public RoundStart()
  76. {
  77. if ( !get_pcvar_num( directmapchange ) && NextRoundChangeMap )
  78. {
  79. server_cmd( "amx_map %s", nextmap );
  80. }
  81. }
  82.  
  83. public rockthevote(id)
  84. {
  85. new said[192];
  86. read_args(said, 192);
  87. if ((contain(said, "/rockthevote") != -1) || (contain(said, "rockthevote") != -1) || (contain(said, "rtv") != -1))
  88. {
  89. if (get_gametime() < (get_pcvar_float(timevote) * 60.0))
  90. ColorChat(id, RED, "Szavazas ^4jelenleg nem engedelyezett, varj meg: %d percet");
  91. else
  92. {
  93. if (rtv[id-1] == id)
  94. ColorChat(id, RED, "Te mar szavaztal!");
  95. else
  96. {
  97. rtv[id-1] = id;
  98. count++;
  99.  
  100. static num;
  101. num = get_playersnum();
  102. num = floatround((get_pcvar_float(howmanyvotesperc) * num));
  103. if ((num == count) || (count >= get_pcvar_num(howmanyvotes)))
  104. {
  105. // AMXX Nextmap Chooser by cheap_suit
  106. if(find_plugin_byfile("mapchooser.amxx") != INVALID_PLUGIN_ID)
  107. {
  108. new oldWinLimit = get_cvar_num("mp_winlimit"), oldMaxRounds = get_cvar_num("mp_maxrounds");
  109. set_cvar_num("mp_winlimit",0);
  110. set_cvar_num("mp_maxrounds",-1);
  111.  
  112. if(callfunc_begin("voteNextmap","mapchooser.amxx") == 1)
  113. callfunc_end();
  114.  
  115. set_cvar_num("mp_winlimit",oldWinLimit);
  116. set_cvar_num("mp_maxrounds",oldMaxRounds);
  117. set_task(get_pcvar_float(task_time), "change_map", true);
  118. return PLUGIN_CONTINUE;
  119. }
  120.  
  121. StartTheVote();
  122. return PLUGIN_CONTINUE;
  123. }
  124. static name[32];
  125. get_user_name( id, name, charsmax( name ) );
  126.  
  127. ColorChat(id, RED, "%s elinditotta a szavazast. meg: %d vagy %d^%^% hogy elinduljon a szavazas!");
  128. }
  129. }
  130. }
  131. return PLUGIN_CONTINUE;
  132. }
  133.  
  134. public gonna_chose(id, key)
  135. {
  136. if (key < MAX_MAPS)
  137. {
  138. keycount[key]++;
  139. static name[32]
  140. get_user_name(id, name, charsmax(name));
  141. client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, s_Maps[key]);
  142. }
  143. }
  144.  
  145. StartTheVote()
  146. {
  147. if (!RetrieveMaps(s_Maps))
  148. return PLUGIN_CONTINUE;
  149.  
  150. static i, chosetext[256];
  151. count=0;
  152.  
  153. formatex(chosetext, charsmax(chosetext), "\y%L:\w^n^n", LANG_SERVER, "CHOOSE_NEXTM");
  154. for (i=0; i < MAX_MAPS; i++)
  155. formatex(chosetext, charsmax(chosetext), "%s%d. %s^n", chosetext, i+1, s_Maps[i]);
  156.  
  157.  
  158. formatex(chosetext, charsmax(chosetext), "%s^n%d. %L", chosetext, MAX_MAPS+2, LANG_SERVER, "NONE");
  159. client_cmd(0, "spk Gman/Gman_Choose2");
  160. client_print(0, print_chat, "%L", LANG_SERVER, "TIME_CHOOSE");
  161. show_menu(0, presskeys, chosetext, 15, "Chose your Map");
  162. set_task(get_pcvar_float(task_time), "change_map", false);
  163. return PLUGIN_CONTINUE;
  164. }
  165.  
  166.  
  167. bool:RetrieveMaps(s_MapsFound[][])
  168. {
  169. new s_File[256], s_ConfigsDir[256];
  170. get_configsdir(s_ConfigsDir, 255);
  171. formatex(s_File, 255, "%s/%s", s_ConfigsDir, MAPSINI);
  172.  
  173. if (!file_exists(s_File))
  174. get_cvar_string("mapcyclefile", s_File, charsmax(s_File));
  175.  
  176. new s_CurrentMap[MAX_MAP_LENGTH];
  177. get_mapname(s_CurrentMap, charsmax(s_CurrentMap));
  178.  
  179. new p_File = fopen(s_File, "rt");
  180. new Array:a_Maps;
  181. new i_MapsCount = SaveAllMaps(p_File, a_Maps);
  182.  
  183. new bool:b_Error = true, i;
  184. switch (i_MapsCount)
  185. {
  186. case 0 : log_amx("Nincsenek mappok %s.", s_File);
  187. case 1 .. MAX_MAPS : log_amx("Nem eleg mappot talatak. (requires at least %d maps)", MAX_MAPS + 1 );
  188. default : b_Error = false;
  189. }
  190. if (b_Error)
  191. {
  192. fclose(p_File);
  193. ArrayDestroy(a_Maps);
  194. return false;
  195. }
  196. fclose(p_File);
  197.  
  198. new i_Rand, i_Cnt;
  199. while (i_Cnt != MAX_MAPS)
  200. {
  201. i_Rand = random_num(0, ArraySize(a_Maps) - 1);
  202. ArrayGetString(a_Maps, i_Rand, s_MapsFound[i_Cnt], MAX_MAP_LENGTH - 1);
  203.  
  204. if (equal(s_MapsFound[i_Cnt], s_CurrentMap))
  205. {
  206. continue;
  207. }
  208.  
  209. for (i = 0; i < i_Cnt; i++)
  210. {
  211. if (equal(s_MapsFound[i], s_MapsFound[i_Cnt]))
  212. {
  213. break;
  214. }
  215. }
  216.  
  217. if (i == i_Cnt)
  218. {
  219. ArrayDeleteItem(a_Maps, i_Rand);
  220. i_Cnt++;
  221. }
  222. }
  223. ArrayDestroy(a_Maps);
  224. return true;
  225. }
  226.  
  227. SaveAllMaps(p_File, &Array:a_Maps)
  228. {
  229. a_Maps = ArrayCreate(MAX_MAP_LENGTH);
  230. new s_Buffer[MAX_MAP_LENGTH]
  231.  
  232. while (!feof(p_File))
  233. {
  234. fgets(p_File, s_Buffer, charsmax(s_Buffer));
  235. trim(s_Buffer);
  236. if (!s_Buffer[0] || s_Buffer[0] == ';' || (s_Buffer[0] == '/' && s_Buffer[1] == '/'))
  237. {
  238. continue;
  239. }
  240. if (is_map_valid(s_Buffer))
  241. {
  242. ArrayPushString(a_Maps, s_Buffer);
  243. }
  244. }
  245. return ArraySize(a_Maps);
  246. }
  247.  
  248. public change_map(bool:chooserornot)
  249. {
  250. if (!chooserornot)
  251. {
  252. static keypuffer=0, i=0;
  253. for (i=0; i < MAX_MAPS; i++)
  254. if (keycount[i] > keycount[keypuffer])
  255. keypuffer = i;
  256.  
  257. copy(nextmap, charsmax(nextmap), s_Maps[keypuffer]);
  258. }
  259. else
  260. get_cvar_string("amx_nextmap", nextmap, charsmax(nextmap));
  261.  
  262. log_amx("Map will be changed to %s.", nextmap)
  263. if (chooserornot)
  264. client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", nextmap);
  265.  
  266. if ( !get_pcvar_num( directmapchange ) )
  267. {
  268. set_hudmessage(210, 0, 0, 0.05, 0.45, 1, 20.0, 10.0, 0.5, 0.15, 4);
  269. show_hudmessage(0, "This is the final round");
  270.  
  271. NextRoundChangeMap = true;
  272. }
  273.  
  274. else
  275. {
  276. server_cmd("amx_map %s", nextmap);
  277. }
  278. }


nagyjából át írtam a lényegesebbet..

Szerző:  mforce [2015.10.06. 21:11 ]
Hozzászólás témája:  Re: RTV ColorChat

Szerkeszd és Másold be újra a helyére azt az sma-t pls...

Szerző:  asdafaka [2015.10.06. 21:18 ]
Hozzászólás témája:  Re: RTV ColorChat

mforce írta:
Szerkeszd és Másold be újra a helyére azt az sma-t pls...


Kész van!

Szerző:  mforce [2015.10.06. 21:23 ]
Hozzászólás témája:  Re: RTV ColorChat

SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define PLUGIN "RockTheVote"
  5. #define AUTHOR "DA"
  6. #define VERSION "1.8"
  7.  
  8. #define MAX_MAPS 5
  9. #define MAX_MAP_LENGTH 64
  10. #define MAPSINI "maps.ini"
  11.  
  12. new rtv[33], howmanyvotes, task_time, keycount[MAX_MAPS], s_Maps[MAX_MAPS][MAX_MAP_LENGTH], count;
  13. new presskeys, howmanyvotesperc, timevote, directmapchange, bool:NextRoundChangeMap = false, nextmap[MAX_MAP_LENGTH];
  14.  
  15. public plugin_init()
  16. {
  17. register_plugin(PLUGIN, VERSION, AUTHOR);
  18. register_dictionary("mapchooser.txt");
  19. register_dictionary("common.txt");
  20. register_clcmd("say", "rockthevote");
  21. register_menu("Chose your Map", 1023, "gonna_chose");
  22. howmanyvotes = register_cvar("amx_howmanyvotes", "8");
  23. howmanyvotesperc = register_cvar("amx_howmanypercentage", "0.30");
  24. task_time = register_cvar("amx_rocktime", "10.0");
  25. timevote = register_cvar("amx_timevote", "5");
  26. directmapchange = register_cvar( "amx_directmapchange", "0" );
  27.  
  28. register_logevent ( "RoundStart", 2, "1=Round_Start" );
  29.  
  30. for (new i=0; i < MAX_MAPS+2; i++)
  31. presskeys = presskeys | (1<<i)
  32. }
  33.  
  34. public client_disconnect(id)
  35. {
  36. if (rtv[id-1] == id)
  37. {
  38. rtv[id-1] = 0;
  39. count--;
  40. }
  41. }
  42.  
  43. public RoundStart()
  44. {
  45. if ( !get_pcvar_num( directmapchange ) && NextRoundChangeMap )
  46. {
  47. server_cmd( "amx_map %s", nextmap );
  48. }
  49. }
  50.  
  51. public rockthevote(id)
  52. {
  53. new said[192];
  54. read_args(said, 192);
  55. if ((contain(said, "/rockthevote") != -1) || (contain(said, "rockthevote") != -1) || (contain(said, "rtv") != -1))
  56. {
  57. if (get_gametime() < (get_pcvar_float(timevote) * 60.0))
  58. print_color(id, "Szavazas jelenleg nem engedelyezett, varj meg:!t %d percet");
  59. else
  60. {
  61. if (rtv[id-1] == id)
  62. print_color(id, "!tTe mar szavaztal!");
  63. else
  64. {
  65. rtv[id-1] = id;
  66. count++;
  67.  
  68. static num;
  69. num = get_playersnum();
  70. num = floatround((get_pcvar_float(howmanyvotesperc) * num));
  71. if ((num == count) || (count >= get_pcvar_num(howmanyvotes)))
  72. {
  73. // AMXX Nextmap Chooser by cheap_suit
  74. if(find_plugin_byfile("mapchooser.amxx") != INVALID_PLUGIN_ID)
  75. {
  76. new oldWinLimit = get_cvar_num("mp_winlimit"), oldMaxRounds = get_cvar_num("mp_maxrounds");
  77. set_cvar_num("mp_winlimit",0);
  78. set_cvar_num("mp_maxrounds",-1);
  79.  
  80. if(callfunc_begin("voteNextmap","mapchooser.amxx") == 1)
  81. callfunc_end();
  82.  
  83. set_cvar_num("mp_winlimit",oldWinLimit);
  84. set_cvar_num("mp_maxrounds",oldMaxRounds);
  85. set_task(get_pcvar_float(task_time), "change_map", true);
  86. return PLUGIN_CONTINUE;
  87. }
  88.  
  89. StartTheVote();
  90. return PLUGIN_CONTINUE;
  91. }
  92. static name[32];
  93. get_user_name( id, name, charsmax( name ) );
  94.  
  95. print_color(id, "%s elinditotta a szavazast. meg: %d vagy %d^%^% hogy elinduljon a szavazas!");
  96. }
  97. }
  98. }
  99. return PLUGIN_CONTINUE;
  100. }
  101.  
  102. public gonna_chose(id, key)
  103. {
  104. if (key < MAX_MAPS)
  105. {
  106. keycount[key]++;
  107. static name[32]
  108. get_user_name(id, name, charsmax(name));
  109. client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, s_Maps[key]);
  110. }
  111. }
  112.  
  113. StartTheVote()
  114. {
  115. if (!RetrieveMaps(s_Maps))
  116. return PLUGIN_CONTINUE;
  117.  
  118. static i, chosetext[256];
  119. count=0;
  120.  
  121. formatex(chosetext, charsmax(chosetext), "\y%L:\w^n^n", LANG_SERVER, "CHOOSE_NEXTM");
  122. for (i=0; i < MAX_MAPS; i++)
  123. formatex(chosetext, charsmax(chosetext), "%s%d. %s^n", chosetext, i+1, s_Maps[i]);
  124.  
  125.  
  126. formatex(chosetext, charsmax(chosetext), "%s^n%d. %L", chosetext, MAX_MAPS+2, LANG_SERVER, "NONE");
  127. client_cmd(0, "spk Gman/Gman_Choose2");
  128. client_print(0, print_chat, "%L", LANG_SERVER, "TIME_CHOOSE");
  129. show_menu(0, presskeys, chosetext, 15, "Chose your Map");
  130. set_task(get_pcvar_float(task_time), "change_map", false);
  131. return PLUGIN_CONTINUE;
  132. }
  133.  
  134.  
  135. bool:RetrieveMaps(s_MapsFound[][])
  136. {
  137. new s_File[256], s_ConfigsDir[256];
  138. get_configsdir(s_ConfigsDir, 255);
  139. formatex(s_File, 255, "%s/%s", s_ConfigsDir, MAPSINI);
  140.  
  141. if (!file_exists(s_File))
  142. get_cvar_string("mapcyclefile", s_File, charsmax(s_File));
  143.  
  144. new s_CurrentMap[MAX_MAP_LENGTH];
  145. get_mapname(s_CurrentMap, charsmax(s_CurrentMap));
  146.  
  147. new p_File = fopen(s_File, "rt");
  148. new Array:a_Maps;
  149. new i_MapsCount = SaveAllMaps(p_File, a_Maps);
  150.  
  151. new bool:b_Error = true, i;
  152. switch (i_MapsCount)
  153. {
  154. case 0 : log_amx("Nincsenek mappok %s.", s_File);
  155. case 1 .. MAX_MAPS : log_amx("Nem eleg mappot talatak. (requires at least %d maps)", MAX_MAPS + 1 );
  156. default : b_Error = false;
  157. }
  158. if (b_Error)
  159. {
  160. fclose(p_File);
  161. ArrayDestroy(a_Maps);
  162. return false;
  163. }
  164. fclose(p_File);
  165.  
  166. new i_Rand, i_Cnt;
  167. while (i_Cnt != MAX_MAPS)
  168. {
  169. i_Rand = random_num(0, ArraySize(a_Maps) - 1);
  170. ArrayGetString(a_Maps, i_Rand, s_MapsFound[i_Cnt], MAX_MAP_LENGTH - 1);
  171.  
  172. if (equal(s_MapsFound[i_Cnt], s_CurrentMap))
  173. {
  174. continue;
  175. }
  176.  
  177. for (i = 0; i < i_Cnt; i++)
  178. {
  179. if (equal(s_MapsFound[i], s_MapsFound[i_Cnt]))
  180. {
  181. break;
  182. }
  183. }
  184.  
  185. if (i == i_Cnt)
  186. {
  187. ArrayDeleteItem(a_Maps, i_Rand);
  188. i_Cnt++;
  189. }
  190. }
  191. ArrayDestroy(a_Maps);
  192. return true;
  193. }
  194.  
  195. SaveAllMaps(p_File, &Array:a_Maps)
  196. {
  197. a_Maps = ArrayCreate(MAX_MAP_LENGTH);
  198. new s_Buffer[MAX_MAP_LENGTH]
  199.  
  200. while (!feof(p_File))
  201. {
  202. fgets(p_File, s_Buffer, charsmax(s_Buffer));
  203. trim(s_Buffer);
  204. if (!s_Buffer[0] || s_Buffer[0] == ';' || (s_Buffer[0] == '/' && s_Buffer[1] == '/'))
  205. {
  206. continue;
  207. }
  208. if (is_map_valid(s_Buffer))
  209. {
  210. ArrayPushString(a_Maps, s_Buffer);
  211. }
  212. }
  213. return ArraySize(a_Maps);
  214. }
  215.  
  216. public change_map(bool:chooserornot)
  217. {
  218. if (!chooserornot)
  219. {
  220. static keypuffer=0, i=0;
  221. for (i=0; i < MAX_MAPS; i++)
  222. if (keycount[i] > keycount[keypuffer])
  223. keypuffer = i;
  224.  
  225. copy(nextmap, charsmax(nextmap), s_Maps[keypuffer]);
  226. }
  227. else
  228. get_cvar_string("amx_nextmap", nextmap, charsmax(nextmap));
  229.  
  230. log_amx("Map will be changed to %s.", nextmap)
  231. if (chooserornot)
  232. client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", nextmap);
  233.  
  234. if ( !get_pcvar_num( directmapchange ) )
  235. {
  236. set_hudmessage(210, 0, 0, 0.05, 0.45, 1, 20.0, 10.0, 0.5, 0.15, 4);
  237. show_hudmessage(0, "This is the final round");
  238.  
  239. NextRoundChangeMap = true;
  240. }
  241.  
  242. else
  243. {
  244. server_cmd("amx_map %s", nextmap);
  245. }
  246. }
  247.  
  248. stock print_color(const id, const input[], any:...)
  249. {
  250. new count = 1, players[32]
  251. static msg[191]
  252. vformat(msg, 190, input, 3)
  253.  
  254. replace_all(msg, 190, "!g", "^4")
  255. replace_all(msg, 190, "!y", "^1")
  256. replace_all(msg, 190, "!t", "^3")
  257.  
  258. if (id) players[0] = id; else get_players(players, count, "ch")
  259. {
  260. for (new i = 0; i < count; i++)
  261. {
  262. if (is_user_connected(players[i]))
  263. {
  264. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  265. write_byte(players[i])
  266. write_string(msg)
  267. message_end()
  268. }
  269. }
  270. }
  271. return PLUGIN_HANDLED
  272. }

Szerző:  asdafaka [2015.10.06. 21:36 ]
Hozzászólás témája:  Re: RTV ColorChat

Épp, ez az hogy nekem színesen kéne.. azért akartam ColorChat-ra

Szerző:  mforce [2015.10.06. 21:39 ]
Hozzászólás témája:  Re: RTV ColorChat

és kaptál print_color-t ami sokkal jobb. Színes...

Szerző:  asdafaka [2015.10.06. 21:41 ]
Hozzászólás témája:  Re: RTV ColorChat

mforce írta:
és kaptál print_color-t ami sokkal jobb. Színes...

Beraktam.. de nem működik első sorba tettem
galileo bent van az zavarna neki?

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/