hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2019.10.14. 08:25



Jelenlévő felhasználók

Jelenleg 22 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 20 vendég

A legtöbb felhasználó (652 fő) 2015.05.25. 22:38-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], 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  [ 5 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: minigun
HozzászólásElküldve: 2013.08.27. 19:34 
Offline
Nagyúr
Avatar

Csatlakozott: 2012.09.23. 09:50
Hozzászólások: 569
Megköszönt másnak: 76 alkalommal
Megköszönték neki: 37 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <cstrike>
  5. #include <hamsandwich>
  6. #include <amxmisc>
  7. #include <fun>
  8.  
  9. #define MAX_PLAYERS 32
  10. #define MAX_BLOOD_DISTANCE 64
  11. #define LOADUP_TIME 0.75
  12. #define SHUTDOWN_TIME 1.7
  13. #define SHAKE_FORCE -5.0 //(must be negative value)
  14. new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45} // Gunshot decal list
  15. // Plugin information
  16. new const PLUGIN[] = "WPN Minigun"
  17. new const VERSION[] = "1.65"
  18. new const AUTHOR[] = "CLLlAgOB"
  19. // other
  20. new bool:has_minigun[33], m249, bool:atk2[33], bool:atk1[33],
  21. bool:delay[33], clipp[33],clipstart,g_fwid,bool:delayhud[33],bool:beackup[33],
  22. mcost,msg[128],bool:frstCLIP[33],g_MaxPlayers,g_guns_eventids_bitsum,bool:haswhpnnmg[33],
  23. Float:g_lastShot[33], Float:g_nextSound[33], g_plAction[33],bool:g_fix_punchangle[33],
  24. bool:canfire[33],oneround,only_adminCB,MsgSayText,g_normal_trace[33],DMGMG,bool:user_bot[33],
  25. bool:is_alive[33],bool:is_connected[33]
  26. // Blood
  27. new g_blood
  28. new g_bloodspray
  29. // CS Player PData Offsets (win32)
  30. const OFFSET_CSTEAMS = 114
  31. // Linux diff's
  32. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  33. // Models
  34. new P_MODEL[] = "models/wpnmod/m134/p_minigun.mdl"
  35. new V_MODEL[] = "models/wpnmod/m134/v_minigun.mdl"
  36. new W_MODEL[] = "models/wpnmod/m134/w_minigun.mdl"
  37. // Sounds
  38. new m_SOUND[][] = {"wpnmod/minigun/hw_shoot1.wav", "wpnmod/minigun/hw_spin.wav", "wpnmod/minigun/hw_spinup.wav", "wpnmod/minigun/hw_spindown.wav"}
  39. new g_noammo_sounds[][] = {"weapons/dryfire_rifle.wav"}
  40. //no recoil
  41. new const g_guns_events[][] = {"events/m249.sc"}
  42. //connect
  43. #define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])
  44. enum {
  45. anim_idle,
  46. anim_idle2,
  47. anim_gentleidle,
  48. anim_stillidle,
  49. anim_draw,
  50. anim_holster,
  51. anim_spinup,
  52. anim_spindown,
  53. anim_spinidle,
  54. anim_spinfire,
  55. anim_spinidledown
  56. }
  57.  
  58. // Types
  59. enum {
  60. act_none,
  61. act_load_up,
  62. act_run
  63. }
  64. public plugin_precache() {
  65. precache_model(P_MODEL)
  66. precache_model(V_MODEL)
  67. precache_model(W_MODEL)
  68. precache_sound(m_SOUND[0])
  69. precache_sound(m_SOUND[1])
  70. precache_sound(m_SOUND[2])
  71. precache_sound(m_SOUND[3])
  72. g_blood = precache_model("sprites/blood.spr")
  73. g_bloodspray = precache_model("sprites/bloodspray.spr")
  74. g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1)
  75. }
  76.  
  77. public plugin_init() {
  78. register_plugin(PLUGIN, VERSION, AUTHOR)
  79. register_dictionary("minigun.txt")
  80. MsgSayText = get_user_msgid("SayText")
  81. clipstart = register_cvar("amx_ammo_mini","600")
  82. m249 = register_cvar("amx_speed_mini","0.9")
  83. DMGMG = register_cvar("amx_minigun_damage","1.2")
  84. oneround = register_cvar("amx_oneround","0")
  85. mcost = register_cvar("amx_cost_mini","10000")
  86. only_adminCB = register_cvar("amx_only_adm_buy","0")
  87. register_event("CurWeapon","event_curweapon","be", "1=1")
  88. register_event("DeathMsg","unminigun","a")
  89. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  90. register_forward(FM_CmdStart, "fwd_CmdStart")
  91. register_forward(FM_EmitSound,"fwd_emitsound")
  92. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  93. register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
  94. register_forward(FM_StartFrame, "fwd_StartFrame")
  95. register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
  96. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  97. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  98. RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
  99. register_clcmd("say /minigun","buymini")
  100. register_concmd("amx_minigun_give", "cmdMinigun_give", ADMIN_LEVEL_A, "<@all or name/id> <ammo>")
  101. register_clcmd("drop","dropcmd")
  102. //events
  103. // Get Max Players
  104. g_MaxPlayers = global_get(glb_maxClients)
  105. register_logevent("event_start", 2, "1=Round_Start")
  106. register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
  107. register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
  108. unregister_forward(FM_PrecacheEvent, g_fwid, 1)
  109. }
  110.  
  111. // Client joins the game
  112. public client_putinserver(id)
  113. {
  114. // Player joined
  115. is_connected[id] = true
  116. }
  117. // Client leaving
  118. public fw_ClientDisconnect(id)
  119. {
  120. is_connected[id] = false
  121. is_alive[id] = false
  122. }
  123. public fw_PlayerSpawn_Post(id)
  124. {
  125. // Not alive or didn't join a team yet
  126. if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  127. return;
  128. // Player spawned
  129. is_alive[id] = true
  130. }
  131. public fw_PlayerKilled(victim, attacker, shouldgib)
  132. {
  133. //player die
  134. is_alive[victim] = false
  135. }
  136. public unminigun(){
  137. new id = read_data(2)
  138. if(has_minigun[id] && !is_alive[id]) {
  139. new Float:Aim[3],Float:origin[3]
  140. VelocityByAim(id, 64, Aim)
  141. entity_get_vector(id,EV_VEC_origin,origin)
  142.  
  143. origin[0] += Aim[0]
  144. origin[1] += Aim[1]
  145.  
  146. new minigun = create_entity("info_target")
  147. entity_set_string(minigun,EV_SZ_classname,"minigun")
  148. entity_set_model(minigun,W_MODEL)
  149.  
  150. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  151. entity_set_int(minigun,EV_INT_solid,1)
  152.  
  153. entity_set_int(minigun,EV_INT_movetype,6)
  154. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  155. entity_set_vector(minigun,EV_VEC_origin,origin)
  156. has_minigun[id] = false
  157. remowegun(id)
  158. return PLUGIN_HANDLED
  159. }
  160. return PLUGIN_CONTINUE
  161. }
  162.  
  163. //damage lvl
  164. public player_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) {
  165. if(damagetype & DMG_BULLET && haswhpnnmg[attacker] && has_minigun[attacker] == true && attacker!=victim)
  166. {
  167. damage = damage*get_pcvar_float(DMGMG)
  168. SetHamParamFloat(4, damage)
  169. return HAM_IGNORED
  170. }
  171. return HAM_IGNORED
  172. }
  173.  
  174. public cmdMinigun_give(id, level, cid) {
  175. if (!cmd_access(id, level, cid, 3)) {
  176. return PLUGIN_HANDLED
  177. }
  178.  
  179. new arg[32], arg2[8], name2[32], argument2
  180. read_argv(1,arg,31)
  181. read_argv(2,arg2,7)
  182. argument2 = str_to_num(arg2)
  183. if ( equali(arg,"@all") ){
  184. new plist[32],pnum
  185. get_players(plist,pnum,"a")
  186. if (pnum==0)
  187. {
  188. console_print(id,"[Minigun] This client is invalid")
  189. return PLUGIN_HANDLED
  190. }
  191. for (new i=0; i<pnum; i++)
  192. {
  193. give_weapon(plist[i], argument2, 1)
  194. client_print(plist[i], print_chat, "[Minigun] %L", LANG_PLAYER, "MINIGUN_ADMIN_GIVE_ALL",argument2)
  195. }
  196. }
  197. else
  198. {
  199. get_user_name(id,name2,31)
  200. new player = cmd_target(id,arg,7)
  201. if (!player)
  202. {
  203. console_print(id,"[Minigun] Give Minigun Failed")
  204. return PLUGIN_HANDLED
  205. }
  206. new name[32]
  207. get_user_name(player,name,31)
  208. give_weapon(player, argument2, 1)
  209. client_print(0, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_GIVE",name,argument2)
  210. return PLUGIN_HANDLED
  211. }
  212. return PLUGIN_HANDLED
  213. }
  214.  
  215. public buymini(id) {
  216. if ((!(get_user_flags(id) & ADMIN_IMMUNITY) || !(get_user_flags(id) & ADMIN_RESERVATION)) && get_pcvar_num(only_adminCB)) {
  217. format(msg,256,"[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_BUY")
  218. message_begin(MSG_ONE,MsgSayText,{0,0,0},id)
  219. write_byte(id)
  220. write_string(msg)
  221. message_end()
  222. return PLUGIN_HANDLED
  223. }
  224. new money = cs_get_user_money(id)
  225. new price = get_pcvar_num(mcost)
  226. if(!is_alive[id])
  227. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALIVE")
  228. else if(has_minigun[id])
  229. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALREADY")
  230. else if(money < price)
  231. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_NO_MONEY")
  232. else{
  233. cs_set_user_money(id, money - price)
  234. give_weapon(id, 0, 1)
  235. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_BUY",price)
  236. }
  237. return PLUGIN_HANDLED
  238. }
  239.  
  240. public dropcmd(id) {
  241. if(has_minigun[id] && haswhpnnmg[id] && is_alive[id]) {
  242. new Float:Aim[3],Float:origin[3]
  243. VelocityByAim(id, 64, Aim)
  244. entity_get_vector(id,EV_VEC_origin,origin)
  245.  
  246. origin[0] += Aim[0]
  247. origin[1] += Aim[1]
  248.  
  249. new minigun = create_entity("info_target")
  250. entity_set_string(minigun,EV_SZ_classname,"minigun")
  251. entity_set_model(minigun,W_MODEL)
  252.  
  253. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  254. entity_set_int(minigun,EV_INT_solid,1)
  255.  
  256. entity_set_int(minigun,EV_INT_movetype,6)
  257. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  258. entity_set_vector(minigun,EV_VEC_origin,origin)
  259. has_minigun[id] = false
  260. canfire[id] = false
  261. remowegun(id)
  262. g_plAction[id] = false
  263. return PLUGIN_HANDLED
  264. }
  265. return PLUGIN_CONTINUE
  266. }
  267.  
  268. public pfn_touch(ptr, ptd) {
  269. if(is_valid_ent(ptr)) {
  270. new classname[32]
  271. entity_get_string(ptr,EV_SZ_classname,classname,31)
  272.  
  273. if(equal(classname, "minigun")) {
  274. if(is_valid_ent(ptd)) {
  275. new id = ptd
  276. if(id > 0 && id < 34) {
  277. if(!has_minigun[id] && is_alive[id]) {
  278. give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), 0)
  279. canfire[id] = true
  280. remove_entity(ptr)
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287.  
  288. public remove_miniguns() {
  289. new nextitem = find_ent_by_class(-1,"minigun")
  290. while(nextitem) {
  291. remove_entity(nextitem)
  292. nextitem = find_ent_by_class(-1,"minigun")
  293. }
  294. return PLUGIN_CONTINUE
  295. }
  296. public event_start_freezetime(){
  297. remove_miniguns()
  298. static iPlayers[32], iPlayersNum, i
  299. get_players(iPlayers, iPlayersNum, "a")
  300.  
  301. if(!get_pcvar_num(only_adminCB)){
  302. for (i = 0; i <= iPlayersNum; ++i){
  303. if(!has_minigun[iPlayers[i]]){
  304. set_task(random_float(0.1,1.0),"msghelp",iPlayers[i])
  305. }
  306. }
  307. }
  308. if(get_pcvar_num(oneround)){
  309. for (i = 0; i <= iPlayersNum; ++i){
  310. if(has_minigun[iPlayers[i]]){
  311. has_minigun[iPlayers[i]] = false
  312. remowegun(iPlayers[i])
  313. }
  314. }
  315. } else {
  316. for (i = 0; i <= iPlayersNum; ++i){
  317. g_plAction[iPlayers[i]] = false
  318. canfire[iPlayers[i]] = false
  319. frstCLIP[iPlayers[i]] = true
  320. }
  321. }
  322. }
  323. // remove gun and save all guns
  324. public remowegun(id) {
  325. new wpnList[32]
  326. new number
  327. get_user_weapons(id,wpnList,number)
  328. for (new i = 0;i < number ;i++) {
  329. if (wpnList[i] == CSW_M249) {
  330. fm_strip_user_gun(id, wpnList[i])
  331. }
  332. }
  333. }
  334.  
  335. public msghelp(id){
  336. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_FOR_BUY")
  337. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_PRICE",get_pcvar_num(mcost))
  338. }
  339.  
  340. public event_start(){
  341. static iPlayers[32], iPlayersNum, i
  342. get_players(iPlayers, iPlayersNum, "a")
  343. for (i = 0; i <= iPlayersNum; ++i)
  344. canfire[iPlayers[i]] = true
  345. }
  346.  
  347.  
  348.  
  349. public fwEvGameWillRestartIn() {
  350. static iPlayers[32], iPlayersNum, i
  351. get_players(iPlayers, iPlayersNum, "a")
  352. for (i = 0; i <= iPlayersNum; ++i)
  353. has_minigun[iPlayers[i]] = false
  354. }
  355. public client_connect(id){
  356. canfire[id]= false
  357. has_minigun[id] = false
  358. g_normal_trace[id] = 0
  359. if(is_user_bot(id)) user_bot[id] = true
  360. else user_bot[id] = false
  361. }
  362.  
  363. //block sound no ammo in atack
  364. public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
  365. {
  366. if (!is_user_valid_connected(id) || !has_minigun[id])
  367. return FMRES_IGNORED;
  368. else if((equal(sample, g_noammo_sounds[0])) && has_minigun[id] && haswhpnnmg[id])
  369. {
  370. return FMRES_SUPERCEDE
  371. }
  372. return FMRES_IGNORED
  373. }
  374.  
  375. //give wpn
  376. public give_weapon(id, ammo, frst){
  377. has_minigun[id] = true
  378. give_item(id,"weapon_m249")
  379. canfire[id] = true
  380. clipp[id] = ammo
  381. if(frst) frstCLIP[id] = true
  382. else beackup[id] = true
  383.  
  384. }
  385.  
  386.  
  387. //play anim
  388. public native_playanim(player,anim)
  389. {
  390. set_pev(player, pev_weaponanim, anim)
  391. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
  392. write_byte(anim)
  393. write_byte(pev(player, pev_body))
  394. message_end()
  395. }
  396.  
  397.  
  398. public fwd_CmdStart(id, uc_handle, seed)
  399. {
  400.  
  401.  
  402. if(!is_alive[id] || !canfire[id] || !has_minigun[id]) return FMRES_HANDLED
  403.  
  404. if(haswhpnnmg[id])
  405. {
  406. static buttons
  407. buttons = get_uc(uc_handle, UC_Buttons)
  408. if(buttons & IN_ATTACK)
  409. {
  410. atk1[id] = true
  411. atk2[id] = false
  412.  
  413.  
  414. }
  415. else if(buttons & IN_ATTACK2)
  416. {
  417. atk2[id] = true
  418. atk1[id] = false
  419. }
  420. if(atk1[id] && !atk2[id] && (g_plAction[id] == act_none || g_plAction[id] == act_load_up) && clipp[id]>0){
  421. buttons &= ~IN_ATTACK
  422. buttons &= ~IN_ATTACK2
  423. set_uc(uc_handle, UC_Buttons, buttons)
  424. fire_mode(id,0)
  425. } else if(atk2[id] || atk1[id] && clipp[id]==0){
  426. fire_mode(id,1)
  427. }
  428.  
  429. }
  430. return FMRES_IGNORED
  431. }
  432.  
  433. // in fire
  434. fire_mode(id, type) {
  435. static Float:gtime
  436. gtime = get_gametime()
  437. g_lastShot[id] = gtime
  438.  
  439. if(g_nextSound[id] <= gtime && canfire[id]) {
  440. switch(g_plAction[id]) {
  441. case act_none: {
  442. native_playanim(id, anim_spinup)
  443. emit_sound(id, CHAN_WEAPON, m_SOUND[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  444. g_nextSound[id] = gtime + LOADUP_TIME
  445. g_plAction[id] = act_load_up
  446. }
  447. case act_load_up: {
  448. g_nextSound[id] = gtime
  449. g_plAction[id] = act_run
  450. }
  451. }
  452. }
  453.  
  454. if(g_plAction[id] == act_run) {
  455. if(type == 0 && clipp[id]>0 && atk1[id]){
  456. emit_sound(id, CHAN_WEAPON, m_SOUND[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  457. testbulet(id)
  458. if(!delay[id]) {
  459. native_playanim(id, anim_spinfire)
  460. ammo_hud(id)
  461. set_task(0.2,"delayanim",id)
  462. delay[id] = true
  463. }
  464. }
  465. else {
  466. if(!delay[id]) {
  467. ammo_hud(id)
  468. emit_sound(id, CHAN_WEAPON, m_SOUND[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  469. native_playanim(id, anim_spinidle)
  470. set_task(0.2,"delayanim",id)
  471. delay[id] = true
  472. }
  473. }
  474. }
  475. atk1[id] = false
  476. atk2[id] = false
  477. }
  478.  
  479. public delayanim(id){
  480. delay[id] = false
  481. }
  482.  
  483. //set models
  484. public event_curweapon(id){
  485. if(!is_alive[id] || !is_connected[id] || user_bot[id]) return;
  486. new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
  487. if((has_minigun[id]) && (weapon == CSW_M249)){
  488. if(g_plAction[id] != act_run && frstCLIP[id]){
  489. new ent = get_weapon_ent(id,weapon)
  490. if(clipp[id] < get_pcvar_num(clipstart)) clipp[id] = get_pcvar_num(clipstart)
  491. cs_set_weapon_ammo(ent, clipp[id])
  492. frstCLIP[id] = false
  493. }
  494. if(g_plAction[id] != act_run && beackup[id]){
  495. new ent = get_weapon_ent(id,weapon)
  496. cs_set_weapon_ammo(ent, clipp[id])
  497. beackup[id] = false
  498. }
  499. if(clipp[id] == 0){
  500. new ent = get_weapon_ent(id,weapon)
  501. cs_set_weapon_ammo(ent, clipp[id])
  502. }
  503. if(g_plAction[id] == act_run){
  504. clipp[id] = clip
  505. }
  506. message_begin(MSG_ONE, get_user_msgid("CurWeapon"), {0,0,0}, id)
  507. write_byte(1)
  508. write_byte(CSW_KNIFE)
  509. write_byte(0)
  510. message_end()
  511. if(!haswhpnnmg[id]){
  512. entity_set_string(id,EV_SZ_viewmodel,V_MODEL)
  513. entity_set_string(id,EV_SZ_weaponmodel,P_MODEL)
  514. haswhpnnmg[id] = true
  515. }
  516. new Ent = get_weapon_ent(id,weapon)
  517. new Float:N_Speed
  518. if(Ent)
  519. {
  520. N_Speed = get_pcvar_float(m249)
  521. new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed
  522. if (Delay > 0.0){
  523. set_pdata_float( Ent, 46, Delay, 4)
  524. }
  525. }
  526. ammo_hud(id)
  527. if(atk1[id]){
  528. fire_mode(id, 0)
  529. }
  530. if(atk2[id]){
  531. fire_mode(id, 1)
  532. }
  533. }
  534. if(weapon != CSW_M249) haswhpnnmg[id] = false
  535. if((has_minigun[id]) && (!haswhpnnmg[id])) g_plAction[id] = act_none
  536. return;
  537. }
  538.  
  539. //sound and anim
  540. public fwd_StartFrame() {
  541. static Float:gtime, id
  542.  
  543. gtime = get_gametime()
  544.  
  545. for(id = 0; id <= g_MaxPlayers; id++) {
  546. if(g_plAction[id] != act_none) {
  547.  
  548. if(!(pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK2) && g_lastShot[id] + 0.2 < gtime) {
  549. native_playanim(id, anim_spinidledown)
  550. emit_sound(id, CHAN_WEAPON, m_SOUND[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  551. g_nextSound[id] = gtime + SHUTDOWN_TIME
  552. g_plAction[id] = act_none
  553. }
  554. }
  555. }
  556. }
  557.  
  558. //marks on hit
  559. public native_gi_get_gunshot_decal()
  560. {
  561. return GUNSHOT_DECALS[random_num(0, sizeof(GUNSHOT_DECALS) - 1)]
  562. }
  563.  
  564. //hit bulet
  565. public testbulet(id){
  566. // Find target
  567. new aimOrigin[3], target, body
  568. get_user_origin(id, aimOrigin, 3)
  569. get_user_aiming(id, target, body)
  570.  
  571. if(target > 0 && target <= g_MaxPlayers)
  572. {
  573. new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
  574. pev(id, pev_origin, fStart)
  575.  
  576. // Get ids view direction
  577. velocity_by_aim(id, MAX_BLOOD_DISTANCE, fVel)
  578.  
  579. // Calculate position where blood should be displayed
  580. fStart[0] = float(aimOrigin[0])
  581. fStart[1] = float(aimOrigin[1])
  582. fStart[2] = float(aimOrigin[2])
  583. fEnd[0] = fStart[0]+fVel[0]
  584. fEnd[1] = fStart[1]+fVel[1]
  585. fEnd[2] = fStart[2]+fVel[2]
  586.  
  587. // Draw traceline from victims origin into ids view direction to find
  588. // the location on the wall to put some blood on there
  589. new res
  590. engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
  591. get_tr2(res, TR_vecEndPos, fRes)
  592.  
  593. // Show some blood <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"mosoly\" /><!-- s:) -->
  594. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  595. write_byte(TE_BLOODSPRITE)
  596. write_coord(floatround(fStart[0]))
  597. write_coord(floatround(fStart[1]))
  598. write_coord(floatround(fStart[2]))
  599. write_short(g_bloodspray)
  600. write_short(g_blood)
  601. write_byte(70)
  602. write_byte(random_num(1,2))
  603. message_end()
  604.  
  605.  
  606. } else {
  607. new decal = native_gi_get_gunshot_decal()
  608.  
  609. // Check if the wall hit is an entity
  610. if(target)
  611. {
  612. // Put decal on an entity
  613. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  614. write_byte(TE_DECAL)
  615. write_coord(aimOrigin[0])
  616. write_coord(aimOrigin[1])
  617. write_coord(aimOrigin[2])
  618. write_byte(decal)
  619. write_short(target)
  620. message_end()
  621. } else {
  622. // Put decal on "world" (a wall)
  623. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  624. write_byte(TE_WORLDDECAL)
  625. write_coord(aimOrigin[0])
  626. write_coord(aimOrigin[1])
  627. write_coord(aimOrigin[2])
  628. write_byte(decal)
  629. message_end()
  630. }
  631.  
  632. // Show sparcles
  633. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  634. write_byte(TE_GUNSHOTDECAL)
  635. write_coord(aimOrigin[0])
  636. write_coord(aimOrigin[1])
  637. write_coord(aimOrigin[2])
  638. write_short(id)
  639. write_byte(decal)
  640. message_end()
  641. }
  642. }
  643.  
  644.  
  645. //block anim standart wpn
  646. public UpdateClientData_Post( id, sendweapons, cd_handle ){
  647. if ( !is_alive[id] ) return FMRES_IGNORED;
  648. if(haswhpnnmg[id] && has_minigun[id]) set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );
  649. return FMRES_HANDLED;
  650. }
  651.  
  652.  
  653.  
  654. // No recoil stuff
  655.  
  656. public fwPrecacheEvent(type, const name[]) {
  657. for (new i = 0; i < sizeof g_guns_events; ++i) {
  658. if (equal(g_guns_events[i], name)) {
  659. g_guns_eventids_bitsum |= (1<<get_orig_retval())
  660. return FMRES_HANDLED
  661. }
  662. }
  663.  
  664. return FMRES_IGNORED
  665. }
  666. public fwPlaybackEvent(flags, invoker, eventid) {
  667. if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_MaxPlayers)|| !haswhpnnmg[invoker] || !has_minigun[invoker])
  668. return FMRES_IGNORED
  669.  
  670. g_fix_punchangle[invoker] = true
  671.  
  672. return FMRES_HANDLED
  673. }
  674.  
  675. public fwPlayerPostThink(id) {
  676. if (g_fix_punchangle[id]) {
  677. g_fix_punchangle[id] = false
  678. set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0})
  679. return FMRES_HANDLED
  680. }
  681.  
  682. return FMRES_IGNORED
  683. }
  684.  
  685. public fwTraceLine(const Float:start[3], const Float:dest[3], ignore_monsters, id, ptr) {
  686. if (!(1 <= id <= g_MaxPlayers))
  687. return FMRES_IGNORED
  688.  
  689. if (!g_normal_trace[id]) {
  690. g_normal_trace[id] = ptr
  691. return FMRES_HANDLED
  692. }
  693. if (ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || !haswhpnnmg[id] || !has_minigun[id] || !is_alive[id])
  694. return FMRES_IGNORED
  695.  
  696. fix_recoil_trace(id, start, ptr)
  697.  
  698. return FMRES_SUPERCEDE
  699. }
  700. // show ammo clip
  701. public ammo_hud(id) {
  702. if(!delayhud[id]) {
  703. delayhud[id] = true
  704. new AmmoHud[65]
  705. new clip = clipp[id]
  706. format(AmmoHud, 64, "Ammo: %i", clip)
  707. set_hudmessage(200, 100, 0, 1.0 , 1.0, 0, 0.1, 0.1,0.1)
  708. show_hudmessage(id,"%s",AmmoHud)
  709. set_task(0.2,"delayhutmsg",id)
  710. }
  711. }
  712.  
  713. public delayhutmsg(id){
  714. delayhud[id]= false
  715. }
  716.  
  717. //get weapon id
  718. stock get_weapon_ent(id,wpnid=0,wpnName[]="")
  719. {
  720. // who knows what wpnName will be
  721. static newName[24];
  722.  
  723. // need to find the name
  724. if(wpnid) get_weaponname(wpnid,newName,23);
  725.  
  726. // go with what we were told
  727. else formatex(newName,23,"%s",wpnName);
  728.  
  729. // prefix it if we need to
  730. if(!equal(newName,"weapon_",7))
  731. format(newName,23,"weapon_%s",newName);
  732.  
  733. return fm_find_ent_by_owner(get_maxplayers(),newName,id);
  734. }
  735.  
  736. fix_recoil_trace(id, const Float:start[], ptr) {
  737. static Float:dest[3]
  738. pev(id, pev_v_angle, dest)
  739. engfunc(EngFunc_MakeVectors, dest)
  740. global_get(glb_v_forward, dest)
  741. xs_vec_mul_scalar(dest, 9999.0, dest)
  742. xs_vec_add(start, dest, dest)
  743. engfunc(EngFunc_TraceLine, start, dest, DONT_IGNORE_MONSTERS, id, ptr)
  744. }
  745. // Get User Team
  746. stock fm_cs_get_user_team(id)
  747. {
  748. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  749. }


Ebből kitudnátok venni azt h /minigun?
Mert ha beírják, akkor kapnak..

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: minigun
HozzászólásElküldve: 2013.08.27. 19:38 
Offline
Jómunkásember
Avatar

Csatlakozott: 2012.08.24. 19:42
Hozzászólások: 320
Megköszönt másnak: 11 alkalommal
Megköszönték neki: 30 alkalommal
Kivettem a parancsot.
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <cstrike>
  5. #include <hamsandwich>
  6. #include <amxmisc>
  7. #include <fun>
  8.  
  9. #define MAX_PLAYERS 32
  10. #define MAX_BLOOD_DISTANCE 64
  11. #define LOADUP_TIME 0.75
  12. #define SHUTDOWN_TIME 1.7
  13. #define SHAKE_FORCE -5.0 //(must be negative value)
  14. new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45} // Gunshot decal list
  15. // Plugin information
  16. new const PLUGIN[] = "WPN Minigun"
  17. new const VERSION[] = "1.65"
  18. new const AUTHOR[] = "CLLlAgOB"
  19. // other
  20. new bool:has_minigun[33], m249, bool:atk2[33], bool:atk1[33],
  21. bool:delay[33], clipp[33],clipstart,g_fwid,bool:delayhud[33],bool:beackup[33],
  22. mcost,msg[128],bool:frstCLIP[33],g_MaxPlayers,g_guns_eventids_bitsum,bool:haswhpnnmg[33],
  23. Float:g_lastShot[33], Float:g_nextSound[33], g_plAction[33],bool:g_fix_punchangle[33],
  24. bool:canfire[33],oneround,only_adminCB,MsgSayText,g_normal_trace[33],DMGMG,bool:user_bot[33],
  25. bool:is_alive[33],bool:is_connected[33]
  26. // Blood
  27. new g_blood
  28. new g_bloodspray
  29. // CS Player PData Offsets (win32)
  30. const OFFSET_CSTEAMS = 114
  31. // Linux diff's
  32. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  33. // Models
  34. new P_MODEL[] = "models/wpnmod/m134/p_minigun.mdl"
  35. new V_MODEL[] = "models/wpnmod/m134/v_minigun.mdl"
  36. new W_MODEL[] = "models/wpnmod/m134/w_minigun.mdl"
  37. // Sounds
  38. new m_SOUND[][] = {"wpnmod/minigun/hw_shoot1.wav", "wpnmod/minigun/hw_spin.wav", "wpnmod/minigun/hw_spinup.wav", "wpnmod/minigun/hw_spindown.wav"}
  39. new g_noammo_sounds[][] = {"weapons/dryfire_rifle.wav"}
  40. //no recoil
  41. new const g_guns_events[][] = {"events/m249.sc"}
  42. //connect
  43. #define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])
  44. enum {
  45. anim_idle,
  46. anim_idle2,
  47. anim_gentleidle,
  48. anim_stillidle,
  49. anim_draw,
  50. anim_holster,
  51. anim_spinup,
  52. anim_spindown,
  53. anim_spinidle,
  54. anim_spinfire,
  55. anim_spinidledown
  56. }
  57.  
  58. // Types
  59. enum {
  60. act_none,
  61. act_load_up,
  62. act_run
  63. }
  64. public plugin_precache() {
  65. precache_model(P_MODEL)
  66. precache_model(V_MODEL)
  67. precache_model(W_MODEL)
  68. precache_sound(m_SOUND[0])
  69. precache_sound(m_SOUND[1])
  70. precache_sound(m_SOUND[2])
  71. precache_sound(m_SOUND[3])
  72. g_blood = precache_model("sprites/blood.spr")
  73. g_bloodspray = precache_model("sprites/bloodspray.spr")
  74. g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1)
  75. }
  76.  
  77. public plugin_init() {
  78. register_plugin(PLUGIN, VERSION, AUTHOR)
  79. register_dictionary("minigun.txt")
  80. MsgSayText = get_user_msgid("SayText")
  81. clipstart = register_cvar("amx_ammo_mini","600")
  82. m249 = register_cvar("amx_speed_mini","0.9")
  83. DMGMG = register_cvar("amx_minigun_damage","1.2")
  84. oneround = register_cvar("amx_oneround","0")
  85. mcost = register_cvar("amx_cost_mini","10000")
  86. only_adminCB = register_cvar("amx_only_adm_buy","0")
  87. register_event("CurWeapon","event_curweapon","be", "1=1")
  88. register_event("DeathMsg","unminigun","a")
  89. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  90. register_forward(FM_CmdStart, "fwd_CmdStart")
  91. register_forward(FM_EmitSound,"fwd_emitsound")
  92. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  93. register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
  94. register_forward(FM_StartFrame, "fwd_StartFrame")
  95. register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
  96. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  97. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  98. RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
  99. register_concmd("amx_minigun_give", "cmdMinigun_give", ADMIN_LEVEL_A, "<@all or name/id> <ammo>")
  100. register_clcmd("drop","dropcmd")
  101. //events
  102. // Get Max Players
  103. g_MaxPlayers = global_get(glb_maxClients)
  104. register_logevent("event_start", 2, "1=Round_Start")
  105. register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
  106. register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
  107. unregister_forward(FM_PrecacheEvent, g_fwid, 1)
  108. }
  109.  
  110. // Client joins the game
  111. public client_putinserver(id)
  112. {
  113. // Player joined
  114. is_connected[id] = true
  115. }
  116. // Client leaving
  117. public fw_ClientDisconnect(id)
  118. {
  119. is_connected[id] = false
  120. is_alive[id] = false
  121. }
  122. public fw_PlayerSpawn_Post(id)
  123. {
  124. // Not alive or didn't join a team yet
  125. if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  126. return;
  127. // Player spawned
  128. is_alive[id] = true
  129. }
  130. public fw_PlayerKilled(victim, attacker, shouldgib)
  131. {
  132. //player die
  133. is_alive[victim] = false
  134. }
  135. public unminigun(){
  136. new id = read_data(2)
  137. if(has_minigun[id] && !is_alive[id]) {
  138. new Float:Aim[3],Float:origin[3]
  139. VelocityByAim(id, 64, Aim)
  140. entity_get_vector(id,EV_VEC_origin,origin)
  141.  
  142. origin[0] += Aim[0]
  143. origin[1] += Aim[1]
  144.  
  145. new minigun = create_entity("info_target")
  146. entity_set_string(minigun,EV_SZ_classname,"minigun")
  147. entity_set_model(minigun,W_MODEL)
  148.  
  149. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  150. entity_set_int(minigun,EV_INT_solid,1)
  151.  
  152. entity_set_int(minigun,EV_INT_movetype,6)
  153. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  154. entity_set_vector(minigun,EV_VEC_origin,origin)
  155. has_minigun[id] = false
  156. remowegun(id)
  157. return PLUGIN_HANDLED
  158. }
  159. return PLUGIN_CONTINUE
  160. }
  161.  
  162. //damage lvl
  163. public player_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) {
  164. if(damagetype & DMG_BULLET && haswhpnnmg[attacker] && has_minigun[attacker] == true && attacker!=victim)
  165. {
  166. damage = damage*get_pcvar_float(DMGMG)
  167. SetHamParamFloat(4, damage)
  168. return HAM_IGNORED
  169. }
  170. return HAM_IGNORED
  171. }
  172.  
  173. public cmdMinigun_give(id, level, cid) {
  174. if (!cmd_access(id, level, cid, 3)) {
  175. return PLUGIN_HANDLED
  176. }
  177.  
  178. new arg[32], arg2[8], name2[32], argument2
  179. read_argv(1,arg,31)
  180. read_argv(2,arg2,7)
  181. argument2 = str_to_num(arg2)
  182. if ( equali(arg,"@all") ){
  183. new plist[32],pnum
  184. get_players(plist,pnum,"a")
  185. if (pnum==0)
  186. {
  187. console_print(id,"[Minigun] This client is invalid")
  188. return PLUGIN_HANDLED
  189. }
  190. for (new i=0; i<pnum; i++)
  191. {
  192. give_weapon(plist[i], argument2, 1)
  193. client_print(plist[i], print_chat, "[Minigun] %L", LANG_PLAYER, "MINIGUN_ADMIN_GIVE_ALL",argument2)
  194. }
  195. }
  196. else
  197. {
  198. get_user_name(id,name2,31)
  199. new player = cmd_target(id,arg,7)
  200. if (!player)
  201. {
  202. console_print(id,"[Minigun] Give Minigun Failed")
  203. return PLUGIN_HANDLED
  204. }
  205. new name[32]
  206. get_user_name(player,name,31)
  207. give_weapon(player, argument2, 1)
  208. client_print(0, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_GIVE",name,argument2)
  209. return PLUGIN_HANDLED
  210. }
  211. return PLUGIN_HANDLED
  212. }
  213.  
  214. public buymini(id) {
  215. if ((!(get_user_flags(id) & ADMIN_IMMUNITY) || !(get_user_flags(id) & ADMIN_RESERVATION)) && get_pcvar_num(only_adminCB)) {
  216. format(msg,256,"[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_BUY")
  217. message_begin(MSG_ONE,MsgSayText,{0,0,0},id)
  218. write_byte(id)
  219. write_string(msg)
  220. message_end()
  221. return PLUGIN_HANDLED
  222. }
  223. new money = cs_get_user_money(id)
  224. new price = get_pcvar_num(mcost)
  225. if(!is_alive[id])
  226. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALIVE")
  227. else if(has_minigun[id])
  228. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALREADY")
  229. else if(money < price)
  230. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_NO_MONEY")
  231. else{
  232. cs_set_user_money(id, money - price)
  233. give_weapon(id, 0, 1)
  234. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_BUY",price)
  235. }
  236. return PLUGIN_HANDLED
  237. }
  238.  
  239. public dropcmd(id) {
  240. if(has_minigun[id] && haswhpnnmg[id] && is_alive[id]) {
  241. new Float:Aim[3],Float:origin[3]
  242. VelocityByAim(id, 64, Aim)
  243. entity_get_vector(id,EV_VEC_origin,origin)
  244.  
  245. origin[0] += Aim[0]
  246. origin[1] += Aim[1]
  247.  
  248. new minigun = create_entity("info_target")
  249. entity_set_string(minigun,EV_SZ_classname,"minigun")
  250. entity_set_model(minigun,W_MODEL)
  251.  
  252. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  253. entity_set_int(minigun,EV_INT_solid,1)
  254.  
  255. entity_set_int(minigun,EV_INT_movetype,6)
  256. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  257. entity_set_vector(minigun,EV_VEC_origin,origin)
  258. has_minigun[id] = false
  259. canfire[id] = false
  260. remowegun(id)
  261. g_plAction[id] = false
  262. return PLUGIN_HANDLED
  263. }
  264. return PLUGIN_CONTINUE
  265. }
  266.  
  267. public pfn_touch(ptr, ptd) {
  268. if(is_valid_ent(ptr)) {
  269. new classname[32]
  270. entity_get_string(ptr,EV_SZ_classname,classname,31)
  271.  
  272. if(equal(classname, "minigun")) {
  273. if(is_valid_ent(ptd)) {
  274. new id = ptd
  275. if(id > 0 && id < 34) {
  276. if(!has_minigun[id] && is_alive[id]) {
  277. give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), 0)
  278. canfire[id] = true
  279. remove_entity(ptr)
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286.  
  287. public remove_miniguns() {
  288. new nextitem = find_ent_by_class(-1,"minigun")
  289. while(nextitem) {
  290. remove_entity(nextitem)
  291. nextitem = find_ent_by_class(-1,"minigun")
  292. }
  293. return PLUGIN_CONTINUE
  294. }
  295. public event_start_freezetime(){
  296. remove_miniguns()
  297. static iPlayers[32], iPlayersNum, i
  298. get_players(iPlayers, iPlayersNum, "a")
  299.  
  300. if(!get_pcvar_num(only_adminCB)){
  301. for (i = 0; i <= iPlayersNum; ++i){
  302. if(!has_minigun[iPlayers[i]]){
  303. set_task(random_float(0.1,1.0),"msghelp",iPlayers[i])
  304. }
  305. }
  306. }
  307. if(get_pcvar_num(oneround)){
  308. for (i = 0; i <= iPlayersNum; ++i){
  309. if(has_minigun[iPlayers[i]]){
  310. has_minigun[iPlayers[i]] = false
  311. remowegun(iPlayers[i])
  312. }
  313. }
  314. } else {
  315. for (i = 0; i <= iPlayersNum; ++i){
  316. g_plAction[iPlayers[i]] = false
  317. canfire[iPlayers[i]] = false
  318. frstCLIP[iPlayers[i]] = true
  319. }
  320. }
  321. }
  322. // remove gun and save all guns
  323. public remowegun(id) {
  324. new wpnList[32]
  325. new number
  326. get_user_weapons(id,wpnList,number)
  327. for (new i = 0;i < number ;i++) {
  328. if (wpnList[i] == CSW_M249) {
  329. fm_strip_user_gun(id, wpnList[i])
  330. }
  331. }
  332. }
  333.  
  334. public msghelp(id){
  335. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_FOR_BUY")
  336. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_PRICE",get_pcvar_num(mcost))
  337. }
  338.  
  339. public event_start(){
  340. static iPlayers[32], iPlayersNum, i
  341. get_players(iPlayers, iPlayersNum, "a")
  342. for (i = 0; i <= iPlayersNum; ++i)
  343. canfire[iPlayers[i]] = true
  344. }
  345.  
  346.  
  347.  
  348. public fwEvGameWillRestartIn() {
  349. static iPlayers[32], iPlayersNum, i
  350. get_players(iPlayers, iPlayersNum, "a")
  351. for (i = 0; i <= iPlayersNum; ++i)
  352. has_minigun[iPlayers[i]] = false
  353. }
  354. public client_connect(id){
  355. canfire[id]= false
  356. has_minigun[id] = false
  357. g_normal_trace[id] = 0
  358. if(is_user_bot(id)) user_bot[id] = true
  359. else user_bot[id] = false
  360. }
  361.  
  362. //block sound no ammo in atack
  363. public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
  364. {
  365. if (!is_user_valid_connected(id) || !has_minigun[id])
  366. return FMRES_IGNORED;
  367. else if((equal(sample, g_noammo_sounds[0])) && has_minigun[id] && haswhpnnmg[id])
  368. {
  369. return FMRES_SUPERCEDE
  370. }
  371. return FMRES_IGNORED
  372. }
  373.  
  374. //give wpn
  375. public give_weapon(id, ammo, frst){
  376. has_minigun[id] = true
  377. give_item(id,"weapon_m249")
  378. canfire[id] = true
  379. clipp[id] = ammo
  380. if(frst) frstCLIP[id] = true
  381. else beackup[id] = true
  382.  
  383. }
  384.  
  385.  
  386. //play anim
  387. public native_playanim(player,anim)
  388. {
  389. set_pev(player, pev_weaponanim, anim)
  390. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
  391. write_byte(anim)
  392. write_byte(pev(player, pev_body))
  393. message_end()
  394. }
  395.  
  396.  
  397. public fwd_CmdStart(id, uc_handle, seed)
  398. {
  399.  
  400.  
  401. if(!is_alive[id] || !canfire[id] || !has_minigun[id]) return FMRES_HANDLED
  402.  
  403. if(haswhpnnmg[id])
  404. {
  405. static buttons
  406. buttons = get_uc(uc_handle, UC_Buttons)
  407. if(buttons & IN_ATTACK)
  408. {
  409. atk1[id] = true
  410. atk2[id] = false
  411.  
  412.  
  413. }
  414. else if(buttons & IN_ATTACK2)
  415. {
  416. atk2[id] = true
  417. atk1[id] = false
  418. }
  419. if(atk1[id] && !atk2[id] && (g_plAction[id] == act_none || g_plAction[id] == act_load_up) && clipp[id]>0){
  420. buttons &= ~IN_ATTACK
  421. buttons &= ~IN_ATTACK2
  422. set_uc(uc_handle, UC_Buttons, buttons)
  423. fire_mode(id,0)
  424. } else if(atk2[id] || atk1[id] && clipp[id]==0){
  425. fire_mode(id,1)
  426. }
  427.  
  428. }
  429. return FMRES_IGNORED
  430. }
  431.  
  432. // in fire
  433. fire_mode(id, type) {
  434. static Float:gtime
  435. gtime = get_gametime()
  436. g_lastShot[id] = gtime
  437.  
  438. if(g_nextSound[id] <= gtime && canfire[id]) {
  439. switch(g_plAction[id]) {
  440. case act_none: {
  441. native_playanim(id, anim_spinup)
  442. emit_sound(id, CHAN_WEAPON, m_SOUND[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  443. g_nextSound[id] = gtime + LOADUP_TIME
  444. g_plAction[id] = act_load_up
  445. }
  446. case act_load_up: {
  447. g_nextSound[id] = gtime
  448. g_plAction[id] = act_run
  449. }
  450. }
  451. }
  452.  
  453. if(g_plAction[id] == act_run) {
  454. if(type == 0 && clipp[id]>0 && atk1[id]){
  455. emit_sound(id, CHAN_WEAPON, m_SOUND[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  456. testbulet(id)
  457. if(!delay[id]) {
  458. native_playanim(id, anim_spinfire)
  459. ammo_hud(id)
  460. set_task(0.2,"delayanim",id)
  461. delay[id] = true
  462. }
  463. }
  464. else {
  465. if(!delay[id]) {
  466. ammo_hud(id)
  467. emit_sound(id, CHAN_WEAPON, m_SOUND[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  468. native_playanim(id, anim_spinidle)
  469. set_task(0.2,"delayanim",id)
  470. delay[id] = true
  471. }
  472. }
  473. }
  474. atk1[id] = false
  475. atk2[id] = false
  476. }
  477.  
  478. public delayanim(id){
  479. delay[id] = false
  480. }
  481.  
  482. //set models
  483. public event_curweapon(id){
  484. if(!is_alive[id] || !is_connected[id] || user_bot[id]) return;
  485. new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
  486. if((has_minigun[id]) && (weapon == CSW_M249)){
  487. if(g_plAction[id] != act_run && frstCLIP[id]){
  488. new ent = get_weapon_ent(id,weapon)
  489. if(clipp[id] < get_pcvar_num(clipstart)) clipp[id] = get_pcvar_num(clipstart)
  490. cs_set_weapon_ammo(ent, clipp[id])
  491. frstCLIP[id] = false
  492. }
  493. if(g_plAction[id] != act_run && beackup[id]){
  494. new ent = get_weapon_ent(id,weapon)
  495. cs_set_weapon_ammo(ent, clipp[id])
  496. beackup[id] = false
  497. }
  498. if(clipp[id] == 0){
  499. new ent = get_weapon_ent(id,weapon)
  500. cs_set_weapon_ammo(ent, clipp[id])
  501. }
  502. if(g_plAction[id] == act_run){
  503. clipp[id] = clip
  504. }
  505. message_begin(MSG_ONE, get_user_msgid("CurWeapon"), {0,0,0}, id)
  506. write_byte(1)
  507. write_byte(CSW_KNIFE)
  508. write_byte(0)
  509. message_end()
  510. if(!haswhpnnmg[id]){
  511. entity_set_string(id,EV_SZ_viewmodel,V_MODEL)
  512. entity_set_string(id,EV_SZ_weaponmodel,P_MODEL)
  513. haswhpnnmg[id] = true
  514. }
  515. new Ent = get_weapon_ent(id,weapon)
  516. new Float:N_Speed
  517. if(Ent)
  518. {
  519. N_Speed = get_pcvar_float(m249)
  520. new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed
  521. if (Delay > 0.0){
  522. set_pdata_float( Ent, 46, Delay, 4)
  523. }
  524. }
  525. ammo_hud(id)
  526. if(atk1[id]){
  527. fire_mode(id, 0)
  528. }
  529. if(atk2[id]){
  530. fire_mode(id, 1)
  531. }
  532. }
  533. if(weapon != CSW_M249) haswhpnnmg[id] = false
  534. if((has_minigun[id]) && (!haswhpnnmg[id])) g_plAction[id] = act_none
  535. return;
  536. }
  537.  
  538. //sound and anim
  539. public fwd_StartFrame() {
  540. static Float:gtime, id
  541.  
  542. gtime = get_gametime()
  543.  
  544. for(id = 0; id <= g_MaxPlayers; id++) {
  545. if(g_plAction[id] != act_none) {
  546.  
  547. if(!(pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK2) && g_lastShot[id] + 0.2 < gtime) {
  548. native_playanim(id, anim_spinidledown)
  549. emit_sound(id, CHAN_WEAPON, m_SOUND[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  550. g_nextSound[id] = gtime + SHUTDOWN_TIME
  551. g_plAction[id] = act_none
  552. }
  553. }
  554. }
  555. }
  556.  
  557. //marks on hit
  558. public native_gi_get_gunshot_decal()
  559. {
  560. return GUNSHOT_DECALS[random_num(0, sizeof(GUNSHOT_DECALS) - 1)]
  561. }
  562.  
  563. //hit bulet
  564. public testbulet(id){
  565. // Find target
  566. new aimOrigin[3], target, body
  567. get_user_origin(id, aimOrigin, 3)
  568. get_user_aiming(id, target, body)
  569.  
  570. if(target > 0 && target <= g_MaxPlayers)
  571. {
  572. new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
  573. pev(id, pev_origin, fStart)
  574.  
  575. // Get ids view direction
  576. velocity_by_aim(id, MAX_BLOOD_DISTANCE, fVel)
  577.  
  578. // Calculate position where blood should be displayed
  579. fStart[0] = float(aimOrigin[0])
  580. fStart[1] = float(aimOrigin[1])
  581. fStart[2] = float(aimOrigin[2])
  582. fEnd[0] = fStart[0]+fVel[0]
  583. fEnd[1] = fStart[1]+fVel[1]
  584. fEnd[2] = fStart[2]+fVel[2]
  585.  
  586. // Draw traceline from victims origin into ids view direction to find
  587. // the location on the wall to put some blood on there
  588. new res
  589. engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
  590. get_tr2(res, TR_vecEndPos, fRes)
  591.  
  592. // Show some blood <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"mosoly\" /><!-- s:) -->
  593. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  594. write_byte(TE_BLOODSPRITE)
  595. write_coord(floatround(fStart[0]))
  596. write_coord(floatround(fStart[1]))
  597. write_coord(floatround(fStart[2]))
  598. write_short(g_bloodspray)
  599. write_short(g_blood)
  600. write_byte(70)
  601. write_byte(random_num(1,2))
  602. message_end()
  603.  
  604.  
  605. } else {
  606. new decal = native_gi_get_gunshot_decal()
  607.  
  608. // Check if the wall hit is an entity
  609. if(target)
  610. {
  611. // Put decal on an entity
  612. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  613. write_byte(TE_DECAL)
  614. write_coord(aimOrigin[0])
  615. write_coord(aimOrigin[1])
  616. write_coord(aimOrigin[2])
  617. write_byte(decal)
  618. write_short(target)
  619. message_end()
  620. } else {
  621. // Put decal on "world" (a wall)
  622. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  623. write_byte(TE_WORLDDECAL)
  624. write_coord(aimOrigin[0])
  625. write_coord(aimOrigin[1])
  626. write_coord(aimOrigin[2])
  627. write_byte(decal)
  628. message_end()
  629. }
  630.  
  631. // Show sparcles
  632. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  633. write_byte(TE_GUNSHOTDECAL)
  634. write_coord(aimOrigin[0])
  635. write_coord(aimOrigin[1])
  636. write_coord(aimOrigin[2])
  637. write_short(id)
  638. write_byte(decal)
  639. message_end()
  640. }
  641. }
  642.  
  643.  
  644. //block anim standart wpn
  645. public UpdateClientData_Post( id, sendweapons, cd_handle ){
  646. if ( !is_alive[id] ) return FMRES_IGNORED;
  647. if(haswhpnnmg[id] && has_minigun[id]) set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );
  648. return FMRES_HANDLED;
  649. }
  650.  
  651.  
  652.  
  653. // No recoil stuff
  654.  
  655. public fwPrecacheEvent(type, const name[]) {
  656. for (new i = 0; i < sizeof g_guns_events; ++i) {
  657. if (equal(g_guns_events[i], name)) {
  658. g_guns_eventids_bitsum |= (1<<get_orig_retval())
  659. return FMRES_HANDLED
  660. }
  661. }
  662.  
  663. return FMRES_IGNORED
  664. }
  665. public fwPlaybackEvent(flags, invoker, eventid) {
  666. if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_MaxPlayers)|| !haswhpnnmg[invoker] || !has_minigun[invoker])
  667. return FMRES_IGNORED
  668.  
  669. g_fix_punchangle[invoker] = true
  670.  
  671. return FMRES_HANDLED
  672. }
  673.  
  674. public fwPlayerPostThink(id) {
  675. if (g_fix_punchangle[id]) {
  676. g_fix_punchangle[id] = false
  677. set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0})
  678. return FMRES_HANDLED
  679. }
  680.  
  681. return FMRES_IGNORED
  682. }
  683.  
  684. public fwTraceLine(const Float:start[3], const Float:dest[3], ignore_monsters, id, ptr) {
  685. if (!(1 <= id <= g_MaxPlayers))
  686. return FMRES_IGNORED
  687.  
  688. if (!g_normal_trace[id]) {
  689. g_normal_trace[id] = ptr
  690. return FMRES_HANDLED
  691. }
  692. if (ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || !haswhpnnmg[id] || !has_minigun[id] || !is_alive[id])
  693. return FMRES_IGNORED
  694.  
  695. fix_recoil_trace(id, start, ptr)
  696.  
  697. return FMRES_SUPERCEDE
  698. }
  699. // show ammo clip
  700. public ammo_hud(id) {
  701. if(!delayhud[id]) {
  702. delayhud[id] = true
  703. new AmmoHud[65]
  704. new clip = clipp[id]
  705. format(AmmoHud, 64, "Ammo: %i", clip)
  706. set_hudmessage(200, 100, 0, 1.0 , 1.0, 0, 0.1, 0.1,0.1)
  707. show_hudmessage(id,"%s",AmmoHud)
  708. set_task(0.2,"delayhutmsg",id)
  709. }
  710. }
  711.  
  712. public delayhutmsg(id){
  713. delayhud[id]= false
  714. }
  715.  
  716. //get weapon id
  717. stock get_weapon_ent(id,wpnid=0,wpnName[]="")
  718. {
  719. // who knows what wpnName will be
  720. static newName[24];
  721.  
  722. // need to find the name
  723. if(wpnid) get_weaponname(wpnid,newName,23);
  724.  
  725. // go with what we were told
  726. else formatex(newName,23,"%s",wpnName);
  727.  
  728. // prefix it if we need to
  729. if(!equal(newName,"weapon_",7))
  730. format(newName,23,"weapon_%s",newName);
  731.  
  732. return fm_find_ent_by_owner(get_maxplayers(),newName,id);
  733. }
  734.  
  735. fix_recoil_trace(id, const Float:start[], ptr) {
  736. static Float:dest[3]
  737. pev(id, pev_v_angle, dest)
  738. engfunc(EngFunc_MakeVectors, dest)
  739. global_get(glb_v_forward, dest)
  740. xs_vec_mul_scalar(dest, 9999.0, dest)
  741. xs_vec_add(start, dest, dest)
  742. engfunc(EngFunc_TraceLine, start, dest, DONT_IGNORE_MONSTERS, id, ptr)
  743. }
  744. // Get User Team
  745. stock fm_cs_get_user_team(id)
  746. {
  747. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  748. }
  749.  


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: minigun
HozzászólásElküldve: 2013.08.27. 19:43 
Offline
Nagyúr
Avatar

Csatlakozott: 2012.09.23. 09:50
Hozzászólások: 569
Megköszönt másnak: 76 alkalommal
Megköszönték neki: 37 alkalommal
1 error ..
"fakemeta_until"

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: minigun
HozzászólásElküldve: 2013.08.27. 19:48 
Offline
Jómunkásember
Avatar

Csatlakozott: 2012.08.24. 19:42
Hozzászólások: 320
Megköszönt másnak: 11 alkalommal
Megköszönték neki: 30 alkalommal
Gondolom, hiányzik az INC, mert nekem tökéletesen átalakitotta.
(http://amxx.pl/kompilator/)

Kód:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Header size:           3160 bytes
Code size:            29228 bytes
Data size:             9972 bytes
Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
Total requirements:   58744 bytes
Done.

Ők köszönték meg TysOn nek ezt a hozzászólást: Applee (2013.08.27. 19:55)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: minigun
HozzászólásElküldve: 2013.08.27. 19:49 
Offline
Felfüggesztve

Csatlakozott: 2013.08.09. 22:37
Hozzászólások: 571
Megköszönt másnak: 10 alkalommal
Megköszönték neki: 84 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <cstrike>
  5. #include <hamsandwich>
  6. #include <amxmisc>
  7. #include <fun>
  8.  
  9. #define MAX_PLAYERS 32
  10. #define MAX_BLOOD_DISTANCE 64
  11. #define LOADUP_TIME 0.75
  12. #define SHUTDOWN_TIME 1.7
  13. #define SHAKE_FORCE -5.0 //(must be negative value)
  14. new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45} // Gunshot decal list
  15. // Plugin information
  16. new const PLUGIN[] = "WPN Minigun"
  17. new const VERSION[] = "1.65"
  18. new const AUTHOR[] = "CLLlAgOB"
  19. // other
  20. new bool:has_minigun[33], m249, bool:atk2[33], bool:atk1[33],
  21. bool:delay[33], clipp[33],clipstart,g_fwid,bool:delayhud[33],bool:beackup[33],
  22. mcost,msg[128],bool:frstCLIP[33],g_MaxPlayers,g_guns_eventids_bitsum,bool:haswhpnnmg[33],
  23. Float:g_lastShot[33], Float:g_nextSound[33], g_plAction[33],bool:g_fix_punchangle[33],
  24. bool:canfire[33],oneround,only_adminCB,MsgSayText,g_normal_trace[33],DMGMG,bool:user_bot[33],
  25. bool:is_alive[33],bool:is_connected[33]
  26. // Blood
  27. new g_blood
  28. new g_bloodspray
  29. // CS Player PData Offsets (win32)
  30. const OFFSET_CSTEAMS = 114
  31. // Linux diff's
  32. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  33. // Models
  34. new P_MODEL[] = "models/wpnmod/m134/p_minigun.mdl"
  35. new V_MODEL[] = "models/wpnmod/m134/v_minigun.mdl"
  36. new W_MODEL[] = "models/wpnmod/m134/w_minigun.mdl"
  37. // Sounds
  38. new m_SOUND[][] = {"wpnmod/minigun/hw_shoot1.wav", "wpnmod/minigun/hw_spin.wav", "wpnmod/minigun/hw_spinup.wav", "wpnmod/minigun/hw_spindown.wav"}
  39. new g_noammo_sounds[][] = {"weapons/dryfire_rifle.wav"}
  40. //no recoil
  41. new const g_guns_events[][] = {"events/m249.sc"}
  42. //connect
  43. #define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])
  44. enum {
  45. anim_idle,
  46. anim_idle2,
  47. anim_gentleidle,
  48. anim_stillidle,
  49. anim_draw,
  50. anim_holster,
  51. anim_spinup,
  52. anim_spindown,
  53. anim_spinidle,
  54. anim_spinfire,
  55. anim_spinidledown
  56. }
  57.  
  58. // Types
  59. enum {
  60. act_none,
  61. act_load_up,
  62. act_run
  63. }
  64. public plugin_precache() {
  65. precache_model(P_MODEL)
  66. precache_model(V_MODEL)
  67. precache_model(W_MODEL)
  68. precache_sound(m_SOUND[0])
  69. precache_sound(m_SOUND[1])
  70. precache_sound(m_SOUND[2])
  71. precache_sound(m_SOUND[3])
  72. g_blood = precache_model("sprites/blood.spr")
  73. g_bloodspray = precache_model("sprites/bloodspray.spr")
  74. g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1)
  75. }
  76.  
  77. public plugin_init() {
  78. register_plugin(PLUGIN, VERSION, AUTHOR)
  79. register_dictionary("minigun.txt")
  80. MsgSayText = get_user_msgid("SayText")
  81. clipstart = register_cvar("amx_ammo_mini","600")
  82. m249 = register_cvar("amx_speed_mini","0.9")
  83. DMGMG = register_cvar("amx_minigun_damage","1.2")
  84. oneround = register_cvar("amx_oneround","0")
  85. mcost = register_cvar("amx_cost_mini","10000")
  86. only_adminCB = register_cvar("amx_only_adm_buy","0")
  87. register_event("CurWeapon","event_curweapon","be", "1=1")
  88. register_event("DeathMsg","unminigun","a")
  89. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  90. register_forward(FM_CmdStart, "fwd_CmdStart")
  91. register_forward(FM_EmitSound,"fwd_emitsound")
  92. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  93. register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
  94. register_forward(FM_StartFrame, "fwd_StartFrame")
  95. register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
  96. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  97. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  98. RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
  99. register_clcmd("say /sadasdsadsadsadnemfogodkitalalni","buymini")
  100. register_concmd("amx_minigun_give", "cmdMinigun_give", ADMIN_LEVEL_A, "<@all or name/id> <ammo>")
  101. register_clcmd("drop","dropcmd")
  102. //events
  103. // Get Max Players
  104. g_MaxPlayers = global_get(glb_maxClients)
  105. register_logevent("event_start", 2, "1=Round_Start")
  106. register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
  107. register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
  108. unregister_forward(FM_PrecacheEvent, g_fwid, 1)
  109. }
  110.  
  111. // Client joins the game
  112. public client_putinserver(id)
  113. {
  114. // Player joined
  115. is_connected[id] = true
  116. }
  117. // Client leaving
  118. public fw_ClientDisconnect(id)
  119. {
  120. is_connected[id] = false
  121. is_alive[id] = false
  122. }
  123. public fw_PlayerSpawn_Post(id)
  124. {
  125. // Not alive or didn't join a team yet
  126. if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  127. return;
  128. // Player spawned
  129. is_alive[id] = true
  130. }
  131. public fw_PlayerKilled(victim, attacker, shouldgib)
  132. {
  133. //player die
  134. is_alive[victim] = false
  135. }
  136. public unminigun(){
  137. new id = read_data(2)
  138. if(has_minigun[id] && !is_alive[id]) {
  139. new Float:Aim[3],Float:origin[3]
  140. VelocityByAim(id, 64, Aim)
  141. entity_get_vector(id,EV_VEC_origin,origin)
  142.  
  143. origin[0] += Aim[0]
  144. origin[1] += Aim[1]
  145.  
  146. new minigun = create_entity("info_target")
  147. entity_set_string(minigun,EV_SZ_classname,"minigun")
  148. entity_set_model(minigun,W_MODEL)
  149.  
  150. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  151. entity_set_int(minigun,EV_INT_solid,1)
  152.  
  153. entity_set_int(minigun,EV_INT_movetype,6)
  154. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  155. entity_set_vector(minigun,EV_VEC_origin,origin)
  156. has_minigun[id] = false
  157. remowegun(id)
  158. return PLUGIN_HANDLED
  159. }
  160. return PLUGIN_CONTINUE
  161. }
  162.  
  163. //damage lvl
  164. public player_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) {
  165. if(damagetype & DMG_BULLET && haswhpnnmg[attacker] && has_minigun[attacker] == true && attacker!=victim)
  166. {
  167. damage = damage*get_pcvar_float(DMGMG)
  168. SetHamParamFloat(4, damage)
  169. return HAM_IGNORED
  170. }
  171. return HAM_IGNORED
  172. }
  173.  
  174. public cmdMinigun_give(id, level, cid) {
  175. if (!cmd_access(id, level, cid, 3)) {
  176. return PLUGIN_HANDLED
  177. }
  178.  
  179. new arg[32], arg2[8], name2[32], argument2
  180. read_argv(1,arg,31)
  181. read_argv(2,arg2,7)
  182. argument2 = str_to_num(arg2)
  183. if ( equali(arg,"@all") ){
  184. new plist[32],pnum
  185. get_players(plist,pnum,"a")
  186. if (pnum==0)
  187. {
  188. console_print(id,"[Minigun] This client is invalid")
  189. return PLUGIN_HANDLED
  190. }
  191. for (new i=0; i<pnum; i++)
  192. {
  193. give_weapon(plist[i], argument2, 1)
  194. client_print(plist[i], print_chat, "[Minigun] %L", LANG_PLAYER, "MINIGUN_ADMIN_GIVE_ALL",argument2)
  195. }
  196. }
  197. else
  198. {
  199. get_user_name(id,name2,31)
  200. new player = cmd_target(id,arg,7)
  201. if (!player)
  202. {
  203. console_print(id,"[Minigun] Give Minigun Failed")
  204. return PLUGIN_HANDLED
  205. }
  206. new name[32]
  207. get_user_name(player,name,31)
  208. give_weapon(player, argument2, 1)
  209. client_print(0, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_GIVE",name,argument2)
  210. return PLUGIN_HANDLED
  211. }
  212. return PLUGIN_HANDLED
  213. }
  214.  
  215. public buymini(id) {
  216. if ((!(get_user_flags(id) & ADMIN_IMMUNITY) || !(get_user_flags(id) & ADMIN_RESERVATION)) && get_pcvar_num(only_adminCB)) {
  217. format(msg,256,"[Minigun] %L", LANG_PLAYER,"MINIGUN_ADMIN_BUY")
  218. message_begin(MSG_ONE,MsgSayText,{0,0,0},id)
  219. write_byte(id)
  220. write_string(msg)
  221. message_end()
  222. return PLUGIN_HANDLED
  223. }
  224. new money = cs_get_user_money(id)
  225. new price = get_pcvar_num(mcost)
  226. if(!is_alive[id])
  227. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALIVE")
  228. else if(has_minigun[id])
  229. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_ALREADY")
  230. else if(money < price)
  231. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_NO_MONEY")
  232. else{
  233. cs_set_user_money(id, money - price)
  234. give_weapon(id, 0, 1)
  235. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_BUY",price)
  236. }
  237. return PLUGIN_HANDLED
  238. }
  239.  
  240. public dropcmd(id) {
  241. if(has_minigun[id] && haswhpnnmg[id] && is_alive[id]) {
  242. new Float:Aim[3],Float:origin[3]
  243. VelocityByAim(id, 64, Aim)
  244. entity_get_vector(id,EV_VEC_origin,origin)
  245.  
  246. origin[0] += Aim[0]
  247. origin[1] += Aim[1]
  248.  
  249. new minigun = create_entity("info_target")
  250. entity_set_string(minigun,EV_SZ_classname,"minigun")
  251. entity_set_model(minigun,W_MODEL)
  252.  
  253. entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  254. entity_set_int(minigun,EV_INT_solid,1)
  255.  
  256. entity_set_int(minigun,EV_INT_movetype,6)
  257. entity_set_int(minigun, EV_INT_iuser1, clipp[id])
  258. entity_set_vector(minigun,EV_VEC_origin,origin)
  259. has_minigun[id] = false
  260. canfire[id] = false
  261. remowegun(id)
  262. g_plAction[id] = false
  263. return PLUGIN_HANDLED
  264. }
  265. return PLUGIN_CONTINUE
  266. }
  267.  
  268. public pfn_touch(ptr, ptd) {
  269. if(is_valid_ent(ptr)) {
  270. new classname[32]
  271. entity_get_string(ptr,EV_SZ_classname,classname,31)
  272.  
  273. if(equal(classname, "minigun")) {
  274. if(is_valid_ent(ptd)) {
  275. new id = ptd
  276. if(id > 0 && id < 34) {
  277. if(!has_minigun[id] && is_alive[id]) {
  278. give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), 0)
  279. canfire[id] = true
  280. remove_entity(ptr)
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287.  
  288. public remove_miniguns() {
  289. new nextitem = find_ent_by_class(-1,"minigun")
  290. while(nextitem) {
  291. remove_entity(nextitem)
  292. nextitem = find_ent_by_class(-1,"minigun")
  293. }
  294. return PLUGIN_CONTINUE
  295. }
  296. public event_start_freezetime(){
  297. remove_miniguns()
  298. static iPlayers[32], iPlayersNum, i
  299. get_players(iPlayers, iPlayersNum, "a")
  300.  
  301. if(!get_pcvar_num(only_adminCB)){
  302. for (i = 0; i <= iPlayersNum; ++i){
  303. if(!has_minigun[iPlayers[i]]){
  304. set_task(random_float(0.1,1.0),"msghelp",iPlayers[i])
  305. }
  306. }
  307. }
  308. if(get_pcvar_num(oneround)){
  309. for (i = 0; i <= iPlayersNum; ++i){
  310. if(has_minigun[iPlayers[i]]){
  311. has_minigun[iPlayers[i]] = false
  312. remowegun(iPlayers[i])
  313. }
  314. }
  315. } else {
  316. for (i = 0; i <= iPlayersNum; ++i){
  317. g_plAction[iPlayers[i]] = false
  318. canfire[iPlayers[i]] = false
  319. frstCLIP[iPlayers[i]] = true
  320. }
  321. }
  322. }
  323. // remove gun and save all guns
  324. public remowegun(id) {
  325. new wpnList[32]
  326. new number
  327. get_user_weapons(id,wpnList,number)
  328. for (new i = 0;i < number ;i++) {
  329. if (wpnList[i] == CSW_M249) {
  330. fm_strip_user_gun(id, wpnList[i])
  331. }
  332. }
  333. }
  334.  
  335. public msghelp(id){
  336. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_FOR_BUY")
  337. client_print(id, print_chat, "[Minigun] %L", LANG_PLAYER,"MINIGUN_PRICE",get_pcvar_num(mcost))
  338. }
  339.  
  340. public event_start(){
  341. static iPlayers[32], iPlayersNum, i
  342. get_players(iPlayers, iPlayersNum, "a")
  343. for (i = 0; i <= iPlayersNum; ++i)
  344. canfire[iPlayers[i]] = true
  345. }
  346.  
  347.  
  348.  
  349. public fwEvGameWillRestartIn() {
  350. static iPlayers[32], iPlayersNum, i
  351. get_players(iPlayers, iPlayersNum, "a")
  352. for (i = 0; i <= iPlayersNum; ++i)
  353. has_minigun[iPlayers[i]] = false
  354. }
  355. public client_connect(id){
  356. canfire[id]= false
  357. has_minigun[id] = false
  358. g_normal_trace[id] = 0
  359. if(is_user_bot(id)) user_bot[id] = true
  360. else user_bot[id] = false
  361. }
  362.  
  363. //block sound no ammo in atack
  364. public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
  365. {
  366. if (!is_user_valid_connected(id) || !has_minigun[id])
  367. return FMRES_IGNORED;
  368. else if((equal(sample, g_noammo_sounds[0])) && has_minigun[id] && haswhpnnmg[id])
  369. {
  370. return FMRES_SUPERCEDE
  371. }
  372. return FMRES_IGNORED
  373. }
  374.  
  375. //give wpn
  376. public give_weapon(id, ammo, frst){
  377. has_minigun[id] = true
  378. give_item(id,"weapon_m249")
  379. canfire[id] = true
  380. clipp[id] = ammo
  381. if(frst) frstCLIP[id] = true
  382. else beackup[id] = true
  383.  
  384. }
  385.  
  386.  
  387. //play anim
  388. public native_playanim(player,anim)
  389. {
  390. set_pev(player, pev_weaponanim, anim)
  391. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
  392. write_byte(anim)
  393. write_byte(pev(player, pev_body))
  394. message_end()
  395. }
  396.  
  397.  
  398. public fwd_CmdStart(id, uc_handle, seed)
  399. {
  400.  
  401.  
  402. if(!is_alive[id] || !canfire[id] || !has_minigun[id]) return FMRES_HANDLED
  403.  
  404. if(haswhpnnmg[id])
  405. {
  406. static buttons
  407. buttons = get_uc(uc_handle, UC_Buttons)
  408. if(buttons & IN_ATTACK)
  409. {
  410. atk1[id] = true
  411. atk2[id] = false
  412.  
  413.  
  414. }
  415. else if(buttons & IN_ATTACK2)
  416. {
  417. atk2[id] = true
  418. atk1[id] = false
  419. }
  420. if(atk1[id] && !atk2[id] && (g_plAction[id] == act_none || g_plAction[id] == act_load_up) && clipp[id]>0){
  421. buttons &= ~IN_ATTACK
  422. buttons &= ~IN_ATTACK2
  423. set_uc(uc_handle, UC_Buttons, buttons)
  424. fire_mode(id,0)
  425. } else if(atk2[id] || atk1[id] && clipp[id]==0){
  426. fire_mode(id,1)
  427. }
  428.  
  429. }
  430. return FMRES_IGNORED
  431. }
  432.  
  433. // in fire
  434. fire_mode(id, type) {
  435. static Float:gtime
  436. gtime = get_gametime()
  437. g_lastShot[id] = gtime
  438.  
  439. if(g_nextSound[id] <= gtime && canfire[id]) {
  440. switch(g_plAction[id]) {
  441. case act_none: {
  442. native_playanim(id, anim_spinup)
  443. emit_sound(id, CHAN_WEAPON, m_SOUND[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  444. g_nextSound[id] = gtime + LOADUP_TIME
  445. g_plAction[id] = act_load_up
  446. }
  447. case act_load_up: {
  448. g_nextSound[id] = gtime
  449. g_plAction[id] = act_run
  450. }
  451. }
  452. }
  453.  
  454. if(g_plAction[id] == act_run) {
  455. if(type == 0 && clipp[id]>0 && atk1[id]){
  456. emit_sound(id, CHAN_WEAPON, m_SOUND[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  457. testbulet(id)
  458. if(!delay[id]) {
  459. native_playanim(id, anim_spinfire)
  460. ammo_hud(id)
  461. set_task(0.2,"delayanim",id)
  462. delay[id] = true
  463. }
  464. }
  465. else {
  466. if(!delay[id]) {
  467. ammo_hud(id)
  468. emit_sound(id, CHAN_WEAPON, m_SOUND[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  469. native_playanim(id, anim_spinidle)
  470. set_task(0.2,"delayanim",id)
  471. delay[id] = true
  472. }
  473. }
  474. }
  475. atk1[id] = false
  476. atk2[id] = false
  477. }
  478.  
  479. public delayanim(id){
  480. delay[id] = false
  481. }
  482.  
  483. //set models
  484. public event_curweapon(id){
  485. if(!is_alive[id] || !is_connected[id] || user_bot[id]) return;
  486. new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
  487. if((has_minigun[id]) && (weapon == CSW_M249)){
  488. if(g_plAction[id] != act_run && frstCLIP[id]){
  489. new ent = get_weapon_ent(id,weapon)
  490. if(clipp[id] < get_pcvar_num(clipstart)) clipp[id] = get_pcvar_num(clipstart)
  491. cs_set_weapon_ammo(ent, clipp[id])
  492. frstCLIP[id] = false
  493. }
  494. if(g_plAction[id] != act_run && beackup[id]){
  495. new ent = get_weapon_ent(id,weapon)
  496. cs_set_weapon_ammo(ent, clipp[id])
  497. beackup[id] = false
  498. }
  499. if(clipp[id] == 0){
  500. new ent = get_weapon_ent(id,weapon)
  501. cs_set_weapon_ammo(ent, clipp[id])
  502. }
  503. if(g_plAction[id] == act_run){
  504. clipp[id] = clip
  505. }
  506. message_begin(MSG_ONE, get_user_msgid("CurWeapon"), {0,0,0}, id)
  507. write_byte(1)
  508. write_byte(CSW_KNIFE)
  509. write_byte(0)
  510. message_end()
  511. if(!haswhpnnmg[id]){
  512. entity_set_string(id,EV_SZ_viewmodel,V_MODEL)
  513. entity_set_string(id,EV_SZ_weaponmodel,P_MODEL)
  514. haswhpnnmg[id] = true
  515. }
  516. new Ent = get_weapon_ent(id,weapon)
  517. new Float:N_Speed
  518. if(Ent)
  519. {
  520. N_Speed = get_pcvar_float(m249)
  521. new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed
  522. if (Delay > 0.0){
  523. set_pdata_float( Ent, 46, Delay, 4)
  524. }
  525. }
  526. ammo_hud(id)
  527. if(atk1[id]){
  528. fire_mode(id, 0)
  529. }
  530. if(atk2[id]){
  531. fire_mode(id, 1)
  532. }
  533. }
  534. if(weapon != CSW_M249) haswhpnnmg[id] = false
  535. if((has_minigun[id]) && (!haswhpnnmg[id])) g_plAction[id] = act_none
  536. return;
  537. }
  538.  
  539. //sound and anim
  540. public fwd_StartFrame() {
  541. static Float:gtime, id
  542.  
  543. gtime = get_gametime()
  544.  
  545. for(id = 0; id <= g_MaxPlayers; id++) {
  546. if(g_plAction[id] != act_none) {
  547.  
  548. if(!(pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK2) && g_lastShot[id] + 0.2 < gtime) {
  549. native_playanim(id, anim_spinidledown)
  550. emit_sound(id, CHAN_WEAPON, m_SOUND[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  551. g_nextSound[id] = gtime + SHUTDOWN_TIME
  552. g_plAction[id] = act_none
  553. }
  554. }
  555. }
  556. }
  557.  
  558. //marks on hit
  559. public native_gi_get_gunshot_decal()
  560. {
  561. return GUNSHOT_DECALS[random_num(0, sizeof(GUNSHOT_DECALS) - 1)]
  562. }
  563.  
  564. //hit bulet
  565. public testbulet(id){
  566. // Find target
  567. new aimOrigin[3], target, body
  568. get_user_origin(id, aimOrigin, 3)
  569. get_user_aiming(id, target, body)
  570.  
  571. if(target > 0 && target <= g_MaxPlayers)
  572. {
  573. new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
  574. pev(id, pev_origin, fStart)
  575.  
  576. // Get ids view direction
  577. velocity_by_aim(id, MAX_BLOOD_DISTANCE, fVel)
  578.  
  579. // Calculate position where blood should be displayed
  580. fStart[0] = float(aimOrigin[0])
  581. fStart[1] = float(aimOrigin[1])
  582. fStart[2] = float(aimOrigin[2])
  583. fEnd[0] = fStart[0]+fVel[0]
  584. fEnd[1] = fStart[1]+fVel[1]
  585. fEnd[2] = fStart[2]+fVel[2]
  586.  
  587. // Draw traceline from victims origin into ids view direction to find
  588. // the location on the wall to put some blood on there
  589. new res
  590. engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
  591. get_tr2(res, TR_vecEndPos, fRes)
  592.  
  593. // Show some blood <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"mosoly\" /><!-- s:) -->
  594. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  595. write_byte(TE_BLOODSPRITE)
  596. write_coord(floatround(fStart[0]))
  597. write_coord(floatround(fStart[1]))
  598. write_coord(floatround(fStart[2]))
  599. write_short(g_bloodspray)
  600. write_short(g_blood)
  601. write_byte(70)
  602. write_byte(random_num(1,2))
  603. message_end()
  604.  
  605.  
  606. } else {
  607. new decal = native_gi_get_gunshot_decal()
  608.  
  609. // Check if the wall hit is an entity
  610. if(target)
  611. {
  612. // Put decal on an entity
  613. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  614. write_byte(TE_DECAL)
  615. write_coord(aimOrigin[0])
  616. write_coord(aimOrigin[1])
  617. write_coord(aimOrigin[2])
  618. write_byte(decal)
  619. write_short(target)
  620. message_end()
  621. } else {
  622. // Put decal on "world" (a wall)
  623. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  624. write_byte(TE_WORLDDECAL)
  625. write_coord(aimOrigin[0])
  626. write_coord(aimOrigin[1])
  627. write_coord(aimOrigin[2])
  628. write_byte(decal)
  629. message_end()
  630. }
  631.  
  632. // Show sparcles
  633. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  634. write_byte(TE_GUNSHOTDECAL)
  635. write_coord(aimOrigin[0])
  636. write_coord(aimOrigin[1])
  637. write_coord(aimOrigin[2])
  638. write_short(id)
  639. write_byte(decal)
  640. message_end()
  641. }
  642. }
  643.  
  644.  
  645. //block anim standart wpn
  646. public UpdateClientData_Post( id, sendweapons, cd_handle ){
  647. if ( !is_alive[id] ) return FMRES_IGNORED;
  648. if(haswhpnnmg[id] && has_minigun[id]) set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );
  649. return FMRES_HANDLED;
  650. }
  651.  
  652.  
  653.  
  654. // No recoil stuff
  655.  
  656. public fwPrecacheEvent(type, const name[]) {
  657. for (new i = 0; i < sizeof g_guns_events; ++i) {
  658. if (equal(g_guns_events[i], name)) {
  659. g_guns_eventids_bitsum |= (1<<get_orig_retval())
  660. return FMRES_HANDLED
  661. }
  662. }
  663.  
  664. return FMRES_IGNORED
  665. }
  666. public fwPlaybackEvent(flags, invoker, eventid) {
  667. if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_MaxPlayers)|| !haswhpnnmg[invoker] || !has_minigun[invoker])
  668. return FMRES_IGNORED
  669.  
  670. g_fix_punchangle[invoker] = true
  671.  
  672. return FMRES_HANDLED
  673. }
  674.  
  675. public fwPlayerPostThink(id) {
  676. if (g_fix_punchangle[id]) {
  677. g_fix_punchangle[id] = false
  678. set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0})
  679. return FMRES_HANDLED
  680. }
  681.  
  682. return FMRES_IGNORED
  683. }
  684.  
  685. public fwTraceLine(const Float:start[3], const Float:dest[3], ignore_monsters, id, ptr) {
  686. if (!(1 <= id <= g_MaxPlayers))
  687. return FMRES_IGNORED
  688.  
  689. if (!g_normal_trace[id]) {
  690. g_normal_trace[id] = ptr
  691. return FMRES_HANDLED
  692. }
  693. if (ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || !haswhpnnmg[id] || !has_minigun[id] || !is_alive[id])
  694. return FMRES_IGNORED
  695.  
  696. fix_recoil_trace(id, start, ptr)
  697.  
  698. return FMRES_SUPERCEDE
  699. }
  700. // show ammo clip
  701. public ammo_hud(id) {
  702. if(!delayhud[id]) {
  703. delayhud[id] = true
  704. new AmmoHud[65]
  705. new clip = clipp[id]
  706. format(AmmoHud, 64, "Ammo: %i", clip)
  707. set_hudmessage(200, 100, 0, 1.0 , 1.0, 0, 0.1, 0.1,0.1)
  708. show_hudmessage(id,"%s",AmmoHud)
  709. set_task(0.2,"delayhutmsg",id)
  710. }
  711. }
  712.  
  713. public delayhutmsg(id){
  714. delayhud[id]= false
  715. }
  716.  
  717. //get weapon id
  718. stock get_weapon_ent(id,wpnid=0,wpnName[]="")
  719. {
  720. // who knows what wpnName will be
  721. static newName[24];
  722.  
  723. // need to find the name
  724. if(wpnid) get_weaponname(wpnid,newName,23);
  725.  
  726. // go with what we were told
  727. else formatex(newName,23,"%s",wpnName);
  728.  
  729. // prefix it if we need to
  730. if(!equal(newName,"weapon_",7))
  731. format(newName,23,"weapon_%s",newName);
  732.  
  733. return fm_find_ent_by_owner(get_maxplayers(),newName,id);
  734. }
  735.  
  736. fix_recoil_trace(id, const Float:start[], ptr) {
  737. static Float:dest[3]
  738. pev(id, pev_v_angle, dest)
  739. engfunc(EngFunc_MakeVectors, dest)
  740. global_get(glb_v_forward, dest)
  741. xs_vec_mul_scalar(dest, 9999.0, dest)
  742. xs_vec_add(start, dest, dest)
  743. engfunc(EngFunc_TraceLine, start, dest, DONT_IGNORE_MONSTERS, id, ptr)
  744. }
  745. // Get User Team
  746. stock fm_cs_get_user_team(id)
  747. {
  748. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  749. }

Ők köszönték meg stupid nek ezt a hozzászólást: Applee (2013.08.27. 19:55)
  Népszerűség: 2.27%


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  [ 5 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 2 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 és a hlmod.hu csapata
Portal: Kiss Portal Extension © Michael O'Toole