hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.06.16. 12:10



Jelenlévő felhasználók

Jelenleg 342 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 341 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Google [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: sv_restart 1 command
HozzászólásElküldve: 2013.11.13. 07:17 
Offline
Újonc

Csatlakozott: 2013.11.13. 07:11
Hozzászólások: 3
Sziasztok!

Még új vagyok PAWN terén. Van egy NPC zm módom, ha aktiválni akarom a módot, hogy elinduljon újra kell a kört sv_restart 1-el.

Egy olyan kiegészítés kellene, hogy az első felcsatlakozónak kiirja, hogy elinditja e a módot. Ez alatt persze a servercmd menne az sv_restart 1-el. Illetve a másik kiegészítés, ha megölünk minden zm-et akkor is kiirja az elinditást.

Edit: Vagy nem is kell több mint egy egyszerűbb visszaszámláló a kör kezdésig és sv_restart 1 parancs, ami az összes zombie megölésekor jön elő vagy halálkor.
A kód.

SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4. #include <engine>
  5. #include <fakemeta>
  6. #include <hamsandwich>
  7. #include <cstrike>
  8. #include <round_terminator>
  9. #include <fun>
  10. #include <colorchat>
  11.  
  12. #define ZB_CLASSNAME "npc_zombie"
  13. #define AMMOBOX_CLASSNAME "ammo_box"
  14.  
  15. #define TASK_ATTACK 323423
  16. #define TASK_APPEAR 534534
  17. #define TASK_CREATE 534332
  18. #define TASK_HUD 967697
  19. #define TASK_AMMO 5234234
  20. #define TASK_SHOWAMMO 5345345
  21. #define TASK_LIGHT 5343452
  22. #define TASK_ROUND_SOUND 3234234
  23.  
  24. #define LIGHT "c"
  25. #define SKYNAME "DrkG"
  26.  
  27. enum
  28. {
  29. ANIM_IDLE = 0,
  30. ANIM_WALK = 1,
  31. ANIM_ATTACK = 2,
  32. ANIM_DIE = 3
  33. }
  34.  
  35. new pev_victim = pev_enemy
  36. new m_iBlood[2]
  37.  
  38. // spawns & way points
  39. new const SPAWNS_FILE[] = "%s/zm_ai/sp_%s.cfg"
  40. new const BOXS_FILE[] = "%s/zm_ai/box_%s.cfg"
  41. const MAX_SPAWNS = 128
  42. new Float:g_spawns[MAX_SPAWNS][3], g_total_spawns, Float:g_spawns_boss[MAX_SPAWNS][3], g_total_spawns_boss
  43. new Float:npc_size_width = 16.0, Float:npc_size_height = 75.0
  44. new Float:g_boxs[MAX_SPAWNS][3], g_total_boxs
  45.  
  46. #define MAX_DAY 12
  47. new g_day
  48. new const g_zombie_count[MAX_DAY + 1] = {
  49. 20,
  50. 30,
  51. 40,
  52. 50,
  53. 60,
  54. 70,
  55. 80,
  56. 90,
  57. 100,
  58. 110,
  59. 120,
  60. 200,
  61. 300
  62. }
  63.  
  64. new const g_remove_entities[][] =
  65. {
  66. "func_bomb_target",
  67. "info_bomb_target",
  68. "hostage_entity",
  69. "monster_scientist",
  70. "func_hostage_rescue",
  71. "info_hostage_rescue",
  72. "info_vip_start",
  73. "func_vip_safetyzone",
  74. "func_escapezone"
  75. //"func_buyzone"
  76. }
  77.  
  78. new const Float:g_health_multi[MAX_DAY] = {
  79. 1.0,
  80. 1.2,
  81. 1.4,
  82. 1.6,
  83. 1.8,
  84. 2.0,
  85. 2.2,
  86. 2.4,
  87. 2.6,
  88. 2.8,
  89. 3.0
  90. }
  91.  
  92. new bool:g_reg
  93. new g_day_zombie, g_current_zombie, g_current_zombie2
  94. new sync_hud1//, sync_hud2
  95. new g_fail, in_reloading_ammobox[33]
  96. new is_boss_round, ammobox_id, fwd_zombie_create, g_fwSpawn
  97.  
  98. #define MAX_NPC 1000
  99. new g_zombie[MAX_NPC], g_class[MAX_NPC], g_total_class, g_think[MAX_NPC]
  100. new Array:g_class_health, Array:g_class_speed, Array:g_class_model, Array:g_class_modelindex
  101. new current_target[MAX_NPC]
  102.  
  103. new const ammobox_spr[] = "sprites/zombie_mode_ai/ammo_box.spr"
  104. new const ammobox_model[] = "models/zombie_mode_ai/ammo_box.mdl"
  105. new const ammobox_reload_sound[] = "zombie_mode_ai/FullAmmo.wav"
  106. new const sound_start[][] = {
  107. "zombie_mode_ai/AI_STAGE_START.WAV"
  108. }
  109.  
  110. new const sound_end[][] = {
  111. "zombie_mode_ai/AI_STAGE_END.WAV"
  112. }
  113.  
  114. new const sound_die[][] = {
  115. "zombie_mode_ai/NPC_DOWN1.WAV",
  116. "zombie_mode_ai/NPC_DOWN2.WAV",
  117. "zombie_mode_ai/2NANODEATH.WAV",
  118. "zombie_mode_ai/3NANODEATH.WAV"
  119. }
  120.  
  121. new const sound_attack[][] = {
  122. "zombie_mode_ai/nano_attack_2.wav",
  123. "weapons/knife_hit4.wav",
  124. "zombie_mode_ai/zombi_attack_1.wav",
  125. "weapons/knife_hit2.wav"
  126. }
  127.  
  128. new const sound_pain[][] = {
  129. "zombie_mode_ai/zombie_pain1.wav",
  130. "zombie_mode_ai/zombie_pain2.wav",
  131. "zombie_mode_ai/zombie_pain3.wav",
  132. "zombie_mode_ai/zombie_pain4.wav",
  133. "zombie_mode_ai/zombie_pain5.wav"
  134. }
  135. new const round_sound[][] = {
  136. "zombie_mode_ai/Daft_Punk-Recognizer.mp3"
  137. }
  138.  
  139. public plugin_init()
  140. {
  141. register_plugin("Zombie NPC", "1.0", "ZHR")
  142.  
  143. register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  144. register_logevent("event_roundstart", 2, "1=Round_Start")
  145. register_event("SendAudio", "round_end", "a", "2&%!MRAD_terwin")
  146. register_event("SendAudio", "round_end", "a", "2&%!MRAD_ctwin")
  147. register_event("SendAudio", "round_end", "a", "2&%!MRAD_rounddraw")
  148.  
  149. register_logevent("event_round_end", 2, "1=Round_End")
  150. register_event("TextMsg","event_round_end","a","2=#Game_Commencing","2=#Game_will_restart_in")
  151.  
  152. register_message(get_user_msgid("TextMsg"), "hook_textmsg")
  153. register_think(ZB_CLASSNAME, "fw_zb_think")
  154. register_forward(FM_CmdStart, "fw_cmdstart")
  155. unregister_forward(FM_Spawn, g_fwSpawn)
  156. RegisterHam(Ham_Spawn, "player", "fw_spawn", 1)
  157. RegisterHam(Ham_TakeDamage, "player", "fw_takedamage")
  158.  
  159. sync_hud1 = CreateHudSyncObj(5)
  160. //sync_hud2 = CreateHudSyncObj(6)
  161.  
  162. g_day = 0
  163. g_day_zombie = g_zombie_count[g_day]
  164. g_current_zombie = g_day_zombie
  165. g_current_zombie2 = g_day_zombie
  166.  
  167. fwd_zombie_create = CreateMultiForward("zmai_zombie_create", ET_IGNORE, FP_CELL)
  168.  
  169. set_cvar_string("sv_skyname", SKYNAME)
  170.  
  171. set_cvar_num("sv_skycolor_r", 0)
  172. set_cvar_num("sv_skycolor_g", 0)
  173. set_cvar_num("sv_skycolor_b", 0)
  174.  
  175. set_task(2.0, "set_light", TASK_LIGHT, _, _, "b")
  176. }
  177.  
  178.  
  179. public plugin_precache()
  180. {
  181. g_class_health = ArrayCreate(1, 1)
  182. g_class_speed = ArrayCreate(1, 1)
  183. g_class_model = ArrayCreate(64, 1)
  184. g_class_modelindex = ArrayCreate(1, 1)
  185.  
  186. engfunc(EngFunc_PrecacheModel, ammobox_model)
  187. precache_sound(ammobox_reload_sound)
  188.  
  189. m_iBlood[0] = precache_model("sprites/blood.spr")
  190. m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  191. ammobox_id = precache_model(ammobox_spr)
  192.  
  193. static i, string[100]
  194.  
  195. for (i = 0; i < ArraySize(g_class_model); i++)
  196. {
  197. ArrayGetString(g_class_model, i, string, charsmax(string))
  198. engfunc(EngFunc_PrecacheModel, string)
  199. }
  200. for(i = 0; i < sizeof(sound_start); i++)
  201. engfunc(EngFunc_PrecacheSound, sound_start[i])
  202. for(i = 0; i < sizeof(sound_end); i++)
  203. engfunc(EngFunc_PrecacheSound, sound_end[i])
  204. for(i = 0; i < sizeof(sound_die); i++)
  205. engfunc(EngFunc_PrecacheSound, sound_die[i])
  206. for(i = 0; i < sizeof(sound_attack); i++)
  207. engfunc(EngFunc_PrecacheSound, sound_attack[i])
  208. for(i = 0; i < sizeof(sound_pain); i++)
  209. engfunc(EngFunc_PrecacheSound, sound_pain[i])
  210. for(i = 0; i < sizeof(round_sound); i++)
  211. engfunc(EngFunc_PrecacheSound, round_sound[i])
  212.  
  213. load_spawn_points()
  214. load_ammobox_spawns()
  215.  
  216. // Prevent some entities from spawning
  217. g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
  218. }
  219.  
  220. public plugin_natives()
  221. {
  222. register_native("zmai_register_class", "native_register_class", 1)
  223. register_native("zmai_is_zombie", "native_is_zombie", 1)
  224. register_native("zmai_is_valid_zombie", "native_is_valid_zombie", 1)
  225. register_native("zmai_get_class", "native_get_class", 1)
  226. register_native("zmai_set_think", "native_set_think", 1)
  227. register_native("zmai_set_zombie_count", "native_set_zb_count", 1)
  228. register_native("zmai_get_zombie_count", "native_get_zb_count", 1)
  229. register_native("zmai_get_current_target", "native_get_target", 1)
  230. }
  231.  
  232. public fw_Spawn(entity)
  233. {
  234. // Invalid entity
  235. if (!pev_valid(entity)) return FMRES_IGNORED;
  236.  
  237. // Get classname
  238. new classname[32]
  239. pev(entity, pev_classname, classname, charsmax(classname))
  240.  
  241. // Check whether it needs to be removed
  242. for (new i = 0; i < sizeof(g_remove_entities); i++)
  243. {
  244. if (equal(classname, g_remove_entities[i]))
  245. {
  246. engfunc(EngFunc_RemoveEntity, entity)
  247. return FMRES_SUPERCEDE;
  248. }
  249. }
  250.  
  251. return FMRES_IGNORED;
  252. }
  253.  
  254. public client_putinserver(id)
  255. {
  256. set_task(0.2, "show_hud", id+TASK_HUD, _, _, "b")
  257. }
  258.  
  259. public set_light()
  260. {
  261. set_lights(LIGHT)
  262. }
  263.  
  264. public event_newround(id)
  265. {
  266. //set_lights("f")
  267. balance_teams()
  268.  
  269. remove_entity_name(ZB_CLASSNAME)
  270. remove_entity_name("temp_zb")
  271.  
  272. if(task_exists(TASK_ATTACK)) remove_task(TASK_ATTACK)
  273. if(task_exists(TASK_APPEAR)) remove_task(TASK_APPEAR)
  274. if(task_exists(TASK_CREATE)) remove_task(TASK_CREATE)
  275. if(task_exists(TASK_SHOWAMMO)) remove_task(TASK_SHOWAMMO)
  276.  
  277. remove_entity_name(AMMOBOX_CLASSNAME)
  278. set_task(0.1, "create_ammobox")
  279.  
  280. if(g_fail == 0)
  281. {
  282. if(g_day >= MAX_DAY)
  283. {
  284. g_day = 0
  285. } else {
  286. g_day++
  287.  
  288. //if(g_day == MAX_DAY)
  289. //is_boss_round = 1
  290. }
  291. }
  292.  
  293. g_day_zombie = g_zombie_count[g_day]
  294. g_current_zombie = g_day_zombie
  295. g_current_zombie2 = g_day_zombie
  296.  
  297. set_task(3.0, "zombie_appear", TASK_APPEAR)
  298. }
  299.  
  300. public fw_spawn(id)
  301. {
  302. if(is_user_connected(id))
  303. {
  304. set_task(0.1, "set_ammo", id)
  305. }
  306. }
  307.  
  308. public set_ammo(id)
  309. {
  310. cs_set_user_bpammo(id, get_user_weapon(id), 300)
  311. cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM)
  312. }
  313.  
  314. public event_round_end(id)
  315. {
  316. if(task_exists(TASK_ATTACK)) remove_task(TASK_ATTACK)
  317. if(task_exists(TASK_APPEAR)) remove_task(TASK_APPEAR)
  318. if(task_exists(TASK_CREATE)) remove_task(TASK_CREATE)
  319. if(task_exists(TASK_ROUND_SOUND)) remove_task(TASK_ROUND_SOUND)
  320.  
  321. if(get_player_alive() >= 1)
  322. {
  323. for(new i = 0; i < g_zombie_count[g_day]; i++)
  324. {
  325. new ent = find_ent_by_class(-1, ZB_CLASSNAME)
  326.  
  327. if(is_valid_ent(ent))
  328. kill_zombie(ent)
  329. }
  330.  
  331. g_fail = 0
  332.  
  333.  
  334. }
  335.  
  336. else {
  337. for(new i = 0; i < g_zombie_count[g_day]; i++)
  338. {
  339. new ent = find_ent_by_class(-1, ZB_CLASSNAME)
  340.  
  341. if(is_valid_ent(ent))
  342. native_set_think(ent, 0)
  343. }
  344.  
  345. g_fail = 1
  346.  
  347.  
  348. }
  349. }
  350.  
  351. public create_ammobox()
  352. {
  353. new Float:Origin[3]
  354. collect_spawn_box(Origin)
  355.  
  356. new ent = create_entity("info_target")
  357.  
  358. Origin[2] -= 35.0
  359. entity_set_origin(ent, Origin)
  360.  
  361. entity_set_string(ent, EV_SZ_classname, AMMOBOX_CLASSNAME)
  362. entity_set_model(ent, ammobox_model)
  363. entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
  364.  
  365. new Float:maxs[3] = {30.0, 30.0, 30.0}
  366. new Float:mins[3] = {-30.0, -30.0, -30.0}
  367. entity_set_size(ent, mins, maxs)
  368.  
  369. set_task(0.25, "task_show_ammo_spr", TASK_SHOWAMMO, _, _, "b")
  370.  
  371. drop_to_floor(ent)
  372. }
  373.  
  374. public task_show_ammo_spr()
  375. {
  376. static ent, Float:Origin[3]
  377.  
  378. ent = find_ent_by_class(-1, AMMOBOX_CLASSNAME)
  379. pev(ent, pev_origin, Origin)
  380.  
  381. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  382. write_byte(TE_SPRITE)
  383. engfunc(EngFunc_WriteCoord, Origin[0])
  384. engfunc(EngFunc_WriteCoord, Origin[1])
  385. engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
  386. write_short(ammobox_id)
  387. write_byte(2)
  388. write_byte(186)
  389. message_end()
  390. }
  391.  
  392. public zombie_appear()
  393. {
  394. if(!is_boss_round)
  395. {
  396. PlaySound(sound_start[random_num(0, charsmax(sound_start))])
  397. client_print(0, print_center, "%i. kör", g_day)
  398.  
  399. set_task(random_float(0.1, 2.5), "make_zombie", TASK_CREATE, _, _, "b")
  400. } else {
  401. client_print(0, print_center, "Utolsó kör!", g_day)
  402. }
  403.  
  404. set_task(10.0, "start_round_sound", TASK_ROUND_SOUND)
  405. }
  406.  
  407. public start_round_sound()
  408. {
  409. PlaySound(round_sound[random_num(0, charsmax(round_sound))])
  410. }
  411.  
  412. public make_zombie()
  413. {
  414. if(g_current_zombie2 > 0)
  415. {
  416. if(get_zombie_alive() < 7)
  417. {
  418. g_current_zombie2--
  419. create_zombie()
  420. }
  421. } else {
  422. remove_task(TASK_CREATE)
  423. }
  424. }
  425.  
  426. public event_roundstart(id)
  427. {
  428. //set_task(5.0, "create_zombie", _, _, _, "b")
  429. }
  430.  
  431. public create_zombie()
  432. {
  433. new ent = create_entity("info_target")
  434. new Float:Origin[3], Float:health, model[64]
  435. collect_spawn(Origin)
  436.  
  437. g_class[ent] = random(g_total_class)
  438. health = ArrayGetCell(g_class_health, g_class[ent])
  439.  
  440. health *= g_health_multi[g_day]
  441.  
  442. ArrayGetString(g_class_model, g_class[ent], model, sizeof(model))
  443.  
  444. dllfunc(DLLFunc_Spawn, ent)
  445. entity_set_origin(ent, Origin)
  446.  
  447. entity_set_float(ent, EV_FL_takedamage, 1.0)
  448. entity_set_float(ent, EV_FL_health, health)
  449.  
  450. entity_set_string(ent, EV_SZ_classname, ZB_CLASSNAME)
  451. entity_set_model(ent, model)
  452. entity_set_int(ent, EV_INT_solid, SOLID_SLIDEBOX)
  453.  
  454. static modelindex
  455. modelindex = ArrayGetCell(g_class_modelindex, g_class[ent])
  456. set_pev(ent, pev_modelindex, modelindex)
  457.  
  458. entity_set_int(ent, EV_INT_movetype, MOVETYPE_STEP)
  459.  
  460. set_pev(ent, pev_victim, 0)
  461.  
  462. new Float:VEC_HULL_MIN[3] = { -16.0, -16.0, -40.0 }
  463. new Float:VEC_HULL_MAX[3] = { 16.0, 16.0, 72.0}
  464. entity_set_size(ent, VEC_HULL_MIN, VEC_HULL_MAX)
  465.  
  466. play_anim(ent, ANIM_IDLE, 1.0)
  467.  
  468. set_task(1.0, "start_attack", ent)
  469. //drop_to_floor(ent)
  470.  
  471. if(!g_reg)
  472. {
  473. RegisterHamFromEntity(Ham_TakeDamage, ent, "fw_zb_takedmg")
  474. RegisterHamFromEntity(Ham_Killed, ent, "fw_zb_killed")
  475. g_reg = true
  476. }
  477.  
  478. g_think[ent] = 1
  479. g_zombie[ent] = 1
  480.  
  481. static g_fwDummyResult
  482. ExecuteForward(fwd_zombie_create, g_fwDummyResult, ent)
  483.  
  484. return 1
  485. }
  486.  
  487. public start_attack(ent)
  488. {
  489. if(is_valid_ent(ent))
  490. entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.01)
  491. }
  492.  
  493. public fw_takedamage(victim, inflictor, attacker, Float:damage, damagebits)
  494. {
  495. if((get_user_team(victim) == 1) || (get_user_team(victim) == 2))
  496. return HAM_SUPERCEDE
  497.  
  498. return HAM_HANDLED
  499. }
  500.  
  501. public fw_zb_takedmg(victim, inflictor, attacker, Float:damage, damagebits)
  502. {
  503. emit_sound(victim, CHAN_BODY, sound_pain[random_num(0, charsmax(sound_pain))], 1.0, ATTN_NORM, 0, PITCH_NORM)
  504.  
  505. static Float:Origin[3]
  506. pev(victim, pev_origin, Origin)
  507.  
  508. create_blood(Origin)
  509. }
  510.  
  511. public fw_zb_killed(ent2, attacker)
  512. {
  513. g_current_zombie--
  514. emit_sound(ent2, CHAN_BODY, sound_die[random_num(0, charsmax(sound_die))], 1.0, ATTN_NORM, 0, PITCH_NORM)
  515.  
  516. static ent
  517. ent = create_entity("info_target")
  518. static Float:Origin[3], Float:Angles[3], Model[64]
  519.  
  520. pev(ent2, pev_origin, Origin)
  521. pev(ent2, pev_angles, Angles)
  522. ArrayGetString(g_class_model, g_class[ent2], Model, sizeof(Model))
  523.  
  524. entity_set_origin(ent, Origin)
  525. entity_set_vector(ent, EV_VEC_angles, Angles)
  526.  
  527. entity_set_string(ent, EV_SZ_classname, "temp_zb")
  528. entity_set_model(ent, Model)
  529.  
  530. drop_to_floor(ent)
  531.  
  532. play_anim(ent, ANIM_DIE, 1.0)
  533.  
  534. set_task(3.0, "remove_temp_zb", ent)
  535.  
  536. if(g_current_zombie == 0)
  537. {
  538. TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Ct)
  539. }
  540.  
  541. if(0 < attacker < 32)
  542. {
  543. if(cs_get_user_money(attacker) < 16000)
  544. {
  545. cs_set_user_money(attacker, cs_get_user_money(attacker) + 200)
  546. }
  547.  
  548. client_print(attacker, print_center, "Halál!")
  549. }
  550. }
  551.  
  552. public fw_cmdstart(id, uc_handle, seed)
  553. {
  554. static Button
  555. Button = get_uc(uc_handle, UC_Buttons)
  556.  
  557. if(Button & IN_USE)
  558. {
  559. static Ent, Float:Range
  560. Ent = find_ent_by_class(-1, AMMOBOX_CLASSNAME)
  561.  
  562. if(!is_valid_ent(Ent))
  563. return FMRES_IGNORED
  564.  
  565. static Weapon
  566. Weapon = get_user_weapon(id)
  567.  
  568. if(Weapon == CSW_KNIFE || Weapon == CSW_C4 || Weapon == CSW_FLASHBANG ||
  569. Weapon == CSW_HEGRENADE || Weapon == CSW_SMOKEGRENADE)
  570. return FMRES_IGNORED
  571.  
  572.  
  573. Range = entity_range(Ent, id)
  574. if(Range <= 70.0)
  575. {
  576. if(cs_get_user_bpammo(id, get_user_weapon(id)) < 200)
  577. {
  578. if(!in_reloading_ammobox[id])
  579. {
  580. in_reloading_ammobox[id] = 1
  581.  
  582. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), _, id)
  583. write_short(1)
  584. message_end()
  585.  
  586. set_task(1.0, "reload_ammo", id+TASK_AMMO)
  587.  
  588. emit_sound(id, CHAN_BODY, ammobox_reload_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  589. }
  590. }
  591. } else {
  592. if(in_reloading_ammobox[id])
  593. {
  594. in_reloading_ammobox[id] = 0
  595.  
  596. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), _, id)
  597. write_short(0)
  598. message_end()
  599.  
  600. if(task_exists(id+TASK_AMMO)) remove_task(id+TASK_AMMO)
  601. }
  602. }
  603. } else {
  604. if(pev(id, pev_oldbuttons) & IN_USE)
  605. {
  606. if(in_reloading_ammobox[id])
  607. {
  608. in_reloading_ammobox[id] = 0
  609.  
  610. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), _, id)
  611. write_short(0)
  612. message_end()
  613.  
  614. if(task_exists(id+TASK_AMMO)) remove_task(id+TASK_AMMO)
  615. }
  616. }
  617. }
  618.  
  619. return FMRES_HANDLED
  620. }
  621.  
  622. public reload_ammo(id)
  623. {
  624. id -= TASK_AMMO
  625.  
  626. client_print(id, print_center, "Újratöltve - 100% ammo")
  627. in_reloading_ammobox[id] = 0
  628.  
  629. cs_set_user_bpammo(id, get_user_weapon(id),200 )
  630. }
  631.  
  632. public kill_zombie(ent2)
  633. {
  634. emit_sound(ent2, CHAN_BODY, sound_die[random_num(0, charsmax(sound_die))], 1.0, ATTN_NORM, 0, PITCH_NORM)
  635.  
  636. static ent
  637. ent = create_entity("info_target")
  638. static Float:Origin[3], Float:Angles[3], Model[64]
  639.  
  640. ArrayGetString(g_class_model, g_class[ent2], Model, sizeof(Model))
  641.  
  642. pev(ent2, pev_origin, Origin)
  643. pev(ent2, pev_angles, Angles)
  644.  
  645. entity_set_origin(ent, Origin)
  646. entity_set_vector(ent, EV_VEC_angles, Angles)
  647.  
  648. entity_set_string(ent, EV_SZ_classname, "temp_zb")
  649. entity_set_model(ent, Model)
  650.  
  651. //drop_to_floor(ent)
  652.  
  653. play_anim(ent, ANIM_DIE, 1.0)
  654.  
  655. set_task(3.0, "remove_temp_zb", ent)
  656. }
  657.  
  658. public remove_temp_zb(ent)
  659. {
  660. remove_entity(ent)
  661. }
  662.  
  663. public fw_zb_think(ent)
  664. {
  665. if(!is_valid_ent(ent))
  666. return FMRES_IGNORED
  667.  
  668. if(g_think[ent])
  669. {
  670. static victim
  671. static Float:Origin[3], Float:VicOrigin[3], Float:distance
  672.  
  673. victim = FindClosesEnemy(ent)
  674. pev(ent, pev_origin, Origin)
  675. pev(victim, pev_origin, VicOrigin)
  676.  
  677. distance = get_distance_f(Origin, VicOrigin)
  678.  
  679. if(is_user_alive(victim))
  680. {
  681. if(distance <= 60.0)
  682. {
  683. if(!is_valid_ent(ent))
  684. return FMRES_IGNORED
  685.  
  686. new Float:Ent_Origin[3], Float:Vic_Origin[3]
  687.  
  688. pev(ent, pev_origin, Ent_Origin)
  689. pev(victim, pev_origin, Vic_Origin)
  690.  
  691. npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin)
  692.  
  693. zombie_attack(ent, victim)
  694. entity_set_float(ent, EV_FL_nextthink, get_gametime() + 2.5)
  695. } else {
  696.  
  697. if(get_anim(ent) != ANIM_WALK)
  698. play_anim(ent, ANIM_WALK, 1.0)
  699.  
  700. new Float:Ent_Origin[3], Float:Vic_Origin[3]
  701.  
  702. pev(ent, pev_origin, Ent_Origin)
  703. pev(victim, pev_origin, Vic_Origin)
  704.  
  705. npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin)
  706. hook_ent(ent, victim)
  707.  
  708. entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.5)
  709. }
  710.  
  711. current_target[ent] = victim
  712. } else {
  713. //hook_ent(ent, ent)
  714.  
  715. if(get_anim(ent) != ANIM_IDLE)
  716. play_anim(ent, ANIM_IDLE, 1.0)
  717.  
  718. entity_set_float(ent, EV_FL_nextthink, get_gametime() + 1.0)
  719. }
  720. } else {
  721. if(get_anim(ent) != ANIM_IDLE)
  722. play_anim(ent, ANIM_IDLE, 1.0)
  723.  
  724. entity_set_float(ent, EV_FL_nextthink, get_gametime() + 1.0)
  725. }
  726.  
  727. return FMRES_HANDLED
  728. }
  729.  
  730. public zombie_attack(ent, victim)
  731. {
  732. play_anim(ent, ANIM_ATTACK, 1.0)
  733.  
  734. emit_sound(victim, CHAN_BODY, sound_attack[random_num(0, charsmax(sound_attack))], 1.0, ATTN_NORM, 0, PITCH_NORM)
  735. ExecuteHam(Ham_TakeDamage, victim, 0, victim, random_float(15.0, 30.0), DMG_BULLET)
  736.  
  737. remove_task(ent+TASK_ATTACK)
  738. set_task(1.5, "stop_attack", ent+TASK_ATTACK)
  739. }
  740.  
  741. public stop_attack(ent)
  742. {
  743. ent -= TASK_ATTACK
  744.  
  745. play_anim(ent, ANIM_IDLE, 1.0)
  746. remove_task(ent+TASK_ATTACK)
  747. }
  748.  
  749. public npc_turntotarget(ent, Float:Ent_Origin[3], target, Float:Vic_Origin[3])
  750. {
  751. if(target)
  752. {
  753. new Float:newAngle[3]
  754. entity_get_vector(ent, EV_VEC_angles, newAngle)
  755. new Float:x = Vic_Origin[0] - Ent_Origin[0]
  756. new Float:z = Vic_Origin[1] - Ent_Origin[1]
  757.  
  758. new Float:radians = floatatan(z/x, radian)
  759. newAngle[1] = radians * (180 / 3.14)
  760. if (Vic_Origin[0] < Ent_Origin[0])
  761. newAngle[1] -= 180.0
  762.  
  763. entity_set_vector(ent, EV_VEC_angles, newAngle)
  764. }
  765. }
  766.  
  767. public hook_ent(ent, victim)
  768. {
  769. static Float:fl_Velocity[3]
  770. static Float:VicOrigin[3], Float:EntOrigin[3]
  771. static Float:Speed
  772.  
  773. pev(ent, pev_origin, EntOrigin)
  774. pev(victim, pev_origin, VicOrigin)
  775. Speed = ArrayGetCell(g_class_speed, g_class[ent])
  776.  
  777. static Float:distance_f
  778. distance_f = get_distance_f(EntOrigin, VicOrigin)
  779.  
  780. if (distance_f > 60.0)
  781. {
  782. new Float:fl_Time = distance_f / Speed
  783.  
  784. fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
  785. fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
  786. fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
  787. } else
  788. {
  789. fl_Velocity[0] = 0.0
  790. fl_Velocity[1] = 0.0
  791. fl_Velocity[2] = 0.0
  792. }
  793.  
  794. entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
  795. }
  796.  
  797. public round_end()
  798. {
  799. client_cmd(0, "stopsound")
  800. PlaySound(sound_end[random_num(0, charsmax(sound_end))])
  801.  
  802. return PLUGIN_HANDLED
  803. }
  804.  
  805. public hook_textmsg()
  806. {
  807. new szMsg[22]
  808. get_msg_arg_string(2, szMsg, sizeof szMsg)
  809.  
  810. if(get_player_alive() >= 1)
  811. {
  812. if(equal(szMsg, "#Terrorists_Win"))
  813. set_msg_arg_string(2, "Gyözelem!")
  814. else if(equal(szMsg, "#CTs_Win"))
  815. set_msg_arg_string(2 , "Gyözelem")
  816. else if(equal(szMsg, "#Round_Draw"))
  817. set_msg_arg_string(2 , "Gyözelem")
  818.  
  819. g_fail = 0
  820. } else {
  821. if(equal(szMsg, "#Terrorists_Win"))
  822. set_msg_arg_string(2, "Sikertelen küldetés!")
  823. else if(equal(szMsg, "#CTs_Win"))
  824. set_msg_arg_string(2 , "Sikertelen küldetés!")
  825. else if(equal(szMsg, "#Round_Draw"))
  826. set_msg_arg_string(2 , "Sikertelen küldetés!")
  827.  
  828. g_fail = 1
  829. }
  830. }
  831.  
  832. // Transfer Player Team
  833. public balance_teams()
  834. {
  835. static iPlayersnum
  836. iPlayersnum = get_playersnum()
  837.  
  838. if (iPlayersnum < 1) return;
  839.  
  840. static iTerrors, iMaxTerrors, id
  841. iMaxTerrors = iPlayersnum/2
  842. iTerrors = 0
  843.  
  844. for (id = 1; id <= get_maxplayers(); id++)
  845. {
  846. if (!is_user_connected(id))
  847. continue;
  848.  
  849. if (cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
  850. continue;
  851.  
  852. cs_set_user_team(id, CS_TEAM_CT)
  853. }
  854.  
  855. while (iTerrors < iMaxTerrors)
  856. {
  857. if (++id > get_maxplayers()) id = 1
  858.  
  859. if (!is_user_connected(id))
  860. continue;
  861.  
  862. if (cs_get_user_team(id) != CS_TEAM_CT)
  863. continue;
  864.  
  865. if (random_num(0, 1))
  866. {
  867. cs_set_user_team(id, CS_TEAM_T)
  868. iTerrors++
  869. }
  870. }
  871. }
  872.  
  873. stock bool:IsValidTarget(iTarget)
  874. {
  875. if (!iTarget || !(1<= iTarget <= get_maxplayers()) || !is_user_connected(iTarget) || !is_user_alive(iTarget))
  876. return false
  877. return true
  878. }
  879.  
  880. public FindClosesEnemy(entid)
  881. {
  882. new Float:Dist
  883. new Float:maxdistance=4000.0
  884. new indexid=0
  885. for(new i=1;i<=get_maxplayers();i++){
  886. if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i))
  887. {
  888. Dist = entity_range(entid, i)
  889. if(Dist <= maxdistance)
  890. {
  891. maxdistance=Dist
  892. indexid=i
  893.  
  894. return indexid
  895. }
  896. }
  897. }
  898. return 0
  899. }
  900.  
  901. public bool:can_see_fm(entindex1, entindex2)
  902. {
  903. if (!entindex1 || !entindex2)
  904. return false
  905.  
  906. if (pev_valid(entindex1) && pev_valid(entindex1))
  907. {
  908. new flags = pev(entindex1, pev_flags)
  909. if (flags & EF_NODRAW || flags & FL_NOTARGET)
  910. {
  911. return false
  912. }
  913.  
  914. new Float:lookerOrig[3]
  915. new Float:targetBaseOrig[3]
  916. new Float:targetOrig[3]
  917. new Float:temp[3]
  918.  
  919. pev(entindex1, pev_origin, lookerOrig)
  920. pev(entindex1, pev_view_ofs, temp)
  921. lookerOrig[0] += temp[0]
  922. lookerOrig[1] += temp[1]
  923. lookerOrig[2] += temp[2]
  924.  
  925. pev(entindex2, pev_origin, targetBaseOrig)
  926. pev(entindex2, pev_view_ofs, temp)
  927. targetOrig[0] = targetBaseOrig [0] + temp[0]
  928. targetOrig[1] = targetBaseOrig [1] + temp[1]
  929. targetOrig[2] = targetBaseOrig [2] + temp[2]
  930.  
  931. engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the had of seen player
  932. if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
  933. {
  934. return false
  935. }
  936. else
  937. {
  938. new Float:flFraction
  939. get_tr2(0, TraceResult:TR_flFraction, flFraction)
  940. if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
  941. {
  942. return true
  943. }
  944. else
  945. {
  946. targetOrig[0] = targetBaseOrig [0]
  947. targetOrig[1] = targetBaseOrig [1]
  948. targetOrig[2] = targetBaseOrig [2]
  949. engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the body of seen player
  950. get_tr2(0, TraceResult:TR_flFraction, flFraction)
  951. if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
  952. {
  953. return true
  954. }
  955. else
  956. {
  957. targetOrig[0] = targetBaseOrig [0]
  958. targetOrig[1] = targetBaseOrig [1]
  959. targetOrig[2] = targetBaseOrig [2] - 17.0
  960. engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the legs of seen player
  961. get_tr2(0, TraceResult:TR_flFraction, flFraction)
  962. if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
  963. {
  964. return true
  965. }
  966. }
  967. }
  968. }
  969. }
  970. return false
  971. }
  972.  
  973. stock get_anim(id)
  974. {
  975. if(is_valid_ent(id))
  976. {
  977. return pev(id, pev_sequence)
  978. }
  979.  
  980. return PLUGIN_HANDLED
  981. }
  982.  
  983. stock play_anim(index, sequence, Float:framerate = 1.0)
  984. {
  985. if(is_valid_ent(index))
  986. {
  987. entity_set_float(index, EV_FL_animtime, get_gametime())
  988. entity_set_float(index, EV_FL_framerate, framerate)
  989. entity_set_float(index, EV_FL_frame, 0.0)
  990. entity_set_int(index, EV_INT_sequence, sequence)
  991. }
  992. }
  993.  
  994. public create_blood(const Float:origin[3])
  995. {
  996. // Show some blood <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"mosoly\" /><!-- s:) -->
  997. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  998. write_byte(TE_BLOODSPRITE)
  999. engfunc(EngFunc_WriteCoord, origin[0])
  1000. engfunc(EngFunc_WriteCoord, origin[1])
  1001. engfunc(EngFunc_WriteCoord, origin[2])
  1002. write_short(m_iBlood[1])
  1003. write_short(m_iBlood[0])
  1004. write_byte(75)
  1005. write_byte(5)
  1006. message_end()
  1007. }
  1008.  
  1009. stock collect_spawn_box(Float:origin[3])
  1010. {
  1011. for (new i=1; i<=g_total_boxs*3; i++)
  1012. {
  1013. origin = g_boxs[random(g_total_boxs)]
  1014. if (check_spawn_box(origin)) return 1;
  1015. }
  1016.  
  1017. return 0;
  1018. }
  1019. stock check_spawn_box(Float:origin[3])
  1020. {
  1021. new Float:originE[3], Float:origin1[3], Float:origin2[3]
  1022. new ent = -1
  1023. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "ammobox")) != 0)
  1024. {
  1025. pev(ent, pev_origin, originE)
  1026.  
  1027. // xoy
  1028. origin1 = origin
  1029. origin2 = originE
  1030. origin1[2] = origin2[2] = 0.0
  1031. if (vector_distance(origin1, origin2)<=2*npc_size_width) return 0;
  1032. }
  1033. return 1;
  1034. }
  1035.  
  1036. stock collect_spawn(Float:origin[3])
  1037. {
  1038. for (new i=1; i<=g_total_spawns*3; i++)
  1039. {
  1040. origin = g_spawns[random(g_total_spawns)]
  1041. if (check_spawn(origin)) return 1;
  1042. }
  1043.  
  1044. return 0;
  1045. }
  1046.  
  1047. stock check_spawn(Float:origin[3])
  1048. {
  1049. new Float:originE[3], Float:origin1[3], Float:origin2[3]
  1050. new ent = -1
  1051. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", ZB_CLASSNAME)) != 0)
  1052. {
  1053. pev(ent, pev_origin, originE)
  1054.  
  1055. // xoy
  1056. origin1 = origin
  1057. origin2 = originE
  1058. origin1[2] = origin2[2] = 0.0
  1059. if (vector_distance(origin1, origin2)<=2*npc_size_width)
  1060. {
  1061. // oz
  1062. origin1 = origin
  1063. origin2 = originE
  1064. origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0
  1065. if (vector_distance(origin1, origin2)<=npc_size_height) return 0;
  1066. }
  1067. }
  1068. return 1;
  1069. }
  1070.  
  1071. stock str_count(const str[], searchchar)
  1072. {
  1073. new count, i, len = strlen(str)
  1074.  
  1075. for (i = 0; i <= len; i++)
  1076. {
  1077. if(str[i] == searchchar)
  1078. count++
  1079. }
  1080.  
  1081. return count;
  1082. }
  1083.  
  1084. // load spawn points
  1085. load_spawn_points()
  1086. {
  1087. // Check for spawns points of the current map
  1088. new cfgdir[32], mapname[32], filepath[100], linedata[64]
  1089. get_configsdir(cfgdir, charsmax(cfgdir))
  1090. get_mapname(mapname, charsmax(mapname))
  1091. formatex(filepath, charsmax(filepath), SPAWNS_FILE, cfgdir, mapname)
  1092.  
  1093. // Load spawns points
  1094. if (file_exists(filepath))
  1095. {
  1096. new file = fopen(filepath,"rt"), row[4][6], boss
  1097.  
  1098. while (file && !feof(file))
  1099. {
  1100. fgets(file, linedata, charsmax(linedata))
  1101.  
  1102. // invalid spawn
  1103. if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  1104.  
  1105. // get spawn point data
  1106. parse(linedata,row[0],5,row[1],5,row[2],5,row[3],5)
  1107.  
  1108. // origin
  1109. boss = str_to_num(row[0])
  1110. if (boss && g_total_spawns_boss<MAX_SPAWNS)
  1111. {
  1112. g_spawns_boss[g_total_spawns_boss][0] = floatstr(row[1])
  1113. g_spawns_boss[g_total_spawns_boss][1] = floatstr(row[2])
  1114. g_spawns_boss[g_total_spawns_boss][2] = floatstr(row[3])
  1115. g_total_spawns_boss++
  1116. }
  1117. else if (g_total_spawns<MAX_SPAWNS)
  1118. {
  1119. g_spawns[g_total_spawns][0] = floatstr(row[1])
  1120. g_spawns[g_total_spawns][1] = floatstr(row[2])
  1121. g_spawns[g_total_spawns][2] = floatstr(row[3])
  1122. g_total_spawns++
  1123. }
  1124. }
  1125. if (file) fclose(file)
  1126. }
  1127. }
  1128.  
  1129. // load spawn points
  1130. load_ammobox_spawns()
  1131. {
  1132. // Check for spawns points of the current map
  1133. new cfgdir[32], mapname[32], filepath[100], linedata[64]
  1134. get_configsdir(cfgdir, charsmax(cfgdir))
  1135. get_mapname(mapname, charsmax(mapname))
  1136. formatex(filepath, charsmax(filepath), BOXS_FILE, cfgdir, mapname)
  1137.  
  1138. // Load spawns points
  1139. if (file_exists(filepath))
  1140. {
  1141. new file = fopen(filepath,"rt"), row[4][6]
  1142.  
  1143. while (file && !feof(file))
  1144. {
  1145. fgets(file, linedata, charsmax(linedata))
  1146.  
  1147. // invalid spawn
  1148. if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  1149.  
  1150. // get spawn point data
  1151. parse(linedata,row[0],5,row[1],5,row[2],5)
  1152.  
  1153. // origin
  1154. g_boxs[g_total_boxs][0] = floatstr(row[0])
  1155. g_boxs[g_total_boxs][1] = floatstr(row[1])
  1156. g_boxs[g_total_boxs][2] = floatstr(row[2])
  1157.  
  1158. g_total_boxs++
  1159. if (g_total_boxs>=MAX_SPAWNS) break;
  1160. }
  1161. if (file) fclose(file)
  1162. }
  1163. }
  1164.  
  1165. public get_player_alive()
  1166. {
  1167. static iAlive, id
  1168. iAlive = 0
  1169.  
  1170. for (id = 1; id <= get_maxplayers(); id++)
  1171. {
  1172. if (is_user_alive(id))
  1173. iAlive++
  1174. }
  1175.  
  1176. return iAlive;
  1177. }
  1178.  
  1179. public get_zombie_alive()
  1180. {
  1181. static iAlive, i
  1182. iAlive = 0
  1183.  
  1184. static classname[32]
  1185.  
  1186. for (i = 1; i <= entity_count(); i++)
  1187. {
  1188. if(is_valid_ent(i))
  1189. {
  1190. pev(i, pev_classname, classname, sizeof(classname))
  1191. if(equal(classname, ZB_CLASSNAME))
  1192. iAlive++
  1193. }
  1194. }
  1195.  
  1196. return iAlive;
  1197. }
  1198.  
  1199. // Plays a sound on clients
  1200. public PlaySound(const sound[])
  1201. {
  1202. client_cmd(0, "spk ^"%s^"", sound)
  1203. }
  1204.  
  1205. public native_register_class(const Float:Health, const Float:Speed, const Model[], const modelindex)
  1206. {
  1207. param_convert(3)
  1208.  
  1209. ArrayPushCell(g_class_health, Health)
  1210. ArrayPushCell(g_class_speed, Speed)
  1211. ArrayPushString(g_class_model, Model)
  1212. ArrayPushCell(g_class_modelindex, modelindex)
  1213.  
  1214. g_total_class++
  1215.  
  1216. return g_total_class - 1
  1217. }
  1218.  
  1219. public native_is_zombie(id)
  1220. {
  1221. return g_zombie[id]
  1222. }
  1223.  
  1224. public native_get_class(id)
  1225. {
  1226. return g_class[id]
  1227. }
  1228.  
  1229. public native_set_think(id, think)
  1230. {
  1231. g_think[id] = think
  1232. }
  1233.  
  1234. public native_set_zb_count(count)
  1235. {
  1236. g_current_zombie = count
  1237.  
  1238. if(g_current_zombie == 0)
  1239. {
  1240. TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Ct)
  1241. }
  1242. }
  1243.  
  1244. public native_get_zb_count()
  1245. {
  1246. return g_current_zombie
  1247. }
  1248.  
  1249. public native_is_valid_zombie(ent)
  1250. {
  1251. return is_valid_ent(ent)
  1252. }
  1253.  
  1254. public native_get_target(ent)
  1255. {
  1256. return current_target[ent]
  1257. }
  1258. stock print_color(const id, const input[], any:...)
  1259. {
  1260. new count = 1, players[32]
  1261. static msg[191]
  1262. vformat(msg, 190, input, 3)
  1263.  
  1264. replace_all(msg, 190, "!w", "^0")
  1265. replace_all(msg, 190, "!g", "^4")
  1266. replace_all(msg, 190, "!y", "^1")
  1267. replace_all(msg, 190, "!t", "^3")
  1268. replace_all(msg, 190, "á", "á")
  1269. replace_all(msg, 190, "é", "Ă©")
  1270. replace_all(msg, 190, "í", "Ă")
  1271. replace_all(msg, 190, "ó", "Ăł")
  1272. replace_all(msg, 190, "ö", "ö")
  1273. replace_all(msg, 190, "ő", "Ĺ‘")
  1274. replace_all(msg, 190, "ú", "Ăş")
  1275. replace_all(msg, 190, "ü", "ĂĽ")
  1276. replace_all(msg, 190, "ű", "ű")
  1277. replace_all(msg, 190, "Á", "Á")
  1278. replace_all(msg, 190, "É", "É")
  1279. replace_all(msg, 190, "Í", "ĂŤ")
  1280. replace_all(msg, 190, "Ó", "Ă“")
  1281. replace_all(msg, 190, "Ö", "Ă–")
  1282. replace_all(msg, 190, "Ő", "Ő")
  1283. replace_all(msg, 190, "Ú", "Ăš")
  1284. replace_all(msg, 190, "Ü", "Ăś")
  1285. replace_all(msg, 190, "Ű", "Ĺ°")
  1286.  
  1287. if (id) players[0] = id; else get_players(players, count, "ch")
  1288. {
  1289. for (new i = 0; i < count; i++)
  1290. {
  1291. if (is_user_connected(players[i]))
  1292.  


Köszönöm a segítségeteket.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: sv_restart 1 command
HozzászólásElküldve: 2013.11.13. 16:30 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.27. 09:42
Hozzászólások: 2588
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 418 alkalommal
tehát ha jól értem: mapváltáskor automatikusan nem indul el a plugin hanem kell 1 kör restart ahhoz, hogy elindúljon?

ha ez áll fent akkor próbáld meg így

Kód:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <round_terminator>
#include <fun>
#include <colorchat>
 
#define ZB_CLASSNAME "npc_zombie"
#define AMMOBOX_CLASSNAME "ammo_box"
 
#define TASK_ATTACK 323423
#define TASK_APPEAR 534534
#define TASK_CREATE 534332
#define TASK_HUD 967697
#define TASK_AMMO 5234234
#define TASK_SHOWAMMO 5345345
#define TASK_LIGHT 5343452
#define TASK_ROUND_SOUND 3234234
 
#define LIGHT "c"
#define SKYNAME "DrkG"
 
enum
{
   ANIM_IDLE = 0,
   ANIM_WALK = 1,
   ANIM_ATTACK = 2,
   ANIM_DIE = 3
}
 
new pev_victim = pev_enemy
new m_iBlood[2]
 
// spawns & way points
new const SPAWNS_FILE[] = "%s/zm_ai/sp_%s.cfg"
new const BOXS_FILE[] = "%s/zm_ai/box_%s.cfg"
const MAX_SPAWNS = 128
new Float:g_spawns[MAX_SPAWNS][3], g_total_spawns, Float:g_spawns_boss[MAX_SPAWNS][3], g_total_spawns_boss
new Float:npc_size_width = 16.0, Float:npc_size_height = 75.0
new Float:g_boxs[MAX_SPAWNS][3], g_total_boxs
 
#define MAX_DAY 12
new g_day
new const g_zombie_count[MAX_DAY + 1] = {
   20,
   30,
   40,
   50,
   60,
   70,
   80,
   90,
   100,
   110,
   120,
   200,
   300
}
 
new const g_remove_entities[][] =
{
   "func_bomb_target",   
   "info_bomb_target",
   "hostage_entity",     
   "monster_scientist",
   "func_hostage_rescue",
   "info_hostage_rescue",
   "info_vip_start",     
   "func_vip_safetyzone",
   "func_escapezone"
   //"func_buyzone"
}
 
new const Float:g_health_multi[MAX_DAY] = {
   1.0,
   1.2,
   1.4,
   1.6,
   1.8,
   2.0,
   2.2,
   2.4,
   2.6,
   2.8,
   3.0
}
 
new bool:g_reg
new g_day_zombie, g_current_zombie, g_current_zombie2
new sync_hud1//, sync_hud2
new g_fail, in_reloading_ammobox[33]
new is_boss_round, ammobox_id, fwd_zombie_create, g_fwSpawn
 
#define MAX_NPC 1000
new g_zombie[MAX_NPC], g_class[MAX_NPC], g_total_class, g_think[MAX_NPC]
new Array:g_class_health, Array:g_class_speed, Array:g_class_model, Array:g_class_modelindex
new current_target[MAX_NPC]
 
new const ammobox_spr[] = "sprites/zombie_mode_ai/ammo_box.spr"
new const ammobox_model[] = "models/zombie_mode_ai/ammo_box.mdl"
new const ammobox_reload_sound[] = "zombie_mode_ai/FullAmmo.wav"
new const sound_start[][] = {
   "zombie_mode_ai/AI_STAGE_START.WAV"
}
 
new const sound_end[][] = {
   "zombie_mode_ai/AI_STAGE_END.WAV"
}
 
new const sound_die[][] = {
   "zombie_mode_ai/NPC_DOWN1.WAV",
   "zombie_mode_ai/NPC_DOWN2.WAV",
   "zombie_mode_ai/2NANODEATH.WAV",
   "zombie_mode_ai/3NANODEATH.WAV"
}
 
new const sound_attack[][] = {
   "zombie_mode_ai/nano_attack_2.wav",
   "weapons/knife_hit4.wav",
   "zombie_mode_ai/zombi_attack_1.wav",
   "weapons/knife_hit2.wav"
}
 
new const sound_pain[][] = {
   "zombie_mode_ai/zombie_pain1.wav",
   "zombie_mode_ai/zombie_pain2.wav",
   "zombie_mode_ai/zombie_pain3.wav",
   "zombie_mode_ai/zombie_pain4.wav",
   "zombie_mode_ai/zombie_pain5.wav"
}
new const round_sound[][] = {
   "zombie_mode_ai/Daft_Punk-Recognizer.mp3"
}
 
public plugin_init()
{
   register_plugin("Zombie NPC", "1.0", "ZHR")
 
   register_event("HLTV", "event_newround", "a", "1=0", "2=0")
   register_logevent("event_roundstart", 2, "1=Round_Start")
   register_event("SendAudio", "round_end", "a", "2&%!MRAD_terwin")
   register_event("SendAudio", "round_end", "a", "2&%!MRAD_ctwin") 
   register_event("SendAudio", "round_end", "a", "2&%!MRAD_rounddraw")     
 
   register_logevent("event_round_end", 2, "1=Round_End")
   register_event("TextMsg","event_round_end","a","2=#Game_Commencing","2=#Game_will_restart_in")
 
   register_message(get_user_msgid("TextMsg"), "hook_textmsg")   
   register_think(ZB_CLASSNAME, "fw_zb_think")
   register_forward(FM_CmdStart, "fw_cmdstart")
   unregister_forward(FM_Spawn, g_fwSpawn)
   RegisterHam(Ham_Spawn, "player", "fw_spawn", 1)
   RegisterHam(Ham_TakeDamage, "player", "fw_takedamage")
 
   sync_hud1 = CreateHudSyncObj(5)
   //sync_hud2 = CreateHudSyncObj(6)
 
   g_day = 0
   g_day_zombie = g_zombie_count[g_day]
   g_current_zombie = g_day_zombie   
   g_current_zombie2 = g_day_zombie
 
   fwd_zombie_create = CreateMultiForward("zmai_zombie_create", ET_IGNORE, FP_CELL)
 
   set_cvar_string("sv_skyname", SKYNAME)
 
   set_cvar_num("sv_skycolor_r", 0)
   set_cvar_num("sv_skycolor_g", 0)
   set_cvar_num("sv_skycolor_b", 0)   
 
   set_task(2.0, "set_light", TASK_LIGHT, _, _, "b")
   server_cmd("sv_restart 1")
}
 
 
public plugin_precache()
{
   g_class_health = ArrayCreate(1, 1)
   g_class_speed = ArrayCreate(1, 1)
   g_class_model = ArrayCreate(64, 1)
   g_class_modelindex = ArrayCreate(1, 1)
 
   engfunc(EngFunc_PrecacheModel, ammobox_model)
   precache_sound(ammobox_reload_sound)
 
   m_iBlood[0] = precache_model("sprites/blood.spr")
   m_iBlood[1] = precache_model("sprites/bloodspray.spr")
   ammobox_id = precache_model(ammobox_spr)
 
   static i, string[100]
 
   for (i = 0; i < ArraySize(g_class_model); i++)
   {
      ArrayGetString(g_class_model, i, string, charsmax(string))
      engfunc(EngFunc_PrecacheModel, string)
   }
   for(i = 0; i < sizeof(sound_start); i++)
      engfunc(EngFunc_PrecacheSound, sound_start[i])
   for(i = 0; i < sizeof(sound_end); i++)
      engfunc(EngFunc_PrecacheSound, sound_end[i])   
   for(i = 0; i < sizeof(sound_die); i++)
      engfunc(EngFunc_PrecacheSound, sound_die[i])   
   for(i = 0; i < sizeof(sound_attack); i++)
      engfunc(EngFunc_PrecacheSound, sound_attack[i])   
   for(i = 0; i < sizeof(sound_pain); i++)
      engfunc(EngFunc_PrecacheSound, sound_pain[i])
   for(i = 0; i < sizeof(round_sound); i++)
      engfunc(EngFunc_PrecacheSound, round_sound[i])
 
   load_spawn_points()
   load_ammobox_spawns()
 
   // Prevent some entities from spawning
   g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")   
}
 
public plugin_natives()
{
   register_native("zmai_register_class", "native_register_class", 1)
   register_native("zmai_is_zombie", "native_is_zombie", 1)
   register_native("zmai_is_valid_zombie", "native_is_valid_zombie", 1)
   register_native("zmai_get_class", "native_get_class", 1)
   register_native("zmai_set_think", "native_set_think", 1)
   register_native("zmai_set_zombie_count", "native_set_zb_count", 1)
   register_native("zmai_get_zombie_count", "native_get_zb_count", 1)
   register_native("zmai_get_current_target", "native_get_target", 1)
}
 
public fw_Spawn(entity)
{
   // Invalid entity
   if (!pev_valid(entity)) return FMRES_IGNORED;
 
   // Get classname
   new classname[32]
   pev(entity, pev_classname, classname, charsmax(classname))
 
   // Check whether it needs to be removed
   for (new i = 0; i < sizeof(g_remove_entities); i++)
   {
      if (equal(classname, g_remove_entities[i]))
      {
         engfunc(EngFunc_RemoveEntity, entity)
         return FMRES_SUPERCEDE;
      }
   }
 
   return FMRES_IGNORED;
}
 
public client_putinserver(id)
{
   set_task(0.2, "show_hud", id+TASK_HUD, _, _, "b")
}
 
public set_light()
{
   set_lights(LIGHT)
}
 
public event_newround(id)
{
   //set_lights("f")
   balance_teams()
 
   remove_entity_name(ZB_CLASSNAME)
   remove_entity_name("temp_zb")
 
   if(task_exists(TASK_ATTACK)) remove_task(TASK_ATTACK)
   if(task_exists(TASK_APPEAR)) remove_task(TASK_APPEAR)
   if(task_exists(TASK_CREATE)) remove_task(TASK_CREATE)
   if(task_exists(TASK_SHOWAMMO)) remove_task(TASK_SHOWAMMO)
 
   remove_entity_name(AMMOBOX_CLASSNAME)
   set_task(0.1, "create_ammobox")
 
   if(g_fail == 0)
   {
      if(g_day >= MAX_DAY)
      {
         g_day = 0
      } else {
         g_day++
 
         //if(g_day == MAX_DAY)
            //is_boss_round = 1
      }      
   }
 
   g_day_zombie = g_zombie_count[g_day]
   g_current_zombie = g_day_zombie
   g_current_zombie2 = g_day_zombie
 
   set_task(3.0, "zombie_appear", TASK_APPEAR)
}
 
public fw_spawn(id)
{
   if(is_user_connected(id))
   {
      set_task(0.1, "set_ammo", id)
   }
}
 
public set_ammo(id)
{
   cs_set_user_bpammo(id, get_user_weapon(id), 300)
   cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM)
}
 
public event_round_end(id)
{
   if(task_exists(TASK_ATTACK)) remove_task(TASK_ATTACK)
   if(task_exists(TASK_APPEAR)) remove_task(TASK_APPEAR)
   if(task_exists(TASK_CREATE)) remove_task(TASK_CREATE)      
   if(task_exists(TASK_ROUND_SOUND)) remove_task(TASK_ROUND_SOUND)
 
   if(get_player_alive() >= 1)
   {
      for(new i = 0; i < g_zombie_count[g_day]; i++)
      {
         new ent = find_ent_by_class(-1, ZB_CLASSNAME)
 
         if(is_valid_ent(ent))
            kill_zombie(ent)
      }      
 
      g_fail = 0
 
 
   }
 
   else {
      for(new i = 0; i < g_zombie_count[g_day]; i++)
      {
         new ent = find_ent_by_class(-1, ZB_CLASSNAME)
 
         if(is_valid_ent(ent))
            native_set_think(ent, 0)
      }            
 
      g_fail = 1
 
 
   }
}
 
public create_ammobox()
{
   new Float:Origin[3]
   collect_spawn_box(Origin)
 
   new ent = create_entity("info_target")
 
   Origin[2] -= 35.0
   entity_set_origin(ent, Origin)
 
   entity_set_string(ent, EV_SZ_classname, AMMOBOX_CLASSNAME)
   entity_set_model(ent, ammobox_model)
   entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
 
   new Float:maxs[3] = {30.0, 30.0, 30.0}
   new Float:mins[3] = {-30.0, -30.0, -30.0}
   entity_set_size(ent, mins, maxs)
 
   set_task(0.25, "task_show_ammo_spr", TASK_SHOWAMMO, _, _, "b")
 
   drop_to_floor(ent)
}
 
public task_show_ammo_spr()
{
   static ent, Float:Origin[3]
 
   ent = find_ent_by_class(-1, AMMOBOX_CLASSNAME)
   pev(ent, pev_origin, Origin)
 
   engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
   write_byte(TE_SPRITE)
   engfunc(EngFunc_WriteCoord, Origin[0])
   engfunc(EngFunc_WriteCoord, Origin[1])
   engfunc(EngFunc_WriteCoord, Origin[2] + 45.0)
   write_short(ammobox_id)
   write_byte(2)
   write_byte(186)
   message_end()
}
 
public zombie_appear()
{
   if(!is_boss_round)
   {
      PlaySound(sound_start[random_num(0, charsmax(sound_start))])
      client_print(0, print_center, "%i. kör", g_day)
 
      set_task(random_float(0.1, 2.5), "make_zombie", TASK_CREATE, _, _, "b")   
   } else {
      client_print(0, print_center, "Utolsó kör!", g_day)
   }
 
   set_task(10.0, "start_round_sound", TASK_ROUND_SOUND)
}
 
public start_round_sound()
{
   PlaySound(round_sound[random_num(0, charsmax(round_sound))])
}
 
public make_zombie()
{
   if(g_current_zombie2 > 0)
   {
      if(get_zombie_alive() < 7)
      {
         g_current_zombie2--
         create_zombie()
      }
   } else {
      remove_task(TASK_CREATE)
   }
}
 
public event_roundstart(id)
{
   //set_task(5.0, "create_zombie", _, _, _, "b")
}
 
public create_zombie()
{   
   new ent = create_entity("info_target")
   new Float:Origin[3], Float:health, model[64]
   collect_spawn(Origin)
 
   g_class[ent] = random(g_total_class)
   health = ArrayGetCell(g_class_health, g_class[ent])
 
   health *= g_health_multi[g_day]
 
   ArrayGetString(g_class_model, g_class[ent], model, sizeof(model))
 
   dllfunc(DLLFunc_Spawn, ent)
   entity_set_origin(ent, Origin)
 
   entity_set_float(ent, EV_FL_takedamage, 1.0)
   entity_set_float(ent, EV_FL_health, health)
 
   entity_set_string(ent, EV_SZ_classname, ZB_CLASSNAME)
   entity_set_model(ent, model)
   entity_set_int(ent, EV_INT_solid, SOLID_SLIDEBOX)
 
   static modelindex
   modelindex = ArrayGetCell(g_class_modelindex, g_class[ent])
   set_pev(ent, pev_modelindex, modelindex)
 
   entity_set_int(ent, EV_INT_movetype, MOVETYPE_STEP)
 
   set_pev(ent, pev_victim, 0)
 
   new Float:VEC_HULL_MIN[3] = { -16.0, -16.0, -40.0 }
   new Float:VEC_HULL_MAX[3] = { 16.0, 16.0, 72.0}
   entity_set_size(ent, VEC_HULL_MIN, VEC_HULL_MAX)
 
   play_anim(ent, ANIM_IDLE, 1.0)
 
   set_task(1.0, "start_attack", ent)
   //drop_to_floor(ent)
 
   if(!g_reg)
   {
      RegisterHamFromEntity(Ham_TakeDamage, ent, "fw_zb_takedmg")
      RegisterHamFromEntity(Ham_Killed, ent, "fw_zb_killed")
      g_reg = true
   }
 
   g_think[ent] = 1   
   g_zombie[ent] = 1
 
   static g_fwDummyResult
   ExecuteForward(fwd_zombie_create, g_fwDummyResult, ent)   
 
   return 1
}
 
public start_attack(ent)
{
   if(is_valid_ent(ent))
      entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.01)
}
 
public fw_takedamage(victim, inflictor, attacker, Float:damage, damagebits)
{
   if((get_user_team(victim) == 1) || (get_user_team(victim) == 2))
      return HAM_SUPERCEDE
 
   return HAM_HANDLED
}
 
public fw_zb_takedmg(victim, inflictor, attacker, Float:damage, damagebits)
{
   emit_sound(victim, CHAN_BODY, sound_pain[random_num(0, charsmax(sound_pain))], 1.0, ATTN_NORM, 0, PITCH_NORM)
 
   static Float:Origin[3]
   pev(victim, pev_origin, Origin)
 
   create_blood(Origin)   
}
 
public fw_zb_killed(ent2, attacker)
{
   g_current_zombie--
   emit_sound(ent2, CHAN_BODY, sound_die[random_num(0, charsmax(sound_die))], 1.0, ATTN_NORM, 0, PITCH_NORM)   
 
   static ent
   ent = create_entity("info_target")
   static Float:Origin[3], Float:Angles[3], Model[64]
 
   pev(ent2, pev_origin, Origin)
   pev(ent2, pev_angles, Angles)
   ArrayGetString(g_class_model, g_class[ent2], Model, sizeof(Model))
 
   entity_set_origin(ent, Origin)
   entity_set_vector(ent, EV_VEC_angles, Angles)
 
   entity_set_string(ent, EV_SZ_classname, "temp_zb")
   entity_set_model(ent, Model)
 
   drop_to_floor(ent)
 
   play_anim(ent, ANIM_DIE, 1.0)
 
   set_task(3.0, "remove_temp_zb", ent)
 
   if(g_current_zombie == 0)
   {
      TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Ct)
   }
 
   if(0 < attacker < 32)
   {
      if(cs_get_user_money(attacker) < 16000)
      {
         cs_set_user_money(attacker, cs_get_user_money(attacker) + 200)
      }
 
      client_print(attacker, print_center, "Halál!")
   }
}
 
