HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*Kitalálta: Matthew
  2. www.stayhosting.hu*/
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <cstrike>
  6. #include <fakemeta>
  7. #include <engine>
  8. #include <hamsandwich>
  9.  
  10. #define PLUGIN "Zoom Mod"
  11. #define VERSION "1.0"
  12. #define AUTHOR "Idarav"
  13.  
  14. #define ZOOM_DEFAULT 0
  15. #define ZOOM_OFF 1
  16. #define ZOOM_DRAGSHOT 2
  17.  
  18. #define TIME_DELAY 0.75
  19. #define TIME_ZOOM 0.25
  20. #define TIME_VOTE_DELAY 300.0
  21. #define TIME_VOTE_TIME 15.0
  22.  
  23. #define ADMIN_FLAG ADMIN_BAN
  24.  
  25. new Float: lastzoom[33]
  26. new cvar_zoom
  27.  
  28. new weapons[][] = {
  29. "weapon_awp",
  30. "weapon_scout",
  31. "weapon_sg550",
  32. "weapon_g3sg1"
  33. }
  34.  
  35. new saytext_msgid
  36.  
  37. //KEYSMENU
  38. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
  39. new szavazat[33]=-1
  40. new szavazat_szam[3]=0
  41. new Float: lastvote=-5000.0
  42.  
  43. new warmupc = 30
  44.  
  45. new g_iMaxPlayers
  46. public plugin_init() {
  47. register_plugin(PLUGIN, VERSION, AUTHOR)
  48.  
  49. register_forward(FM_CmdStart, "cmdstart");
  50. register_forward(FM_EmitSound, "fw_EmitSound")
  51.  
  52. for (new i = 0; i < sizeof(weapons); i++)
  53. RegisterHam(Ham_Weapon_PrimaryAttack, weapons[i], "fw_Weapon_PrimaryAttack_Pre")
  54.  
  55. register_event( "DeathMsg","playerkilled","a" );
  56.  
  57. register_menu("vote_menu", KEYSMENU, "cmd_vote_menu")
  58. register_menu("ures_menu", KEYSMENU, "cmd_ures_menu")
  59.  
  60. register_clcmd("say /zoomvote", "zoomvote")
  61. register_clcmd("amx_zoomvote", "zoomvote_admin")
  62.  
  63. register_clcmd("say zoomvotemenu", "vote_menu")
  64. register_clcmd("say zv", "vote_menu")
  65.  
  66. saytext_msgid = get_user_msgid("SayText")
  67.  
  68. cvar_zoom = register_cvar("zoom_type", "1")
  69.  
  70. g_iMaxPlayers = get_maxplayers()
  71.  
  72. set_task(10.0, "warmup")
  73. set_pcvar_num(cvar_zoom, 0)
  74.  
  75. return PLUGIN_CONTINUE;
  76. }
  77.  
  78. public plugin_precache()
  79. {
  80. new iEnt
  81. iEnt = create_entity("info_map_parameters")
  82. DispatchKeyValue(iEnt, "buying", "3")
  83. DispatchSpawn(iEnt)
  84.  
  85. server_cmd("sv_restart 1")
  86. }
  87.  
  88. public client_disconnect(id)
  89. {
  90. szavazat[id]=-1
  91. }
  92. public client_putinserver(id)
  93. {
  94. szavazat[id]=-1
  95. set_task(20.0, "reklam", id+1717)
  96. }
  97.  
  98. public warmup()
  99. {
  100. if(warmupc > 0)
  101. {
  102. set_task(1.0, "warmup")
  103. set_hudmessage(255, 170, 127, -1.0, 0.29, 0, 6.0, 1.0)
  104. show_hudmessage(0, "Warmup^n%d sec", warmupc)
  105. warmupc--
  106.  
  107. }
  108. if(warmupc == 15)
  109. {
  110. set_task(1.0, "zoomvote", 0)
  111. set_task(2.0+TIME_VOTE_TIME, "rr")
  112. }
  113. }
  114. public rr()
  115. {
  116. server_cmd("sv_restartround 1")
  117. }
  118.  
  119. public reklam(taskid)
  120. {
  121. taskid-=1717
  122. print_color(taskid, "^x04[ZOOM]^x01 Ha szavazast szeretnel ird a chatbe: ^x03/zoomvote ^x04(By Idarav)")
  123. }
  124.  
  125. public cmdstart( id, uc_handle, random_seed )
  126. {
  127. new Float: gametime = get_gametime()
  128. //static buttons; buttons = get_uc( uc_handle, UC_Buttons )
  129. //new oldbutton = get_user_oldbutton(id)
  130. new zoom = cs_get_user_zoom(id)
  131. //client_print(0, print_chat, " VALAMI %d %d %f", id, zoom, gametime)
  132.  
  133. if(zoom == 2 || zoom == 3)
  134. {
  135. if(get_pcvar_num(cvar_zoom) == ZOOM_DRAGSHOT)
  136. {
  137. if(lastzoom[id] == -1.0)
  138. {
  139. lastzoom[id] = (gametime)
  140. }else if(gametime-lastzoom[id] > TIME_ZOOM)
  141. {
  142. cs_set_user_zoom(id, 1, 1)
  143. new weapon = get_user_weapon(id)
  144. switch(weapon)
  145. {
  146. case CSW_AWP: set_pev(id, pev_maxspeed, 210.0 )
  147. case CSW_SCOUT: set_pev(id, pev_maxspeed, 260.0)
  148. case CSW_SG550: set_pev(id, pev_maxspeed, 210.0)
  149. case CSW_G3SG1: set_pev(id, pev_maxspeed, 210.0)
  150. }
  151. client_cmd(id, "-attack2")
  152. }
  153. }else if(get_pcvar_num(cvar_zoom) == ZOOM_OFF){
  154. cs_set_user_zoom(id, 1, 1)
  155. new weapon = get_user_weapon(id)
  156. switch(weapon)
  157. {
  158. case CSW_AWP: set_pev(id, pev_maxspeed, 210.0 )
  159. case CSW_SCOUT: set_pev(id, pev_maxspeed, 260.0)
  160. case CSW_SG550: set_pev(id, pev_maxspeed, 210.0)
  161. case CSW_G3SG1: set_pev(id, pev_maxspeed, 210.0)
  162. }
  163. client_cmd(id, "-attack2")
  164. }
  165. }else{
  166. if(gametime-lastzoom[id] > TIME_DELAY)
  167. lastzoom[id] = -1.0
  168. }
  169. }
  170. public fw_Weapon_PrimaryAttack_Pre(entity)
  171. {
  172. if(get_pcvar_num(cvar_zoom) == ZOOM_DRAGSHOT)
  173. {
  174. new id = pev(entity, pev_owner)
  175. cs_set_user_zoom(id, 1, 1)
  176. new weapon = get_user_weapon(id)
  177. switch(weapon)
  178. {
  179. case CSW_AWP: set_pev(id, pev_maxspeed, 210.0 )
  180. case CSW_SCOUT: set_pev(id, pev_maxspeed, 260.0)
  181. case CSW_SG550: set_pev(id, pev_maxspeed, 210.0)
  182. case CSW_G3SG1: set_pev(id, pev_maxspeed, 210.0)
  183. }
  184. client_cmd(id, "-attack2")
  185. }
  186.  
  187. }
  188.  
  189.  
  190. public fw_EmitSound(id,channel,const sample[],Float:volume,Float:attn,flags,pitch)
  191. {
  192. if(is_user_connected(id) && lastzoom[id] != -1.0 && equal(sample, "weapons/zoom.wav"))
  193. {
  194. emit_sound(id,channel,"",volume,attn,flags,pitch)
  195. return FMRES_SUPERCEDE;
  196. }
  197. return FMRES_IGNORED
  198. }
  199.  
  200. /*=============================7
  201. == ZOOM VOTE
  202. ===*/
  203. public zoomvote(id)
  204. {
  205. new Float: gametime = get_gametime()
  206.  
  207. if(gametime-lastvote >= TIME_VOTE_DELAY)
  208. {
  209. print_color(0, "^x04[ZOOM]^x03 Szavazas lesz! ^x01(ha eltunik a szavazas menu azelott hogy szavaztal volna ird a chatbe: ^x04zv^x01 vagy ^x04zoomvotemenu^x01)")
  210. set_task(3.0, "showvote")
  211. }else if(warmupc>0)
  212. {
  213. print_color(id, "^x04[ZOOM] ^x01Csak warmup utan indithatsz szavazast")
  214. }else{
  215. new Float: kul = TIME_VOTE_DELAY-gametime+lastvote
  216. new perc = floatround(kul/60+0.0, floatround_floor)
  217. new sec = floatround(kul-perc*60+0.0, floatround_floor)
  218. print_color(id, "^x04[ZOOM] ^x01Kovetkezo zavazasig meg varni kell ^x03%d^x01 percet es ^x03%d^x01 masodpercet", perc, sec)
  219. }
  220. }
  221. public zoomvote_admin(id)
  222. {
  223. if(get_user_flags(id) & ADMIN_FLAG)
  224. {
  225. new name[33]
  226. get_user_name(id, name, 32)
  227. print_color(0, "^x04[ZOOM]^x03 Szavazas lesz! ^x04[%s]", name)
  228. print_color(0, "^x04[ZOOM]^x01 (ha eltunik a szavazas menu azelott hogy szavaztal volna ird a chatbe: ^x04zv^x01 vagy ^x04zoomvotemenu^x01)")
  229. set_task(3.0, "showvote")
  230. }else{
  231. client_print(id, print_console, "[ZOOM] Ezt a parancsot csak az adminok hasznalhatjak!")
  232. }
  233. }
  234.  
  235. print_color(target, const message[], any:...)
  236. {
  237. static buffer[512], i, argscount
  238. argscount = numargs()
  239.  
  240. // Send to everyone
  241. if (!target)
  242. {
  243. static player
  244. for (player = 1; player <= g_iMaxPlayers; player++)
  245. {
  246. // Not connected
  247. if (!is_user_connected(player))
  248. continue;
  249.  
  250. // Remember changed arguments
  251. static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
  252. changedcount = 0
  253.  
  254. // Replace LANG_PLAYER with player id
  255. for (i = 2; i < argscount; i++)
  256. {
  257. if (getarg(i) == LANG_PLAYER)
  258. {
  259. setarg(i, 0, player)
  260. changed[changedcount] = i
  261. changedcount++
  262. }
  263. }
  264.  
  265. // Format message for player
  266. vformat(buffer, charsmax(buffer), message, 3)
  267.  
  268. // Send it
  269. message_begin(MSG_ONE_UNRELIABLE, saytext_msgid, _, player)
  270. write_byte(player)
  271. write_string(buffer)
  272. message_end()
  273.  
  274. // Replace back player id's with LANG_PLAYER
  275. for (i = 0; i < changedcount; i++)
  276. setarg(changed[i], 0, LANG_PLAYER)
  277. }
  278. }
  279. // Send to specific target
  280. else
  281. {
  282. // Format message for player
  283. vformat(buffer, charsmax(buffer), message, 3)
  284.  
  285. // Send it
  286. message_begin(MSG_ONE, saytext_msgid, _, target)
  287. write_byte(target)
  288. write_string(buffer)
  289. message_end()
  290. }
  291. }
  292.  
  293. public showvote()
  294. {
  295. lastvote = get_gametime()
  296. for(new i=1; i<33; i++)
  297. {
  298. if(is_user_connected(i))
  299. {
  300. szavazat[i]=-1
  301. vote_menu(i)
  302.  
  303. }
  304. }
  305. for(new i; i<sizeof(szavazat_szam); i++)
  306. {
  307. szavazat_szam[i]=0
  308. }
  309. set_task(TIME_VOTE_TIME, "voteend")
  310. }
  311. public vote_menu(id)
  312. {
  313. if(szavazat[id] != -1)
  314. {
  315. print_color(0, "^x04[ZOOM]^x01 Te mar szavaztal!")
  316. return;
  317. }
  318. static menu[350], len
  319. len = 0
  320.  
  321. len += formatex(menu[len], charsmax(menu) - len, "\yZoom Mod szavazas...^n")
  322. len += formatex(menu[len], charsmax(menu) - len, "\wMilyen modot szeretnel?^n^n")
  323.  
  324.  
  325. len += formatex(menu[len], charsmax(menu) - len, "\y1.\w Alap mod^n")
  326. len += formatex(menu[len], charsmax(menu) - len, "\y2.\w Ne lehessen zoomolni.^n")
  327. len += formatex(menu[len], charsmax(menu) - len, "\y3.\w Drag Shot^n (ez egy negyedmasodperces zoomot engedelyez)^n")
  328.  
  329. show_menu(id, KEYSMENU, menu, -1, "vote_menu")
  330. }
  331.  
  332. public cmd_vote_menu(id, key)
  333. {
  334. switch(key) {
  335. case 0:{
  336. print_color(id, "^x04[ZOOM]^x01 A te szavazatod:^x03 Alap mod")
  337. szavazat[id]=0;
  338. return;
  339. }
  340. case 1:{
  341. print_color(id, "^x04[ZOOM]^x01 A te szavazatod:^x03 Ne legyen zoom")
  342. szavazat[id]=1;
  343. return;
  344. }
  345. case 2:{
  346. print_color(id, "^x04[ZOOM]^x01 A te szavazatod:^x03 Drag Shot")
  347. szavazat[id]=2;
  348. return;
  349. }
  350. }
  351. vote_menu(id)
  352. return ;
  353. }
  354. //Üres menü
  355. public ures_menu(id)
  356. {
  357. static menu[350], len
  358. len = 0
  359.  
  360. len += formatex(menu[len], charsmax(menu) - len, " ")
  361.  
  362. show_menu(id, KEYSMENU, menu, -1, "ures_menu")
  363. }
  364.  
  365.  
  366.  
  367. public cmd_ures_menu(id, key)
  368. {
  369. return ;
  370. }
  371.  
  372. public voteend()
  373. {
  374. for(new i=1; i<33; i++)
  375. {
  376. if(is_user_connected(i))
  377. {
  378. if(szavazat[i] == -1)
  379. ures_menu(i)
  380. else
  381. szavazat_szam[szavazat[i]]++
  382.  
  383. }
  384. }
  385. new nyert[50]
  386. if(szavazat_szam[0] >= szavazat_szam[1])
  387. {
  388. if(szavazat_szam[0] >= szavazat_szam[2])// 0
  389. {
  390. nyert = "Alap mod "
  391. set_pcvar_num(cvar_zoom, ZOOM_DEFAULT)
  392. }else{ // 2
  393. nyert = "Drag Shot"
  394. set_pcvar_num(cvar_zoom, ZOOM_DRAGSHOT)
  395. }
  396. }else{
  397. if(szavazat_szam[1] > szavazat_szam[2]) // 1
  398. {
  399. nyert = "Ne legyen zoom"
  400. set_pcvar_num(cvar_zoom, ZOOM_OFF)
  401. }else{ // 2
  402. nyert = "Drag Shot"
  403. set_pcvar_num(cvar_zoom, ZOOM_DRAGSHOT)
  404. }
  405. }
  406. print_color(0, "^x04[ZOOM]^x01 Szavazas vegeredmenye:^x03 Alap mod ^x01- ^x04%d ^x01|^x03Ne legyen zoom ^x01- ^x04%d ^x01|^x03 Drag Shot ^x01- ^x04%d ^x03---> ^x01%s", szavazat_szam[0], szavazat_szam[1], szavazat_szam[2], nyert)
  407.  
  408. }
  409.  
  410. public playerkilled()
  411. {
  412. new id = read_data( 2 );
  413. new team2 = get_user_team(id)
  414.  
  415. if((team2 == 2 || team2 == 1) && warmupc > 0)
  416. {
  417. set_task(2.0, "respawn", id+55555)
  418. }
  419. }
  420. public respawn(id)
  421. {
  422. id-=55555
  423. ExecuteHamB(Ham_CS_RoundRespawn, id)
  424. }
  425.