public fw_cmdstart(id, uc_handle, seed)
{
   static Button
   Button = get_uc(uc_handle, UC_Buttons)
 
   if(Button & IN_USE)
   {
      static Ent, Float:Range
      Ent = find_ent_by_class(-1, AMMOBOX_CLASSNAME)
 
      if(!is_valid_ent(Ent))
         return FMRES_IGNORED
 
      static Weapon
      Weapon = get_user_weapon(id)
 
      if(Weapon == CSW_KNIFE || Weapon == CSW_C4 || Weapon == CSW_FLASHBANG ||
      Weapon == CSW_HEGRENADE || Weapon == CSW_SMOKEGRENADE)
         return FMRES_IGNORED
 
 
      Range = entity_range(Ent, id)
      if(Range <= 70.0)
      {
         if(cs_get_user_bpammo(id, get_user_weapon(id)) < 200)
         {
            if(!in_reloading_ammobox[id])
            {
               in_reloading_ammobox[id] = 1
 
               message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), _, id)
               write_short(1)
               message_end()
 
               set_task(1.0, "reload_ammo", id+TASK_AMMO)
 
               emit_sound(id, CHAN_BODY, ammobox_reload_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
            }               
         }      
      } else {
         if(in_reloading_ammobox[id])
         {
            in_reloading_ammobox[id] = 0
 
            message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), _, id)
            write_short(0)
            message_end()
 
            if(task_exists(id+TASK_AMMO)) remove_task(id+TASK_AMMO)            
         }         
      }
   } else {
      if(pev(id, pev_oldbuttons) & IN_USE)
      {
         if(in_reloading_ammobox[id])
         {
            in_reloading_ammobox[id] = 0
 
            message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("BarTime"), _, id)
            write_short(0)
            message_end()
 
            if(task_exists(id+TASK_AMMO)) remove_task(id+TASK_AMMO)            
         }            
      }
   }
 
   return FMRES_HANDLED
}
 
public reload_ammo(id)
{
   id -= TASK_AMMO
 
   client_print(id, print_center, "Újratöltve - 100% ammo")
   in_reloading_ammobox[id] = 0
 
   cs_set_user_bpammo(id, get_user_weapon(id),200 )
}
 
public kill_zombie(ent2)
{
   emit_sound(ent2, CHAN_BODY, sound_die[random_num(0, charsmax(sound_die))], 1.0, ATTN_NORM, 0, PITCH_NORM)      
 
   static ent
   ent = create_entity("info_target")
   static Float:Origin[3], Float:Angles[3], Model[64]
 
   ArrayGetString(g_class_model, g_class[ent2], Model, sizeof(Model))
 
   pev(ent2, pev_origin, Origin)
   pev(ent2, pev_angles, Angles)
 
   entity_set_origin(ent, Origin)
   entity_set_vector(ent, EV_VEC_angles, Angles)
 
   entity_set_string(ent, EV_SZ_classname, "temp_zb")
   entity_set_model(ent, Model)
 
   //drop_to_floor(ent)
 
   play_anim(ent, ANIM_DIE, 1.0)
 
   set_task(3.0, "remove_temp_zb", ent)
}
 
public remove_temp_zb(ent)
{
   remove_entity(ent)
}
 
public fw_zb_think(ent)
{
   if(!is_valid_ent(ent))
      return FMRES_IGNORED
 
   if(g_think[ent])
   {
      static victim
      static Float:Origin[3], Float:VicOrigin[3], Float:distance
 
      victim = FindClosesEnemy(ent)
      pev(ent, pev_origin, Origin)
      pev(victim, pev_origin, VicOrigin)
 
      distance = get_distance_f(Origin, VicOrigin)
 
      if(is_user_alive(victim))
      {
         if(distance <= 60.0)
         {
            if(!is_valid_ent(ent))
               return FMRES_IGNORED   
 
            new Float:Ent_Origin[3], Float:Vic_Origin[3]
 
            pev(ent, pev_origin, Ent_Origin)
            pev(victim, pev_origin, Vic_Origin)         
 
            npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin)
 
            zombie_attack(ent, victim)
            entity_set_float(ent, EV_FL_nextthink, get_gametime() + 2.5)
         } else {
 
            if(get_anim(ent) != ANIM_WALK)
               play_anim(ent, ANIM_WALK, 1.0)
 
            new Float:Ent_Origin[3], Float:Vic_Origin[3]
 
            pev(ent, pev_origin, Ent_Origin)
            pev(victim, pev_origin, Vic_Origin)
 
            npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin)
            hook_ent(ent, victim)
 
            entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.5)
         }
 
         current_target[ent] = victim
      } else {
         //hook_ent(ent, ent)
 
         if(get_anim(ent) != ANIM_IDLE)
            play_anim(ent, ANIM_IDLE, 1.0)
 
         entity_set_float(ent, EV_FL_nextthink, get_gametime() + 1.0)
      }
   } else {
      if(get_anim(ent) != ANIM_IDLE)
         play_anim(ent, ANIM_IDLE, 1.0)
 
      entity_set_float(ent, EV_FL_nextthink, get_gametime() + 1.0)      
   }
 
   return FMRES_HANDLED
}
 
public zombie_attack(ent, victim)
{
   play_anim(ent, ANIM_ATTACK, 1.0)
 
   emit_sound(victim, CHAN_BODY, sound_attack[random_num(0, charsmax(sound_attack))], 1.0, ATTN_NORM, 0, PITCH_NORM)
   ExecuteHam(Ham_TakeDamage, victim, 0, victim, random_float(15.0, 30.0), DMG_BULLET)
 
   remove_task(ent+TASK_ATTACK)
   set_task(1.5, "stop_attack", ent+TASK_ATTACK)
}
 
public stop_attack(ent)
{
   ent -= TASK_ATTACK
 
   play_anim(ent, ANIM_IDLE, 1.0)
   remove_task(ent+TASK_ATTACK)
}
 
public npc_turntotarget(ent, Float:Ent_Origin[3], target, Float:Vic_Origin[3])
{
   if(target)
   {
      new Float:newAngle[3]
      entity_get_vector(ent, EV_VEC_angles, newAngle)
      new Float:x = Vic_Origin[0] - Ent_Origin[0]
      new Float:z = Vic_Origin[1] - Ent_Origin[1]
 
      new Float:radians = floatatan(z/x, radian)
      newAngle[1] = radians * (180 / 3.14)
      if (Vic_Origin[0] < Ent_Origin[0])
         newAngle[1] -= 180.0
 
      entity_set_vector(ent, EV_VEC_angles, newAngle)
   }
}
 
public hook_ent(ent, victim)
{
   static Float:fl_Velocity[3]
   static Float:VicOrigin[3], Float:EntOrigin[3]
   static Float:Speed
 
   pev(ent, pev_origin, EntOrigin)
   pev(victim, pev_origin, VicOrigin)
   Speed = ArrayGetCell(g_class_speed, g_class[ent])
 
   static Float:distance_f
   distance_f = get_distance_f(EntOrigin, VicOrigin)
 
   if (distance_f > 60.0)
   {
      new Float:fl_Time = distance_f / Speed
 
      fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
      fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
      fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
   } else
   {
      fl_Velocity[0] = 0.0
      fl_Velocity[1] = 0.0
      fl_Velocity[2] = 0.0
   }
 
   entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
}
 
public round_end()
{
   client_cmd(0, "stopsound")
   PlaySound(sound_end[random_num(0, charsmax(sound_end))])
 
   return PLUGIN_HANDLED
}
 
public hook_textmsg()
{
   new szMsg[22]
   get_msg_arg_string(2, szMsg, sizeof szMsg)   
 
   if(get_player_alive() >= 1)
   {
      if(equal(szMsg, "#Terrorists_Win"))
         set_msg_arg_string(2, "Gyözelem!")
      else if(equal(szMsg, "#CTs_Win"))
         set_msg_arg_string(2 , "Gyözelem")
      else if(equal(szMsg, "#Round_Draw"))
         set_msg_arg_string(2 , "Gyözelem")   
 
      g_fail = 0
   } else {
      if(equal(szMsg, "#Terrorists_Win"))
         set_msg_arg_string(2, "Sikertelen küldetés!")
      else if(equal(szMsg, "#CTs_Win"))
         set_msg_arg_string(2 , "Sikertelen küldetés!")
      else if(equal(szMsg, "#Round_Draw"))
         set_msg_arg_string(2 , "Sikertelen küldetés!")      
 
      g_fail = 1
   }   

 
// Transfer Player Team
public balance_teams()
{
   static iPlayersnum
   iPlayersnum = get_playersnum()
 
   if (iPlayersnum < 1) return;
 
   static iTerrors, iMaxTerrors, id
   iMaxTerrors = iPlayersnum/2
   iTerrors = 0
 
   for (id = 1; id <= get_maxplayers(); id++)
   {
      if (!is_user_connected(id))
         continue;
 
      if (cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
         continue;
 
      cs_set_user_team(id, CS_TEAM_CT)
   }
 
   while (iTerrors < iMaxTerrors)
   {
      if (++id > get_maxplayers()) id = 1
 
      if (!is_user_connected(id))
         continue;
 
      if (cs_get_user_team(id) != CS_TEAM_CT)
         continue;
 
      if (random_num(0, 1))
      {
         cs_set_user_team(id, CS_TEAM_T)
         iTerrors++
      }
   }
}
 
stock bool:IsValidTarget(iTarget)
{
   if (!iTarget || !(1<= iTarget <= get_maxplayers()) || !is_user_connected(iTarget) || !is_user_alive(iTarget))
      return false
   return true
}
 
public FindClosesEnemy(entid)
{
   new Float:Dist
   new Float:maxdistance=4000.0
   new indexid=0   
   for(new i=1;i<=get_maxplayers();i++){
      if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i))
      {
         Dist = entity_range(entid, i)
         if(Dist <= maxdistance)
         {
            maxdistance=Dist
            indexid=i
 
            return indexid
         }
      }   
   }   
   return 0
}
 
public bool:can_see_fm(entindex1, entindex2)
{
   if (!entindex1 || !entindex2)
      return false
 
   if (pev_valid(entindex1) && pev_valid(entindex1))
   {
      new flags = pev(entindex1, pev_flags)
      if (flags & EF_NODRAW || flags & FL_NOTARGET)
      {
         return false
      }
 
      new Float:lookerOrig[3]
      new Float:targetBaseOrig[3]
      new Float:targetOrig[3]
      new Float:temp[3]
 
      pev(entindex1, pev_origin, lookerOrig)
      pev(entindex1, pev_view_ofs, temp)
      lookerOrig[0] += temp[0]
      lookerOrig[1] += temp[1]
      lookerOrig[2] += temp[2]
 
      pev(entindex2, pev_origin, targetBaseOrig)
      pev(entindex2, pev_view_ofs, temp)
      targetOrig[0] = targetBaseOrig [0] + temp[0]
      targetOrig[1] = targetBaseOrig [1] + temp[1]
      targetOrig[2] = targetBaseOrig [2] + temp[2]
 
      engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the had of seen player
      if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
      {
         return false
      }
      else
      {
         new Float:flFraction
         get_tr2(0, TraceResult:TR_flFraction, flFraction)
         if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
         {
            return true
         }
         else
         {
            targetOrig[0] = targetBaseOrig [0]
            targetOrig[1] = targetBaseOrig [1]
            targetOrig[2] = targetBaseOrig [2]
            engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the body of seen player
            get_tr2(0, TraceResult:TR_flFraction, flFraction)
            if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
            {
               return true
            }
            else
            {
               targetOrig[0] = targetBaseOrig [0]
               targetOrig[1] = targetBaseOrig [1]
               targetOrig[2] = targetBaseOrig [2] - 17.0
               engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the legs of seen player
               get_tr2(0, TraceResult:TR_flFraction, flFraction)
               if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
               {
                  return true
               }
            }
         }
      }
   }
   return false
}
 
stock get_anim(id)
{
   if(is_valid_ent(id))
   {   
      return pev(id, pev_sequence)
   }
 
   return PLUGIN_HANDLED
}
 
stock play_anim(index, sequence, Float:framerate = 1.0)
{
   if(is_valid_ent(index))
   {
      entity_set_float(index, EV_FL_animtime, get_gametime())
      entity_set_float(index, EV_FL_framerate,  framerate)
      entity_set_float(index, EV_FL_frame, 0.0)
      entity_set_int(index, EV_INT_sequence, sequence)
   }

 
public create_blood(const Float:origin[3])
{
   // Show some blood <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"mosoly\" /><!-- s:) -->
   message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
   write_byte(TE_BLOODSPRITE)
   engfunc(EngFunc_WriteCoord, origin[0])
   engfunc(EngFunc_WriteCoord, origin[1])
   engfunc(EngFunc_WriteCoord, origin[2])
   write_short(m_iBlood[1])
   write_short(m_iBlood[0])
   write_byte(75)
   write_byte(5)
   message_end()
}
 
stock collect_spawn_box(Float:origin[3])
{
   for (new i=1; i<=g_total_boxs*3; i++)
   {
      origin = g_boxs[random(g_total_boxs)]
      if (check_spawn_box(origin)) return 1;
   }
 
   return 0;
}
stock check_spawn_box(Float:origin[3])
{
   new Float:originE[3], Float:origin1[3], Float:origin2[3]
   new ent = -1
   while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "ammobox")) != 0)
   {
      pev(ent, pev_origin, originE)
 
      // xoy
      origin1 = origin
      origin2 = originE
      origin1[2] = origin2[2] = 0.0
      if (vector_distance(origin1, origin2)<=2*npc_size_width) return 0;
   }
   return 1;
}
 
stock collect_spawn(Float:origin[3])
{
   for (new i=1; i<=g_total_spawns*3; i++)
   {
      origin = g_spawns[random(g_total_spawns)]
      if (check_spawn(origin)) return 1;
   }
 
   return 0;
}
 
stock check_spawn(Float:origin[3])
{
   new Float:originE[3], Float:origin1[3], Float:origin2[3]
   new ent = -1
   while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", ZB_CLASSNAME)) != 0)
   {
      pev(ent, pev_origin, originE)
 
      // xoy
      origin1 = origin
      origin2 = originE
      origin1[2] = origin2[2] = 0.0
      if (vector_distance(origin1, origin2)<=2*npc_size_width)
      {
         // oz
         origin1 = origin
         origin2 = originE
         origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0
         if (vector_distance(origin1, origin2)<=npc_size_height) return 0;
      }
   }
   return 1;
}
 
stock str_count(const str[], searchchar)
{
   new count, i, len = strlen(str)
 
   for (i = 0; i <= len; i++)
   {
      if(str[i] == searchchar)
         count++
   }
 
   return count;
}
 
// load spawn points
load_spawn_points()
{
   // Check for spawns points of the current map
   new cfgdir[32], mapname[32], filepath[100], linedata[64]
   get_configsdir(cfgdir, charsmax(cfgdir))
   get_mapname(mapname, charsmax(mapname))
   formatex(filepath, charsmax(filepath), SPAWNS_FILE, cfgdir, mapname)
 
   // Load spawns points
   if (file_exists(filepath))
   {
      new file = fopen(filepath,"rt"), row[4][6], boss
 
      while (file && !feof(file))
      {
         fgets(file, linedata, charsmax(linedata))
 
         // invalid spawn
         if(!linedata[0] || str_count(linedata,' ') < 2) continue;
 
         // get spawn point data
         parse(linedata,row[0],5,row[1],5,row[2],5,row[3],5)
 
         // origin
         boss = str_to_num(row[0])
         if (boss && g_total_spawns_boss<MAX_SPAWNS)
         {
            g_spawns_boss[g_total_spawns_boss][0] = floatstr(row[1])
            g_spawns_boss[g_total_spawns_boss][1] = floatstr(row[2])
            g_spawns_boss[g_total_spawns_boss][2] = floatstr(row[3])
            g_total_spawns_boss++
         }
         else if (g_total_spawns<MAX_SPAWNS)
         {
            g_spawns[g_total_spawns][0] = floatstr(row[1])
            g_spawns[g_total_spawns][1] = floatstr(row[2])
            g_spawns[g_total_spawns][2] = floatstr(row[3])
            g_total_spawns++
         }
      }
      if (file) fclose(file)
   }
}
 
// load spawn points
load_ammobox_spawns()
{
   // Check for spawns points of the current map
   new cfgdir[32], mapname[32], filepath[100], linedata[64]
   get_configsdir(cfgdir, charsmax(cfgdir))
   get_mapname(mapname, charsmax(mapname))
   formatex(filepath, charsmax(filepath), BOXS_FILE, cfgdir, mapname)
 
   // Load spawns points
   if (file_exists(filepath))
   {
      new file = fopen(filepath,"rt"), row[4][6]
 
      while (file && !feof(file))
      {
         fgets(file, linedata, charsmax(linedata))
 
         // invalid spawn
         if(!linedata[0] || str_count(linedata,' ') < 2) continue;
 
         // get spawn point data
         parse(linedata,row[0],5,row[1],5,row[2],5)
 
         // origin
         g_boxs[g_total_boxs][0] = floatstr(row[0])
         g_boxs[g_total_boxs][1] = floatstr(row[1])
         g_boxs[g_total_boxs][2] = floatstr(row[2])
 
         g_total_boxs++
         if (g_total_boxs>=MAX_SPAWNS) break;
      }
      if (file) fclose(file)
   }
}
 
public get_player_alive()
{
   static iAlive, id
   iAlive = 0
 
   for (id = 1; id <= get_maxplayers(); id++)
   {
      if (is_user_alive(id))
         iAlive++
   }
 
   return iAlive;
}
 
public get_zombie_alive()
{
   static iAlive, i
   iAlive = 0
 
   static classname[32]
 
   for (i = 1; i <= entity_count(); i++)
   {
      if(is_valid_ent(i))
      {
         pev(i, pev_classname, classname, sizeof(classname))
         if(equal(classname, ZB_CLASSNAME))
            iAlive++
      }
   }
 
   return iAlive;
}
 
// Plays a sound on clients
public PlaySound(const sound[])
{
   client_cmd(0, "spk ^"%s^"", sound)
}
 
public native_register_class(const Float:Health, const Float:Speed, const Model[], const modelindex)
{
   param_convert(3)
 
   ArrayPushCell(g_class_health, Health)
   ArrayPushCell(g_class_speed, Speed)
   ArrayPushString(g_class_model, Model)
   ArrayPushCell(g_class_modelindex, modelindex)
 
   g_total_class++
 
   return g_total_class - 1
}
 
public native_is_zombie(id)
{
   return g_zombie[id]
}
 
public native_get_class(id)
{
   return g_class[id]
}
 
public native_set_think(id, think)
{
   g_think[id] = think
}
 
public native_set_zb_count(count)
{
   g_current_zombie = count
 
   if(g_current_zombie == 0)
   {
      TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Ct)
   }   
}
 
public native_get_zb_count()
{
   return g_current_zombie
}
 
public native_is_valid_zombie(ent)
{
   return is_valid_ent(ent)
}
 
public native_get_target(ent)
{
   return current_target[ent]
}
stock print_color(const id, const input[], any:...)
{
        new count = 1, players[32]
        static msg[191]
        vformat(msg, 190, input, 3)

        replace_all(msg, 190, "!g", "^4")
        replace_all(msg, 190, "!y", "^1")
        replace_all(msg, 190, "!t", "^3")
        replace_all(msg, 190, "á", "á")
        replace_all(msg, 190, "é", "Ă©")
        replace_all(msg, 190, "í", "Ă­")
        replace_all(msg, 190, "ó", "Ăł")
        replace_all(msg, 190, "ö", "ö")
        replace_all(msg, 190, "ő", "Ĺ‘")
        replace_all(msg, 190, "ú", "Ăş")
        replace_all(msg, 190, "ü", "ĂĽ")
        replace_all(msg, 190, "ű", "ű")
        replace_all(msg, 190, "Á", "Á")
        replace_all(msg, 190, "É", "É")
        replace_all(msg, 190, "Í", "ĂŤ")
        replace_all(msg, 190, "Ó", "Ă“")
        replace_all(msg, 190, "Ö", "Ă–")
        replace_all(msg, 190, "Ő", "Ő")
        replace_all(msg, 190, "Ú", "Ăš")
        replace_all(msg, 190, "Ü", "Ăś")
        replace_all(msg, 190, "Ű", "Ĺ°")       

        if (id) players[0] = id; else get_players(players, count, "ch")
        {
                for (new i = 0; i < count; i++)
                {
                        if (is_user_connected(players[i]))
                        {
                                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
                                write_byte(players[i])
                                write_string(msg)
                                message_end()
                        }
                }
        }
        return PLUGIN_HANDLED
}

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: sv_restart 1 command
HozzászólásElküldve: 2013.11.13. 17:46 
Offline
Újonc

Csatlakozott: 2013.11.13. 07:11
Hozzászólások: 3
Igen mert a cmd nem indul el automatikusan, csak sv_restart után. Ez ki is küszöbölhető, de fenn áll a probléma amikor megnyred a kört. Akkor is kellene egy restart amikor minden ZM halott. És akkor jön a második kör és tovább. A halálkor drasztikus módon megoldottam, hogy restartoljon és folytassa.

Amit írtál parancsot bele már én is próbáltam de csak elinditja a 0. kört.

Úgy kellene amikor a játékos felcsatlakozik, kb. 10 mp. és kezdetét veszi a gyilkolás. A halál utánni respawn megoldva, csak az új kör betöltéséhez ismételten egy sv_restart kell. Mert minden itt dől el:

SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. public event_round_end(id)
  3. {
  4. if(task_exists(TASK_ATTACK)) remove_task(TASK_ATTACK)
  5. if(task_exists(TASK_APPEAR)) remove_task(TASK_APPEAR)
  6. if(task_exists(TASK_CREATE)) remove_task(TASK_CREATE)
  7. if(task_exists(TASK_ROUND_SOUND)) remove_task(TASK_ROUND_SOUND)
  8. if(get_player_alive() >= 1)
  9. {
  10. for(new i = 0; i < g_zombie_count[g_day]; i++)
  11. {
  12. new ent = find_ent_by_class(-1, ZB_CLASSNAME)
  13. if(is_valid_ent(ent))
  14. kill_zombie(ent)
  15. }
  16. g_fail = 0
  17. }
  18.  
  19.  
  20. else {
  21. for(new i = 0; i < g_zombie_count[g_day]; i++)
  22. {
  23. new ent = find_ent_by_class(-1, ZB_CLASSNAME)
  24.  
  25. if(is_valid_ent(ent))
  26. native_set_think(ent, 0)
  27.  
  28. }
  29.  
  30. g_fail = 1 < set_cvar_num("sv_restart",1);
  31.  
  32.  
  33.  
  34. }
  35. }
  36.  


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 65 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole