hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.26. 13:14



Jelenlévő felhasználók

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

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

Regisztrált felhasználók: Bing [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  [ 17 hozzászólás ]  Oldal Előző 1 2
Szerző Üzenet
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 11:50 
Offline
Senior Tag

Csatlakozott: 2012.07.09. 11:57
Hozzászólások: 234
Megköszönt másnak: 20 alkalommal
Megköszönték neki: 12 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6.  
  7. #define PLUGIN "OICW"
  8. #define VERSION "1.0"
  9. #define AUTHOR "Dias"
  10.  
  11. #define V_MODEL "models/v_oicw.mdl"
  12. #define P_MODEL "models/p_oicw.mdl"
  13. #define W_MODEL "models/w_oicw.mdl"
  14. #define S_MODEL "models/s_oicw.mdl"
  15.  
  16. #define CSW_OICW CSW_M4A1
  17. #define weapon_oicw "weapon_m4a1"
  18. #define OLD_W_MODEL "models/w_m4a1.mdl"
  19. #define WEAPON_EVENT "events/m4a1.sc"
  20. #define WEAPON_SECRETCODE 1992
  21.  
  22. #define DAMAGE 31
  23. #define GRENADE_DAMAGE 150
  24. #define GRENADE_RADIUS 150
  25. #define BPAMMO 90
  26. #define GRENADE_DEFAULT 6
  27. #define RELOAD_TIME 3.5
  28. #define GRENADE_RELOAD_TIME 3.0
  29. #define CHANGE_TIME 1.0
  30.  
  31. #define TASK_CHANGE 1987
  32.  
  33. new const WeaponSounds[8][] =
  34. {
  35. "weapons/oicw-1.wav",
  36. "weapons/oicw_grenade_shoot1.wav",
  37. "weapons/oicw_grenade_shoot2.wav",
  38. "weapons/oicw_foley1.wav",
  39. "weapons/oicw_foley2.wav",
  40. "weapons/oicw_foley3.wav",
  41. "weapons/oicw_move_carbine.wav",
  42. "weapons/oicw_move_grenade.wav"
  43. }
  44.  
  45. new const WeaponResources[3][] =
  46. {
  47. "sprites/weapon_oicw.txt",
  48. "sprites/640hud7_2.spr",
  49. "sprites/640hud79_2.spr"
  50. }
  51.  
  52. enum
  53. {
  54. ANIM_CARBINE_IDLE = 0,
  55. ANIM_CARBINE_SHOOT1,
  56. ANIM_CARBINE_SHOOT2,
  57. ANIM_CARBINE_SHOOT3,
  58. ANIM_CARBINE_RELOAD,
  59. ANIM_CARBINE_DRAW,
  60. ANIM_GRENADE_IDLE,
  61. ANIM_GRENADE_SHOOT1,
  62. ANIM_GRENADE_SHOOT2,
  63. ANIM_MOVE_TO_GRENADE,
  64. ANIM_MOVE_TO_CARBINE
  65. }
  66.  
  67. enum
  68. {
  69. OICW_MODE_CARBINE = 1,
  70. OICW_MODE_GRENADE
  71. }
  72.  
  73. new g_Had_Oicw[33], g_WeaponMode[33], g_IsChanging[33], g_GrenadeAmmo[33]
  74. new g_old_weapon[33], g_smokepuff_id, g_ham_bot, shells_model, g_oiwc_event, spr_trail, g_expspr_id, g_SmokeSprId
  75.  
  76. public plugin_init()
  77. {
  78. register_plugin(PLUGIN, VERSION, AUTHOR)
  79.  
  80. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  81.  
  82. register_forward(FM_Think, "fw_Think")
  83. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  84. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  85. register_forward(FM_SetModel, "fw_SetModel")
  86. register_forward(FM_CmdStart, "fw_CmdStart")
  87.  
  88. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  89. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  90. RegisterHam(Ham_Weapon_Reload, weapon_oicw, "fw_Weapon_Reload")
  91. RegisterHam(Ham_Weapon_Reload, weapon_oicw, "fw_Weapon_Reload_Post", 1)
  92. RegisterHam(Ham_Weapon_WeaponIdle, weapon_oicw, "fw_Weapon_WeaponIdle_Post", 1)
  93. RegisterHam(Ham_Item_AddToPlayer, weapon_oicw, "fw_Item_AddToPlayer_Post", 1)
  94.  
  95. register_clcmd("admin_get_oicw", "Get_OICW", ADMIN_KICK)
  96. register_clcmd("weapon_oicw", "hook_weapon")
  97. }
  98.  
  99. public plugin_precache()
  100. {
  101. engfunc(EngFunc_PrecacheModel, V_MODEL)
  102. engfunc(EngFunc_PrecacheModel, P_MODEL)
  103. engfunc(EngFunc_PrecacheModel, W_MODEL)
  104. engfunc(EngFunc_PrecacheModel, S_MODEL)
  105.  
  106. new i
  107. for(i = 0; i < sizeof(WeaponSounds); i++)
  108. engfunc(EngFunc_PrecacheSound, WeaponSounds[i])
  109. for(i = 0; i < sizeof(WeaponResources); i++)
  110. {
  111. if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResources[i])
  112. else engfunc(EngFunc_PrecacheModel, WeaponResources[i])
  113. }
  114.  
  115. g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  116. shells_model = engfunc(EngFunc_PrecacheModel, "models/rshell.mdl")
  117. spr_trail = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
  118. g_expspr_id = engfunc(EngFunc_PrecacheModel, "sprites/zerogxplode.spr")
  119. g_SmokeSprId = engfunc(EngFunc_PrecacheModel, "sprites/steam1.spr")
  120.  
  121. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  122. }
  123.  
  124. public fw_PrecacheEvent_Post(type, const name[])
  125. {
  126. if(equal(WEAPON_EVENT, name))
  127. g_oiwc_event = get_orig_retval()
  128. }
  129.  
  130. public Get_OICW(id)
  131. {
  132. if(!is_user_alive(id))
  133. return
  134.  
  135. g_Had_Oicw[id] = 1
  136. g_WeaponMode[id] = OICW_MODE_CARBINE
  137. g_IsChanging[id] = 0
  138. g_GrenadeAmmo[id] = GRENADE_DEFAULT
  139.  
  140. fm_give_item(id, weapon_oicw)
  141.  
  142. cs_set_user_bpammo(id, CSW_OICW, BPAMMO)
  143. update_ammo(id)
  144. }
  145.  
  146. public update_ammo(id)
  147. {
  148. if(!is_user_alive(id))
  149. return
  150.  
  151. static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_oicw, id)
  152. if(pev_valid(weapon_ent))
  153. {
  154. engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
  155. write_byte(1)
  156. write_byte(CSW_OICW)
  157. write_byte(cs_get_weapon_ammo(weapon_ent))
  158. message_end()
  159. }
  160.  
  161. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  162. write_byte(1)
  163. write_byte(cs_get_user_bpammo(id, CSW_OICW))
  164. message_end()
  165. }
  166.  
  167. public Remove_OICW(id)
  168. {
  169. if(!is_user_connected(id))
  170. return
  171.  
  172. g_Had_Oicw[id] = 0
  173. }
  174.  
  175. public hook_weapon(id)
  176. {
  177. engclient_cmd(id, weapon_oicw)
  178. return PLUGIN_HANDLED
  179. }
  180.  
  181. public client_putinserver(id)
  182. {
  183. if(!g_ham_bot && is_user_bot(id))
  184. {
  185. g_ham_bot = 1
  186. set_task(0.1, "Do_Register_HamBot", id)
  187. }
  188. }
  189.  
  190. public Do_Register_HamBot(id)
  191. {
  192. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  193. }
  194.  
  195. public Event_CurWeapon(id)
  196. {
  197. if(!is_user_alive(id))
  198. return
  199.  
  200. if((get_user_weapon(id) == CSW_OICW && g_Had_Oicw[id]) && g_old_weapon[id] != CSW_OICW)
  201. { // Draw
  202. set_pev(id, pev_viewmodel2, V_MODEL)
  203. set_pev(id, pev_weaponmodel2, P_MODEL)
  204.  
  205. if(g_WeaponMode[id] == OICW_MODE_GRENADE)
  206. {
  207. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_OICW)
  208. update_ammo2(id, pev(Ent, pev_iuser3), pev(Ent, pev_iuser4))
  209. }
  210. g_WeaponMode[id] = OICW_MODE_CARBINE
  211.  
  212. set_weapon_anim(id, ANIM_CARBINE_DRAW)
  213. } else {
  214. g_IsChanging[id] = 0
  215. }
  216.  
  217. g_old_weapon[id] = get_user_weapon(id)
  218. }
  219.  
  220. public fw_Think(ent)
  221. {
  222. if(!pev_valid(ent))
  223. return
  224.  
  225. static Classname[32]
  226. pev(ent, pev_classname, Classname, sizeof(Classname))
  227.  
  228. if(!equal(Classname, "grenade2"))
  229. return
  230.  
  231. Make_Explosion(ent)
  232. engfunc(EngFunc_RemoveEntity, ent)
  233. }
  234.  
  235. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  236. {
  237. if(!is_user_alive(id) || !is_user_connected(id))
  238. return FMRES_IGNORED
  239. if(get_user_weapon(id) == CSW_OICW && g_Had_Oicw[id])
  240. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  241.  
  242. return FMRES_HANDLED
  243. }
  244.  
  245. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  246. {
  247. if (!is_user_connected(invoker))
  248. return FMRES_IGNORED
  249. if(get_user_weapon(invoker) != CSW_OICW || !g_Had_Oicw[invoker])
  250. return FMRES_IGNORED
  251.  
  252. if(eventid == g_oiwc_event)
  253. {
  254. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  255.  
  256. set_weapon_anim(invoker, random_num(ANIM_CARBINE_SHOOT1, ANIM_CARBINE_SHOOT3))
  257. emit_sound(invoker, CHAN_WEAPON, WeaponSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  258.  
  259. make_shell(invoker)
  260.  
  261. return FMRES_SUPERCEDE
  262. }
  263.  
  264. return FMRES_HANDLED
  265. }
  266.  
  267. public fw_SetModel(entity, model[])
  268. {
  269. if(!pev_valid(entity))
  270. return FMRES_IGNORED
  271.  
  272. static Classname[32]
  273. pev(entity, pev_classname, Classname, sizeof(Classname))
  274.  
  275. if(!equal(Classname, "weaponbox"))
  276. return FMRES_IGNORED
  277.  
  278. static iOwner
  279. iOwner = pev(entity, pev_owner)
  280.  
  281. if(equal(model, OLD_W_MODEL))
  282. {
  283. static weapon; weapon = fm_find_ent_by_owner(-1, weapon_oicw, entity)
  284.  
  285. if(!pev_valid(weapon))
  286. return FMRES_IGNORED;
  287.  
  288. if(g_Had_Oicw[iOwner])
  289. {
  290. g_Had_Oicw[iOwner] = 0
  291.  
  292. set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  293. engfunc(EngFunc_SetModel, entity, W_MODEL)
  294.  
  295. return FMRES_SUPERCEDE
  296. }
  297. }
  298.  
  299. return FMRES_IGNORED;
  300. }
  301.  
  302. public fw_CmdStart(id, uc_handle, seed)
  303. {
  304. if(!is_user_alive(id))
  305. return FMRES_IGNORED
  306. if(get_user_weapon(id) != CSW_OICW || !g_Had_Oicw[id])
  307. return FMRES_IGNORED
  308.  
  309. static NewButton; NewButton = get_uc(uc_handle, UC_Buttons)
  310.  
  311. if(NewButton & IN_ATTACK)
  312. {
  313. if(g_IsChanging[id])
  314. {
  315. NewButton &= ~IN_ATTACK
  316. set_uc(uc_handle, UC_Buttons, NewButton)
  317.  
  318. return FMRES_IGNORED
  319. }
  320.  
  321. if(g_WeaponMode[id] != OICW_MODE_GRENADE)
  322. return FMRES_IGNORED
  323.  
  324. NewButton &= ~IN_ATTACK
  325. set_uc(uc_handle, UC_Buttons, NewButton)
  326.  
  327. Shoot_Grenade_Handle(id)
  328. }
  329.  
  330. if(NewButton & IN_ATTACK2) {
  331. NewButton &= ~IN_ATTACK2
  332. set_uc(uc_handle, UC_Buttons, NewButton)
  333.  
  334. NewButton &= ~IN_ATTACK
  335. set_uc(uc_handle, UC_Buttons, NewButton)
  336.  
  337. if((pev(id, pev_oldbuttons) & IN_ATTACK2))
  338. return FMRES_IGNORED
  339. if(get_pdata_float(id, 83, 5) > 0.0)
  340. return FMRES_IGNORED
  341.  
  342. g_IsChanging[id] = 1
  343.  
  344. set_weapons_timeidle(id, CHANGE_TIME + 0.1)
  345. set_player_nextattack(id, CHANGE_TIME)
  346.  
  347. set_weapon_anim(id, g_WeaponMode[id] == OICW_MODE_CARBINE ? ANIM_MOVE_TO_GRENADE : ANIM_MOVE_TO_CARBINE)
  348. set_task(CHANGE_TIME, "OICW_CHANGE_COMPLETE", id+TASK_CHANGE)
  349. }
  350.  
  351. return FMRES_IGNORED
  352. }
  353.  
  354. public OICW_CHANGE_COMPLETE(id)
  355. {
  356. id -= TASK_CHANGE
  357.  
  358. if(!is_user_alive(id))
  359. return
  360. if(get_user_weapon(id) != CSW_OICW || !g_Had_Oicw[id])
  361. return
  362. if(!g_IsChanging[id])
  363. return
  364.  
  365. g_IsChanging[id] = 0
  366.  
  367. if(g_WeaponMode[id] == OICW_MODE_CARBINE) g_WeaponMode[id] = OICW_MODE_GRENADE
  368. else if(g_WeaponMode[id] == OICW_MODE_GRENADE) g_WeaponMode[id] = OICW_MODE_CARBINE
  369.  
  370. Change_Complete(id, g_WeaponMode[id])
  371. }
  372.  
  373. public Shoot_Grenade_Handle(id)
  374. {
  375. if(get_pdata_float(id, 83, 5) > 0.0)
  376. return
  377. if(g_WeaponMode[id] != OICW_MODE_GRENADE)
  378. return
  379. if(g_IsChanging[id])
  380. return
  381. if(!g_GrenadeAmmo[id])
  382. {
  383. client_print(id, print_center, "Out Of Ammo")
  384. set_pdata_float(id, 83, 1.0, 5)
  385.  
  386. return
  387. }
  388.  
  389. g_GrenadeAmmo[id]--
  390. update_ammo2(id, -1, g_GrenadeAmmo[id])
  391.  
  392. static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, "weapon_knife", id)
  393. if(pev_valid(weapon_ent)) ExecuteHamB(Ham_Weapon_PrimaryAttack, weapon_ent)
  394.  
  395. if(g_GrenadeAmmo[id])
  396. {
  397. set_weapons_timeidle(id, GRENADE_RELOAD_TIME + 0.1)
  398. set_player_nextattack(id, GRENADE_RELOAD_TIME)
  399.  
  400. set_weapon_anim(id, ANIM_GRENADE_SHOOT1)
  401. emit_sound(id, CHAN_WEAPON, WeaponSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  402. } else {
  403. set_weapons_timeidle(id, (GRENADE_RELOAD_TIME / 3.0) + 0.1)
  404. set_player_nextattack(id, (GRENADE_RELOAD_TIME / 3.0))
  405.  
  406. set_weapon_anim(id, ANIM_GRENADE_SHOOT2)
  407. emit_sound(id, CHAN_WEAPON, WeaponSounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  408. }
  409.  
  410. static Float:PunchAngles[3]
  411. PunchAngles[0] = random_float(-2.0, -4.0)
  412. PunchAngles[2] = random_float(5.0, -5.0)
  413.  
  414. set_pev(id, pev_punchangle, PunchAngles)
  415.  
  416. Create_Grenade(id)
  417. }
  418.  
  419. public Create_Grenade(id)
  420. {
  421. static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  422. if(!pev_valid(Ent)) return
  423.  
  424. static Float:Origin[3], Float:Angles[3]
  425.  
  426. get_weapon_attachment(id, Origin, 24.0)
  427. pev(id, pev_angles, Angles)
  428.  
  429. set_pev(Ent, pev_movetype, MOVETYPE_PUSHSTEP)
  430. set_pev(Ent, pev_solid, SOLID_BBOX)
  431. set_pev(Ent, pev_nextthink, get_gametime() + 2.5)
  432.  
  433. set_pev(Ent, pev_classname, "grenade2")
  434. engfunc(EngFunc_SetModel, Ent, S_MODEL)
  435. set_pev(Ent, pev_origin, Origin)
  436. set_pev(Ent, pev_angles, Angles)
  437. set_pev(Ent, pev_owner, id)
  438.  
  439. // Create Velocity
  440. static Float:Velocity[3], Float:TargetOrigin[3]
  441.  
  442. fm_get_aim_origin(id, TargetOrigin)
  443. get_speed_vector(Origin, TargetOrigin, 900.0, Velocity)
  444.  
  445. set_pev(Ent, pev_velocity, Velocity)
  446.  
  447. // Make a Beam
  448. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  449. write_byte(TE_BEAMFOLLOW)
  450. write_short(Ent) // entity
  451. write_short(spr_trail) // sprite
  452. write_byte(20) // life
  453. write_byte(2) // width
  454. write_byte(200) // r
  455. write_byte(200); // g
  456. write_byte(200); // b
  457. write_byte(200); // brightness
  458. message_end();
  459. }
  460.  
  461. public Make_Explosion(ent)
  462. {
  463. static Float:Origin[3]
  464. pev(ent, pev_origin, Origin)
  465.  
  466. message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
  467. write_byte(TE_EXPLOSION)
  468. engfunc(EngFunc_WriteCoord, Origin[0])
  469. engfunc(EngFunc_WriteCoord, Origin[1])
  470. engfunc(EngFunc_WriteCoord, Origin[2])
  471. write_short(g_expspr_id) // sprite index
  472. write_byte(30) // scale in 0.1's
  473. write_byte(30) // framerate
  474. write_byte(0) // flags
  475. message_end()
  476.  
  477. // Put decal on "world" (a wall)
  478. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  479. write_byte(TE_WORLDDECAL)
  480. engfunc(EngFunc_WriteCoord, Origin[0])
  481. engfunc(EngFunc_WriteCoord, Origin[1])
  482. engfunc(EngFunc_WriteCoord, Origin[2])
  483. write_byte(random_num(46, 48))
  484. message_end()
  485.  
  486. message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
  487. write_byte(TE_SMOKE)
  488. engfunc(EngFunc_WriteCoord, Origin[0])
  489. engfunc(EngFunc_WriteCoord, Origin[1])
  490. engfunc(EngFunc_WriteCoord, Origin[2])
  491. write_short(g_SmokeSprId) // sprite index
  492. write_byte(30) // scale in 0.1's
  493. write_byte(10) // framerate
  494. message_end()
  495.  
  496. static Float:Origin2[3]
  497.  
  498. for(new i = 0; i < get_maxplayers(); i++)
  499. {
  500. if(!is_user_alive(i))
  501. continue
  502. pev(i, pev_origin, Origin2)
  503. if(get_distance_f(Origin, Origin2) > float(GRENADE_RADIUS))
  504. continue
  505.  
  506. ExecuteHamB(Ham_TakeDamage, i, 0, pev(ent, pev_owner), float(GRENADE_DAMAGE), DMG_BULLET)
  507. }
  508. }
  509.  
  510. public Change_Complete(id, Mode)
  511. {
  512. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_OICW)
  513. if(!pev_valid(Ent))
  514. return
  515.  
  516. if(Mode == OICW_MODE_CARBINE)
  517. {
  518. update_ammo2(id, pev(Ent, pev_iuser3), pev(Ent, pev_iuser4))
  519. } else if(Mode == OICW_MODE_GRENADE) {
  520. set_pev(Ent, pev_iuser3, cs_get_weapon_ammo(Ent))
  521. set_pev(Ent, pev_iuser4, cs_get_user_bpammo(id, CSW_OICW))
  522.  
  523. update_ammo2(id, -1, g_GrenadeAmmo[id])
  524. }
  525. }
  526.  
  527. public fw_TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
  528. {
  529. if(!is_user_alive(attacker) || !is_user_connected(attacker))
  530. return HAM_IGNORED
  531. if(get_user_weapon(attacker) != CSW_OICW || !g_Had_Oicw[attacker])
  532. return HAM_IGNORED
  533.  
  534. static Float:flEnd[3], Float:vecPlane[3]
  535.  
  536. get_tr2(ptr, TR_vecEndPos, flEnd)
  537. get_tr2(ptr, TR_vecPlaneNormal, vecPlane)
  538.  
  539. if(!is_user_alive(ent))
  540. {
  541. make_bullet(attacker, flEnd)
  542. fake_smoke(attacker, ptr)
  543. }
  544.  
  545. SetHamParamFloat(3, float(DAMAGE))
  546.  
  547. return HAM_HANDLED
  548. }
  549.  
  550. public fw_Weapon_Reload(ent)
  551. {
  552. static id; id = pev(ent, pev_owner)
  553. if(!is_user_alive(id))
  554. return HAM_IGNORED
  555. if(!g_Had_Oicw[id])
  556. return HAM_IGNORED
  557. if(g_WeaponMode[id] == OICW_MODE_GRENADE)
  558. return HAM_SUPERCEDE
  559.  
  560. return HAM_HANDLED
  561. }
  562.  
  563. public fw_Weapon_Reload_Post(ent)
  564. {
  565. static id; id = pev(ent, pev_owner)
  566. if(!is_user_alive(id))
  567. return HAM_IGNORED
  568. if(!g_Had_Oicw[id])
  569. return HAM_IGNORED
  570. if(g_WeaponMode[id] == OICW_MODE_GRENADE)
  571. return HAM_IGNORED
  572.  
  573. if((get_pdata_int(ent, 54, 4) == 1) && g_WeaponMode[id] == OICW_MODE_CARBINE)
  574. { // Reload
  575. set_weapon_anim(id, ANIM_CARBINE_RELOAD)
  576. set_pdata_float(id, 83, RELOAD_TIME, 5)
  577. }
  578.  
  579. return HAM_HANDLED
  580. }
  581.  
  582. public fw_Weapon_WeaponIdle_Post(ent)
  583. {
  584. static id; id = pev(ent, pev_owner)
  585. if(!is_user_alive(id))
  586. return HAM_IGNORED
  587. if(!g_Had_Oicw[id])
  588. return HAM_IGNORED
  589.  
  590. if(get_pdata_float(ent, 48, 4) <= 0.1)
  591. {
  592. set_weapon_anim(id, g_WeaponMode[id] == OICW_MODE_CARBINE ? ANIM_CARBINE_IDLE : ANIM_GRENADE_IDLE)
  593. set_pdata_float(ent, 48, 20.0, 4)
  594. }
  595.  
  596. return HAM_IGNORED
  597. }
  598.  
  599. public fw_Item_AddToPlayer_Post(ent, id)
  600. {
  601. if(!pev_valid(ent))
  602. return HAM_IGNORED
  603.  
  604. if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  605. {
  606. g_Had_Oicw[id] = 1
  607. set_pev(ent, pev_impulse, 0)
  608. }
  609.  
  610. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), .player = id)
  611. write_string(g_Had_Oicw[id] == 1 ? "weapon_oicw" : "weapon_m4a1")
  612. write_byte(4) // PrimaryAmmoID
  613. write_byte(90) // PrimaryAmmoMaxAmount
  614. write_byte(-1) // SecondaryAmmoID
  615. write_byte(-1) // SecondaryAmmoMaxAmount
  616. write_byte(0) // SlotID (0...N)
  617. write_byte(6) // NumberInSlot (1...N)
  618. write_byte(g_Had_Oicw[id] == 1 ? CSW_OICW : CSW_M4A1) // WeaponID
  619. write_byte(0) // Flags
  620. message_end()
  621.  
  622. return HAM_HANDLED
  623. }
  624.  
  625. stock make_bullet(id, Float:Origin[3])
  626. {
  627. // Find target
  628. new decal = random_num(41, 45)
  629. const loop_time = 2
  630.  
  631. static Body, Target
  632. get_user_aiming(id, Target, Body, 999999)
  633.  
  634. if(is_user_connected(Target))
  635. return
  636.  
  637. for(new i = 0; i < loop_time; i++)
  638. {
  639. // Put decal on "world" (a wall)
  640. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  641. write_byte(TE_WORLDDECAL)
  642. engfunc(EngFunc_WriteCoord, Origin[0])
  643. engfunc(EngFunc_WriteCoord, Origin[1])
  644. engfunc(EngFunc_WriteCoord, Origin[2])
  645. write_byte(decal)
  646. message_end()
  647.  
  648. // Show sparcles
  649. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  650. write_byte(TE_GUNSHOTDECAL)
  651. engfunc(EngFunc_WriteCoord, Origin[0])
  652. engfunc(EngFunc_WriteCoord, Origin[1])
  653. engfunc(EngFunc_WriteCoord, Origin[2])
  654. write_short(id)
  655. write_byte(decal)
  656. message_end()
  657. }
  658. }
  659.  
  660. public fake_smoke(id, trace_result)
  661. {
  662. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  663.  
  664. get_weapon_attachment(id, vecSrc)
  665. global_get(glb_v_forward, vecEnd)
  666.  
  667. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  668. xs_vec_add(vecSrc, vecEnd, vecEnd)
  669.  
  670. get_tr2(trace_result, TR_vecEndPos, vecSrc)
  671. get_tr2(trace_result, TR_vecPlaneNormal, vecEnd)
  672.  
  673. xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  674. xs_vec_add(vecSrc, vecEnd, vecEnd)
  675.  
  676. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  677. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  678. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  679.  
  680. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  681. write_byte(TE_EXPLOSION)
  682. engfunc(EngFunc_WriteCoord, vecEnd[0])
  683. engfunc(EngFunc_WriteCoord, vecEnd[1])
  684. engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  685. write_short(g_smokepuff_id)
  686. write_byte(2)
  687. write_byte(50)
  688. write_byte(TE_FLAG)
  689. message_end()
  690. }
  691.  
  692. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  693. {
  694. new Float:vfEnd[3], viEnd[3]
  695. get_user_origin(id, viEnd, 3)
  696. IVecFVec(viEnd, vfEnd)
  697.  
  698. new Float:fOrigin[3], Float:fAngle[3]
  699.  
  700. pev(id, pev_origin, fOrigin)
  701. pev(id, pev_view_ofs, fAngle)
  702.  
  703. xs_vec_add(fOrigin, fAngle, fOrigin)
  704.  
  705. new Float:fAttack[3]
  706.  
  707. xs_vec_sub(vfEnd, fOrigin, fAttack)
  708. xs_vec_sub(vfEnd, fOrigin, fAttack)
  709.  
  710. new Float:fRate
  711.  
  712. fRate = fDis / vector_length(fAttack)
  713. xs_vec_mul_scalar(fAttack, fRate, fAttack)
  714.  
  715. xs_vec_add(fOrigin, fAttack, output)
  716. }
  717.  
  718. stock set_weapon_anim(id, anim)
  719. {
  720. if(!is_user_alive(id))
  721. return
  722.  
  723. set_pev(id, pev_weaponanim, anim)
  724.  
  725. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  726. write_byte(anim)
  727. write_byte(pev(id, pev_body))
  728. message_end()
  729. }
  730.  
  731. public make_shell(id)
  732. {
  733. static Float:player_origin[3], Float:origin[3], Float:origin2[3], Float:gunorigin[3], Float:oldangles[3], Float:v_forward[3], Float:v_forward2[3], Float:v_up[3], Float:v_up2[3], Float:v_right[3], Float:v_right2[3], Float:viewoffsets[3];
  734.  
  735. pev(id,pev_v_angle, oldangles); pev(id,pev_origin,player_origin); pev(id, pev_view_ofs, viewoffsets);
  736.  
  737. engfunc(EngFunc_MakeVectors, oldangles)
  738.  
  739. global_get(glb_v_forward, v_forward); global_get(glb_v_up, v_up); global_get(glb_v_right, v_right);
  740. global_get(glb_v_forward, v_forward2); global_get(glb_v_up, v_up2); global_get(glb_v_right, v_right2);
  741.  
  742. xs_vec_add(player_origin, viewoffsets, gunorigin);
  743.  
  744. xs_vec_mul_scalar(v_forward, 10.3, v_forward); xs_vec_mul_scalar(v_right, 2.9, v_right);
  745. xs_vec_mul_scalar(v_up, -3.7, v_up);
  746. xs_vec_mul_scalar(v_forward2, 10.0, v_forward2); xs_vec_mul_scalar(v_right2, 3.0, v_right2);
  747. xs_vec_mul_scalar(v_up2, -4.0, v_up2);
  748.  
  749. xs_vec_add(gunorigin, v_forward, origin);
  750. xs_vec_add(gunorigin, v_forward2, origin2);
  751. xs_vec_add(origin, v_right, origin);
  752. xs_vec_add(origin2, v_right2, origin2);
  753. xs_vec_add(origin, v_up, origin);
  754. xs_vec_add(origin2, v_up2, origin2);
  755.  
  756. static Float:velocity[3]
  757. get_speed_vector(origin2, origin, random_float(140.0, 160.0), velocity)
  758.  
  759. static angle; angle = random_num(0, 360)
  760.  
  761. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  762. write_byte(TE_MODEL)
  763. engfunc(EngFunc_WriteCoord, origin[0])
  764. engfunc(EngFunc_WriteCoord,origin[1])
  765. engfunc(EngFunc_WriteCoord,origin[2])
  766. engfunc(EngFunc_WriteCoord,velocity[0])
  767. engfunc(EngFunc_WriteCoord,velocity[1])
  768. engfunc(EngFunc_WriteCoord,velocity[2])
  769. write_angle(angle)
  770. write_short(shells_model)
  771. write_byte(1)
  772. write_byte(20)
  773. message_end()
  774. }
  775.  
  776. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  777. {
  778. new_velocity[0] = origin2[0] - origin1[0]
  779. new_velocity[1] = origin2[1] - origin1[1]
  780. new_velocity[2] = origin2[2] - origin1[2]
  781. new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  782. new_velocity[0] *= num
  783. new_velocity[1] *= num
  784. new_velocity[2] *= num
  785.  
  786. return 1;
  787. }
  788.  
  789. stock set_weapons_timeidle(id, Float:TimeIdle)
  790. {
  791. if(!is_user_alive(id))
  792. return
  793.  
  794. new entwpn = fm_get_user_weapon_entity(id, CSW_OICW)
  795. if(!pev_valid(entwpn))
  796. return
  797.  
  798. set_pdata_float(entwpn, 46, TimeIdle, 4)
  799. set_pdata_float(entwpn, 47, TimeIdle, 4)
  800. set_pdata_float(entwpn, 48, TimeIdle + 1.0, 4)
  801. }
  802.  
  803. stock set_player_nextattack(id, Float:nexttime)
  804. {
  805. if(!is_user_alive(id))
  806. return
  807.  
  808. set_pdata_float(id, 83, nexttime, 5)
  809. }
  810.  
  811. public update_ammo2(id, ammo, bpammo)
  812. {
  813. if(!is_user_alive(id))
  814. return
  815.  
  816. engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
  817. write_byte(1)
  818. write_byte(CSW_OICW)
  819. write_byte(ammo)
  820. message_end()
  821.  
  822. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  823. write_byte(1)
  824. write_byte(bpammo)
  825. message_end()
  826.  
  827. cs_set_user_bpammo(id, CSW_OICW, bpammo)
  828. }
  829. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  830. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  831. */
  832.  

_________________
[mozgo]Bogdan for President[/mozgo]
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 11:54 
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: 85 alkalommal
oicw parancsra előjön!

SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6.  
  7. #define PLUGIN "OICW"
  8. #define VERSION "1.0"
  9. #define AUTHOR "Dias"
  10.  
  11. #define V_MODEL "models/v_oicw.mdl"
  12. #define P_MODEL "models/p_oicw.mdl"
  13. #define W_MODEL "models/w_oicw.mdl"
  14. #define S_MODEL "models/s_oicw.mdl"
  15.  
  16. #define CSW_OICW CSW_M4A1
  17. #define weapon_oicw "weapon_m4a1"
  18. #define OLD_W_MODEL "models/w_m4a1.mdl"
  19. #define WEAPON_EVENT "events/m4a1.sc"
  20. #define WEAPON_SECRETCODE 1992
  21.  
  22. #define DAMAGE 31
  23. #define GRENADE_DAMAGE 150
  24. #define GRENADE_RADIUS 150
  25. #define BPAMMO 90
  26. #define GRENADE_DEFAULT 6
  27. #define RELOAD_TIME 3.5
  28. #define GRENADE_RELOAD_TIME 3.0
  29. #define CHANGE_TIME 1.0
  30.  
  31. #define TASK_CHANGE 1987
  32.  
  33. new const WeaponSounds[8][] =
  34. {
  35. "weapons/oicw-1.wav",
  36. "weapons/oicw_grenade_shoot1.wav",
  37. "weapons/oicw_grenade_shoot2.wav",
  38. "weapons/oicw_foley1.wav",
  39. "weapons/oicw_foley2.wav",
  40. "weapons/oicw_foley3.wav",
  41. "weapons/oicw_move_carbine.wav",
  42. "weapons/oicw_move_grenade.wav"
  43. }
  44.  
  45. new const WeaponResources[3][] =
  46. {
  47. "sprites/weapon_oicw.txt",
  48. "sprites/640hud7_2.spr",
  49. "sprites/640hud79_2.spr"
  50. }
  51.  
  52. enum
  53. {
  54. ANIM_CARBINE_IDLE = 0,
  55. ANIM_CARBINE_SHOOT1,
  56. ANIM_CARBINE_SHOOT2,
  57. ANIM_CARBINE_SHOOT3,
  58. ANIM_CARBINE_RELOAD,
  59. ANIM_CARBINE_DRAW,
  60. ANIM_GRENADE_IDLE,
  61. ANIM_GRENADE_SHOOT1,
  62. ANIM_GRENADE_SHOOT2,
  63. ANIM_MOVE_TO_GRENADE,
  64. ANIM_MOVE_TO_CARBINE
  65. }
  66.  
  67. enum
  68. {
  69. OICW_MODE_CARBINE = 1,
  70. OICW_MODE_GRENADE
  71. }
  72.  
  73. new g_Had_Oicw[33], g_WeaponMode[33], g_IsChanging[33], g_GrenadeAmmo[33]
  74. new g_old_weapon[33], g_smokepuff_id, g_ham_bot, shells_model, g_oiwc_event, spr_trail, g_expspr_id, g_SmokeSprId
  75.  
  76. public plugin_init()
  77. {
  78. register_plugin(PLUGIN, VERSION, AUTHOR)
  79.  
  80. register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  81.  
  82. register_forward(FM_Think, "fw_Think")
  83. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  84. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  85. register_forward(FM_SetModel, "fw_SetModel")
  86. register_forward(FM_CmdStart, "fw_CmdStart")
  87.  
  88. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  89. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  90. RegisterHam(Ham_Weapon_Reload, weapon_oicw, "fw_Weapon_Reload")
  91. RegisterHam(Ham_Weapon_Reload, weapon_oicw, "fw_Weapon_Reload_Post", 1)
  92. RegisterHam(Ham_Weapon_WeaponIdle, weapon_oicw, "fw_Weapon_WeaponIdle_Post", 1)
  93. RegisterHam(Ham_Item_AddToPlayer, weapon_oicw, "fw_Item_AddToPlayer_Post", 1)
  94.  
  95. register_clcmd("oicw", "Get_OICW", ADMIN_KICK)
  96. register_clcmd("weapon_oicw", "hook_weapon")
  97. }
  98.  
  99. public plugin_precache()
  100. {
  101. engfunc(EngFunc_PrecacheModel, V_MODEL)
  102. engfunc(EngFunc_PrecacheModel, P_MODEL)
  103. engfunc(EngFunc_PrecacheModel, W_MODEL)
  104. engfunc(EngFunc_PrecacheModel, S_MODEL)
  105.  
  106. new i
  107. for(i = 0; i < sizeof(WeaponSounds); i++)
  108. engfunc(EngFunc_PrecacheSound, WeaponSounds[i])
  109. for(i = 0; i < sizeof(WeaponResources); i++)
  110. {
  111. if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResources[i])
  112. else engfunc(EngFunc_PrecacheModel, WeaponResources[i])
  113. }
  114.  
  115. g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
  116. shells_model = engfunc(EngFunc_PrecacheModel, "models/rshell.mdl")
  117. spr_trail = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
  118. g_expspr_id = engfunc(EngFunc_PrecacheModel, "sprites/zerogxplode.spr")
  119. g_SmokeSprId = engfunc(EngFunc_PrecacheModel, "sprites/steam1.spr")
  120.  
  121. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  122. }
  123.  
  124. public fw_PrecacheEvent_Post(type, const name[])
  125. {
  126. if(equal(WEAPON_EVENT, name))
  127. g_oiwc_event = get_orig_retval()
  128. }
  129.  
  130. public Get_OICW(id)
  131. {
  132. if(!is_user_alive(id))
  133. return
  134.  
  135. g_Had_Oicw[id] = 1
  136. g_WeaponMode[id] = OICW_MODE_CARBINE
  137. g_IsChanging[id] = 0
  138. g_GrenadeAmmo[id] = GRENADE_DEFAULT
  139.  
  140. fm_give_item(id, weapon_oicw)
  141.  
  142. cs_set_user_bpammo(id, CSW_OICW, BPAMMO)
  143. update_ammo(id)
  144. }
  145.  
  146. public update_ammo(id)
  147. {
  148. if(!is_user_alive(id))
  149. return
  150.  
  151. static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_oicw, id)
  152. if(pev_valid(weapon_ent))
  153. {
  154. engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
  155. write_byte(1)
  156. write_byte(CSW_OICW)
  157. write_byte(cs_get_weapon_ammo(weapon_ent))
  158. message_end()
  159. }
  160.  
  161. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  162. write_byte(1)
  163. write_byte(cs_get_user_bpammo(id, CSW_OICW))
  164. message_end()
  165. }
  166.  
  167. public Remove_OICW(id)
  168. {
  169. if(!is_user_connected(id))
  170. return
  171.  
  172. g_Had_Oicw[id] = 0
  173. }
  174.  
  175. public hook_weapon(id)
  176. {
  177. engclient_cmd(id, weapon_oicw)
  178. return PLUGIN_HANDLED
  179. }
  180.  
  181. public client_putinserver(id)
  182. {
  183. if(!g_ham_bot && is_user_bot(id))
  184. {
  185. g_ham_bot = 1
  186. set_task(0.1, "Do_Register_HamBot", id)
  187. }
  188. }
  189.  
  190. public Do_Register_HamBot(id)
  191. {
  192. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  193. }
  194.  
  195. public Event_CurWeapon(id)
  196. {
  197. if(!is_user_alive(id))
  198. return
  199.  
  200. if((get_user_weapon(id) == CSW_OICW && g_Had_Oicw[id]) && g_old_weapon[id] != CSW_OICW)
  201. { // Draw
  202. set_pev(id, pev_viewmodel2, V_MODEL)
  203. set_pev(id, pev_weaponmodel2, P_MODEL)
  204.  
  205. if(g_WeaponMode[id] == OICW_MODE_GRENADE)
  206. {
  207. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_OICW)
  208. update_ammo2(id, pev(Ent, pev_iuser3), pev(Ent, pev_iuser4))
  209. }
  210. g_WeaponMode[id] = OICW_MODE_CARBINE
  211.  
  212. set_weapon_anim(id, ANIM_CARBINE_DRAW)
  213. } else {
  214. g_IsChanging[id] = 0
  215. }
  216.  
  217. g_old_weapon[id] = get_user_weapon(id)
  218. }
  219.  
  220. public fw_Think(ent)
  221. {
  222. if(!pev_valid(ent))
  223. return
  224.  
  225. static Classname[32]
  226. pev(ent, pev_classname, Classname, sizeof(Classname))
  227.  
  228. if(!equal(Classname, "grenade2"))
  229. return
  230.  
  231. Make_Explosion(ent)
  232. engfunc(EngFunc_RemoveEntity, ent)
  233. }
  234.  
  235. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  236. {
  237. if(!is_user_alive(id) || !is_user_connected(id))
  238. return FMRES_IGNORED
  239. if(get_user_weapon(id) == CSW_OICW && g_Had_Oicw[id])
  240. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  241.  
  242. return FMRES_HANDLED
  243. }
  244.  
  245. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  246. {
  247. if (!is_user_connected(invoker))
  248. return FMRES_IGNORED
  249. if(get_user_weapon(invoker) != CSW_OICW || !g_Had_Oicw[invoker])
  250. return FMRES_IGNORED
  251.  
  252. if(eventid == g_oiwc_event)
  253. {
  254. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  255.  
  256. set_weapon_anim(invoker, random_num(ANIM_CARBINE_SHOOT1, ANIM_CARBINE_SHOOT3))
  257. emit_sound(invoker, CHAN_WEAPON, WeaponSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  258.  
  259. make_shell(invoker)
  260.  
  261. return FMRES_SUPERCEDE
  262. }
  263.  
  264. return FMRES_HANDLED
  265. }
  266.  
  267. public fw_SetModel(entity, model[])
  268. {
  269. if(!pev_valid(entity))
  270. return FMRES_IGNORED
  271.  
  272. static Classname[32]
  273. pev(entity, pev_classname, Classname, sizeof(Classname))
  274.  
  275. if(!equal(Classname, "weaponbox"))
  276. return FMRES_IGNORED
  277.  
  278. static iOwner
  279. iOwner = pev(entity, pev_owner)
  280.  
  281. if(equal(model, OLD_W_MODEL))
  282. {
  283. static weapon; weapon = fm_find_ent_by_owner(-1, weapon_oicw, entity)
  284.  
  285. if(!pev_valid(weapon))
  286. return FMRES_IGNORED;
  287.  
  288. if(g_Had_Oicw[iOwner])
  289. {
  290. g_Had_Oicw[iOwner] = 0
  291.  
  292. set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  293. engfunc(EngFunc_SetModel, entity, W_MODEL)
  294.  
  295. return FMRES_SUPERCEDE
  296. }
  297. }
  298.  
  299. return FMRES_IGNORED;
  300. }
  301.  
  302. public fw_CmdStart(id, uc_handle, seed)
  303. {
  304. if(!is_user_alive(id))
  305. return FMRES_IGNORED
  306. if(get_user_weapon(id) != CSW_OICW || !g_Had_Oicw[id])
  307. return FMRES_IGNORED
  308.  
  309. static NewButton; NewButton = get_uc(uc_handle, UC_Buttons)
  310.  
  311. if(NewButton & IN_ATTACK)
  312. {
  313. if(g_IsChanging[id])
  314. {
  315. NewButton &= ~IN_ATTACK
  316. set_uc(uc_handle, UC_Buttons, NewButton)
  317.  
  318. return FMRES_IGNORED
  319. }
  320.  
  321. if(g_WeaponMode[id] != OICW_MODE_GRENADE)
  322. return FMRES_IGNORED
  323.  
  324. NewButton &= ~IN_ATTACK
  325. set_uc(uc_handle, UC_Buttons, NewButton)
  326.  
  327. Shoot_Grenade_Handle(id)
  328. }
  329.  
  330. if(NewButton & IN_ATTACK2) {
  331. NewButton &= ~IN_ATTACK2
  332. set_uc(uc_handle, UC_Buttons, NewButton)
  333.  
  334. NewButton &= ~IN_ATTACK
  335. set_uc(uc_handle, UC_Buttons, NewButton)
  336.  
  337. if((pev(id, pev_oldbuttons) & IN_ATTACK2))
  338. return FMRES_IGNORED
  339. if(get_pdata_float(id, 83, 5) > 0.0)
  340. return FMRES_IGNORED
  341.  
  342. g_IsChanging[id] = 1
  343.  
  344. set_weapons_timeidle(id, CHANGE_TIME + 0.1)
  345. set_player_nextattack(id, CHANGE_TIME)
  346.  
  347. set_weapon_anim(id, g_WeaponMode[id] == OICW_MODE_CARBINE ? ANIM_MOVE_TO_GRENADE : ANIM_MOVE_TO_CARBINE)
  348. set_task(CHANGE_TIME, "OICW_CHANGE_COMPLETE", id+TASK_CHANGE)
  349. }
  350.  
  351. return FMRES_IGNORED
  352. }
  353.  
  354. public OICW_CHANGE_COMPLETE(id)
  355. {
  356. id -= TASK_CHANGE
  357.  
  358. if(!is_user_alive(id))
  359. return
  360. if(get_user_weapon(id) != CSW_OICW || !g_Had_Oicw[id])
  361. return
  362. if(!g_IsChanging[id])
  363. return
  364.  
  365. g_IsChanging[id] = 0
  366.  
  367. if(g_WeaponMode[id] == OICW_MODE_CARBINE) g_WeaponMode[id] = OICW_MODE_GRENADE
  368. else if(g_WeaponMode[id] == OICW_MODE_GRENADE) g_WeaponMode[id] = OICW_MODE_CARBINE
  369.  
  370. Change_Complete(id, g_WeaponMode[id])
  371. }
  372.  
  373. public Shoot_Grenade_Handle(id)
  374. {
  375. if(get_pdata_float(id, 83, 5) > 0.0)
  376. return
  377. if(g_WeaponMode[id] != OICW_MODE_GRENADE)
  378. return
  379. if(g_IsChanging[id])
  380. return
  381. if(!g_GrenadeAmmo[id])
  382. {
  383. client_print(id, print_center, "Out Of Ammo")
  384. set_pdata_float(id, 83, 1.0, 5)
  385.  
  386. return
  387. }
  388.  
  389. g_GrenadeAmmo[id]--
  390. update_ammo2(id, -1, g_GrenadeAmmo[id])
  391.  
  392. static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, "weapon_knife", id)
  393. if(pev_valid(weapon_ent)) ExecuteHamB(Ham_Weapon_PrimaryAttack, weapon_ent)
  394.  
  395. if(g_GrenadeAmmo[id])
  396. {
  397. set_weapons_timeidle(id, GRENADE_RELOAD_TIME + 0.1)
  398. set_player_nextattack(id, GRENADE_RELOAD_TIME)
  399.  
  400. set_weapon_anim(id, ANIM_GRENADE_SHOOT1)
  401. emit_sound(id, CHAN_WEAPON, WeaponSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  402. } else {
  403. set_weapons_timeidle(id, (GRENADE_RELOAD_TIME / 3.0) + 0.1)
  404. set_player_nextattack(id, (GRENADE_RELOAD_TIME / 3.0))
  405.  
  406. set_weapon_anim(id, ANIM_GRENADE_SHOOT2)
  407. emit_sound(id, CHAN_WEAPON, WeaponSounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
  408. }
  409.  
  410. static Float:PunchAngles[3]
  411. PunchAngles[0] = random_float(-2.0, -4.0)
  412. PunchAngles[2] = random_float(5.0, -5.0)
  413.  
  414. set_pev(id, pev_punchangle, PunchAngles)
  415.  
  416. Create_Grenade(id)
  417. }
  418.  
  419. public Create_Grenade(id)
  420. {
  421. static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  422. if(!pev_valid(Ent)) return
  423.  
  424. static Float:Origin[3], Float:Angles[3]
  425.  
  426. get_weapon_attachment(id, Origin, 24.0)
  427. pev(id, pev_angles, Angles)
  428.  
  429. set_pev(Ent, pev_movetype, MOVETYPE_PUSHSTEP)
  430. set_pev(Ent, pev_solid, SOLID_BBOX)
  431. set_pev(Ent, pev_nextthink, get_gametime() + 2.5)
  432.  
  433. set_pev(Ent, pev_classname, "grenade2")
  434. engfunc(EngFunc_SetModel, Ent, S_MODEL)
  435. set_pev(Ent, pev_origin, Origin)
  436. set_pev(Ent, pev_angles, Angles)
  437. set_pev(Ent, pev_owner, id)
  438.  
  439. // Create Velocity
  440. static Float:Velocity[3], Float:TargetOrigin[3]
  441.  
  442. fm_get_aim_origin(id, TargetOrigin)
  443. get_speed_vector(Origin, TargetOrigin, 900.0, Velocity)
  444.  
  445. set_pev(Ent, pev_velocity, Velocity)
  446.  
  447. // Make a Beam
  448. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  449. write_byte(TE_BEAMFOLLOW)
  450. write_short(Ent) // entity
  451. write_short(spr_trail) // sprite
  452. write_byte(20) // life
  453. write_byte(2) // width
  454. write_byte(200) // r
  455. write_byte(200); // g
  456. write_byte(200); // b
  457. write_byte(200); // brightness
  458. message_end();
  459. }
  460.  
  461. public Make_Explosion(ent)
  462. {
  463. static Float:Origin[3]
  464. pev(ent, pev_origin, Origin)
  465.  
  466. message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
  467. write_byte(TE_EXPLOSION)
  468. engfunc(EngFunc_WriteCoord, Origin[0])
  469. engfunc(EngFunc_WriteCoord, Origin[1])
  470. engfunc(EngFunc_WriteCoord, Origin[2])
  471. write_short(g_expspr_id) // sprite index
  472. write_byte(30) // scale in 0.1's
  473. write_byte(30) // framerate
  474. write_byte(0) // flags
  475. message_end()
  476.  
  477. // Put decal on "world" (a wall)
  478. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  479. write_byte(TE_WORLDDECAL)
  480. engfunc(EngFunc_WriteCoord, Origin[0])
  481. engfunc(EngFunc_WriteCoord, Origin[1])
  482. engfunc(EngFunc_WriteCoord, Origin[2])
  483. write_byte(random_num(46, 48))
  484. message_end()
  485.  
  486. message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
  487. write_byte(TE_SMOKE)
  488. engfunc(EngFunc_WriteCoord, Origin[0])
  489. engfunc(EngFunc_WriteCoord, Origin[1])
  490. engfunc(EngFunc_WriteCoord, Origin[2])
  491. write_short(g_SmokeSprId) // sprite index
  492. write_byte(30) // scale in 0.1's
  493. write_byte(10) // framerate
  494. message_end()
  495.  
  496. static Float:Origin2[3]
  497.  
  498. for(new i = 0; i < get_maxplayers(); i++)
  499. {
  500. if(!is_user_alive(i))
  501. continue
  502. pev(i, pev_origin, Origin2)
  503. if(get_distance_f(Origin, Origin2) > float(GRENADE_RADIUS))
  504. continue
  505.  
  506. ExecuteHamB(Ham_TakeDamage, i, 0, pev(ent, pev_owner), float(GRENADE_DAMAGE), DMG_BULLET)
  507. }
  508. }
  509.  
  510. public Change_Complete(id, Mode)
  511. {
  512. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_OICW)
  513. if(!pev_valid(Ent))
  514. return
  515.  
  516. if(Mode == OICW_MODE_CARBINE)
  517. {
  518. update_ammo2(id, pev(Ent, pev_iuser3), pev(Ent, pev_iuser4))
  519. } else if(Mode == OICW_MODE_GRENADE) {
  520. set_pev(Ent, pev_iuser3, cs_get_weapon_ammo(Ent))
  521. set_pev(Ent, pev_iuser4, cs_get_user_bpammo(id, CSW_OICW))
  522.  
  523. update_ammo2(id, -1, g_GrenadeAmmo[id])
  524. }
  525. }
  526.  
  527. public fw_TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
  528. {
  529. if(!is_user_alive(attacker) || !is_user_connected(attacker))
  530. return HAM_IGNORED
  531. if(get_user_weapon(attacker) != CSW_OICW || !g_Had_Oicw[attacker])
  532. return HAM_IGNORED
  533.  
  534. static Float:flEnd[3], Float:vecPlane[3]
  535.  
  536. get_tr2(ptr, TR_vecEndPos, flEnd)
  537. get_tr2(ptr, TR_vecPlaneNormal, vecPlane)
  538.  
  539. if(!is_user_alive(ent))
  540. {
  541. make_bullet(attacker, flEnd)
  542. fake_smoke(attacker, ptr)
  543. }
  544.  
  545. SetHamParamFloat(3, float(DAMAGE))
  546.  
  547. return HAM_HANDLED
  548. }
  549.  
  550. public fw_Weapon_Reload(ent)
  551. {
  552. static id; id = pev(ent, pev_owner)
  553. if(!is_user_alive(id))
  554. return HAM_IGNORED
  555. if(!g_Had_Oicw[id])
  556. return HAM_IGNORED
  557. if(g_WeaponMode[id] == OICW_MODE_GRENADE)
  558. return HAM_SUPERCEDE
  559.  
  560. return HAM_HANDLED
  561. }
  562.  
  563. public fw_Weapon_Reload_Post(ent)
  564. {
  565. static id; id = pev(ent, pev_owner)
  566. if(!is_user_alive(id))
  567. return HAM_IGNORED
  568. if(!g_Had_Oicw[id])
  569. return HAM_IGNORED
  570. if(g_WeaponMode[id] == OICW_MODE_GRENADE)
  571. return HAM_IGNORED
  572.  
  573. if((get_pdata_int(ent, 54, 4) == 1) && g_WeaponMode[id] == OICW_MODE_CARBINE)
  574. { // Reload
  575. set_weapon_anim(id, ANIM_CARBINE_RELOAD)
  576. set_pdata_float(id, 83, RELOAD_TIME, 5)
  577. }
  578.  
  579. return HAM_HANDLED
  580. }
  581.  
  582. public fw_Weapon_WeaponIdle_Post(ent)
  583. {
  584. static id; id = pev(ent, pev_owner)
  585. if(!is_user_alive(id))
  586. return HAM_IGNORED
  587. if(!g_Had_Oicw[id])
  588. return HAM_IGNORED
  589.  
  590. if(get_pdata_float(ent, 48, 4) <= 0.1)
  591. {
  592. set_weapon_anim(id, g_WeaponMode[id] == OICW_MODE_CARBINE ? ANIM_CARBINE_IDLE : ANIM_GRENADE_IDLE)
  593. set_pdata_float(ent, 48, 20.0, 4)
  594. }
  595.  
  596. return HAM_IGNORED
  597. }
  598.  
  599. public fw_Item_AddToPlayer_Post(ent, id)
  600. {
  601. if(!pev_valid(ent))
  602. return HAM_IGNORED
  603.  
  604. if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  605. {
  606. g_Had_Oicw[id] = 1
  607. set_pev(ent, pev_impulse, 0)
  608. }
  609.  
  610. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), .player = id)
  611. write_string(g_Had_Oicw[id] == 1 ? "weapon_oicw" : "weapon_m4a1")
  612. write_byte(4) // PrimaryAmmoID
  613. write_byte(90) // PrimaryAmmoMaxAmount
  614. write_byte(-1) // SecondaryAmmoID
  615. write_byte(-1) // SecondaryAmmoMaxAmount
  616. write_byte(0) // SlotID (0...N)
  617. write_byte(6) // NumberInSlot (1...N)
  618. write_byte(g_Had_Oicw[id] == 1 ? CSW_OICW : CSW_M4A1) // WeaponID
  619. write_byte(0) // Flags
  620. message_end()
  621.  
  622. return HAM_HANDLED
  623. }
  624.  
  625. stock make_bullet(id, Float:Origin[3])
  626. {
  627. // Find target
  628. new decal = random_num(41, 45)
  629. const loop_time = 2
  630.  
  631. static Body, Target
  632. get_user_aiming(id, Target, Body, 999999)
  633.  
  634. if(is_user_connected(Target))
  635. return
  636.  
  637. for(new i = 0; i < loop_time; i++)
  638. {
  639. // Put decal on "world" (a wall)
  640. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  641. write_byte(TE_WORLDDECAL)
  642. engfunc(EngFunc_WriteCoord, Origin[0])
  643. engfunc(EngFunc_WriteCoord, Origin[1])
  644. engfunc(EngFunc_WriteCoord, Origin[2])
  645. write_byte(decal)
  646. message_end()
  647.  
  648. // Show sparcles
  649. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  650. write_byte(TE_GUNSHOTDECAL)
  651. engfunc(EngFunc_WriteCoord, Origin[0])
  652. engfunc(EngFunc_WriteCoord, Origin[1])
  653. engfunc(EngFunc_WriteCoord, Origin[2])
  654. write_short(id)
  655. write_byte(decal)
  656. message_end()
  657. }
  658. }
  659.  
  660. public fake_smoke(id, trace_result)
  661. {
  662. static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
  663.  
  664. get_weapon_attachment(id, vecSrc)
  665. global_get(glb_v_forward, vecEnd)
  666.  
  667. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
  668. xs_vec_add(vecSrc, vecEnd, vecEnd)
  669.  
  670. get_tr2(trace_result, TR_vecEndPos, vecSrc)
  671. get_tr2(trace_result, TR_vecPlaneNormal, vecEnd)
  672.  
  673. xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
  674. xs_vec_add(vecSrc, vecEnd, vecEnd)
  675.  
  676. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  677. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  678. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  679.  
  680. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  681. write_byte(TE_EXPLOSION)
  682. engfunc(EngFunc_WriteCoord, vecEnd[0])
  683. engfunc(EngFunc_WriteCoord, vecEnd[1])
  684. engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
  685. write_short(g_smokepuff_id)
  686. write_byte(2)
  687. write_byte(50)
  688. write_byte(TE_FLAG)
  689. message_end()
  690. }
  691.  
  692. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  693. {
  694. new Float:vfEnd[3], viEnd[3]
  695. get_user_origin(id, viEnd, 3)
  696. IVecFVec(viEnd, vfEnd)
  697.  
  698. new Float:fOrigin[3], Float:fAngle[3]
  699.  
  700. pev(id, pev_origin, fOrigin)
  701. pev(id, pev_view_ofs, fAngle)
  702.  
  703. xs_vec_add(fOrigin, fAngle, fOrigin)
  704.  
  705. new Float:fAttack[3]
  706.  
  707. xs_vec_sub(vfEnd, fOrigin, fAttack)
  708. xs_vec_sub(vfEnd, fOrigin, fAttack)
  709.  
  710. new Float:fRate
  711.  
  712. fRate = fDis / vector_length(fAttack)
  713. xs_vec_mul_scalar(fAttack, fRate, fAttack)
  714.  
  715. xs_vec_add(fOrigin, fAttack, output)
  716. }
  717.  
  718. stock set_weapon_anim(id, anim)
  719. {
  720. if(!is_user_alive(id))
  721. return
  722.  
  723. set_pev(id, pev_weaponanim, anim)
  724.  
  725. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  726. write_byte(anim)
  727. write_byte(pev(id, pev_body))
  728. message_end()
  729. }
  730.  
  731. public make_shell(id)
  732. {
  733. static Float:player_origin[3], Float:origin[3], Float:origin2[3], Float:gunorigin[3], Float:oldangles[3], Float:v_forward[3], Float:v_forward2[3], Float:v_up[3], Float:v_up2[3], Float:v_right[3], Float:v_right2[3], Float:viewoffsets[3];
  734.  
  735. pev(id,pev_v_angle, oldangles); pev(id,pev_origin,player_origin); pev(id, pev_view_ofs, viewoffsets);
  736.  
  737. engfunc(EngFunc_MakeVectors, oldangles)
  738.  
  739. global_get(glb_v_forward, v_forward); global_get(glb_v_up, v_up); global_get(glb_v_right, v_right);
  740. global_get(glb_v_forward, v_forward2); global_get(glb_v_up, v_up2); global_get(glb_v_right, v_right2);
  741.  
  742. xs_vec_add(player_origin, viewoffsets, gunorigin);
  743.  
  744. xs_vec_mul_scalar(v_forward, 10.3, v_forward); xs_vec_mul_scalar(v_right, 2.9, v_right);
  745. xs_vec_mul_scalar(v_up, -3.7, v_up);
  746. xs_vec_mul_scalar(v_forward2, 10.0, v_forward2); xs_vec_mul_scalar(v_right2, 3.0, v_right2);
  747. xs_vec_mul_scalar(v_up2, -4.0, v_up2);
  748.  
  749. xs_vec_add(gunorigin, v_forward, origin);
  750. xs_vec_add(gunorigin, v_forward2, origin2);
  751. xs_vec_add(origin, v_right, origin);
  752. xs_vec_add(origin2, v_right2, origin2);
  753. xs_vec_add(origin, v_up, origin);
  754. xs_vec_add(origin2, v_up2, origin2);
  755.  
  756. static Float:velocity[3]
  757. get_speed_vector(origin2, origin, random_float(140.0, 160.0), velocity)
  758.  
  759. static angle; angle = random_num(0, 360)
  760.  
  761. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  762. write_byte(TE_MODEL)
  763. engfunc(EngFunc_WriteCoord, origin[0])
  764. engfunc(EngFunc_WriteCoord,origin[1])
  765. engfunc(EngFunc_WriteCoord,origin[2])
  766. engfunc(EngFunc_WriteCoord,velocity[0])
  767. engfunc(EngFunc_WriteCoord,velocity[1])
  768. engfunc(EngFunc_WriteCoord,velocity[2])
  769. write_angle(angle)
  770. write_short(shells_model)
  771. write_byte(1)
  772. write_byte(20)
  773. message_end()
  774. }
  775.  
  776. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  777. {
  778. new_velocity[0] = origin2[0] - origin1[0]
  779. new_velocity[1] = origin2[1] - origin1[1]
  780. new_velocity[2] = origin2[2] - origin1[2]
  781. new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  782. new_velocity[0] *= num
  783. new_velocity[1] *= num
  784. new_velocity[2] *= num
  785.  
  786. return 1;
  787. }
  788.  
  789. stock set_weapons_timeidle(id, Float:TimeIdle)
  790. {
  791. if(!is_user_alive(id))
  792. return
  793.  
  794. new entwpn = fm_get_user_weapon_entity(id, CSW_OICW)
  795. if(!pev_valid(entwpn))
  796. return
  797.  
  798. set_pdata_float(entwpn, 46, TimeIdle, 4)
  799. set_pdata_float(entwpn, 47, TimeIdle, 4)
  800. set_pdata_float(entwpn, 48, TimeIdle + 1.0, 4)
  801. }
  802.  
  803. stock set_player_nextattack(id, Float:nexttime)
  804. {
  805. if(!is_user_alive(id))
  806. return
  807.  
  808. set_pdata_float(id, 83, nexttime, 5)
  809. }
  810.  
  811. public update_ammo2(id, ammo, bpammo)
  812. {
  813. if(!is_user_alive(id))
  814. return
  815.  
  816. engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
  817. write_byte(1)
  818. write_byte(CSW_OICW)
  819. write_byte(ammo)
  820. message_end()
  821.  
  822. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  823. write_byte(1)
  824. write_byte(bpammo)
  825. message_end()
  826.  
  827. cs_set_user_bpammo(id, CSW_OICW, bpammo)
  828. }
  829. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  830.   *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  831.   */
  832.  

Ők köszönték meg stupid nek ezt a hozzászólást: JAck (2013.09.01. 17:20)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 17:06 
Offline
Senior Tag

Csatlakozott: 2012.07.09. 11:57
Hozzászólások: 234
Megköszönt másnak: 20 alkalommal
Megköszönték neki: 12 alkalommal
köszi:D
és akk ez lenne az utolsó
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <hamsandwich>
  6. #include <xs>
  7. #include <cstrike>
  8. #include <zombieplague>
  9.  
  10. #define ENG_NULLENT -1
  11. #define EV_INT_WEAPONKEY EV_INT_impulse
  12. #define cobra_WEAPONKEY 820
  13. #define MAX_PLAYERS 32
  14. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  15.  
  16. #pragma tabsize 0
  17.  
  18. const USE_STOPPED = 0
  19. const OFFSET_ACTIVE_ITEM = 373
  20. const OFFSET_WEAPONOWNER = 41
  21. const OFFSET_LINUX = 5
  22. const OFFSET_LINUX_WEAPONS = 4
  23.  
  24. #define WEAP_LINUX_XTRA_OFF 4
  25. #define m_fKnown 44
  26. #define m_flNextPrimaryAttack 46
  27. #define m_flTimeWeaponIdle 48
  28. #define m_iClip 51
  29. #define m_fInReload 54
  30. #define PLAYER_LINUX_XTRA_OFF 5
  31. #define m_flNextAttack 83
  32.  
  33. #define cobra_RELOAD_TIME 2.4
  34. #define cobra_SHOOT1 1
  35. #define cobra_SHOOT2 2
  36. #define cobra_SHOOT_EMPTY 3
  37. #define cobra_RELOAD 4
  38. #define cobra_DRAW 5
  39.  
  40. #define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
  41.  
  42. new const Fire_Sounds[][] = { "weapons/kingcobra-1.wav" }
  43. new const Sound_Zoom[] = { "weapons/zoom.wav" }
  44.  
  45. new cobra_V_MODEL[64] = "models/v_kingcobra.mdl"
  46. new cobra_P_MODEL[64] = "models/p_kingcobra.mdl"
  47. new cobra_W_MODEL[64] = "models/w_kingcobra.mdl"
  48.  
  49. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  50.  
  51. new cvar_dmg_cobra, cvar_recoil_cobra, g_itemid_cobra, cvar_clip_cobra, cvar_spd_cobra, cvar_cobra_ammo
  52. new g_MaxPlayers, g_orig_event_cobra, g_IsInPrimaryAttack, g_iClip
  53. new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
  54. new g_has_cobra[33], g_clip_ammo[33], g_cobra_TmpClip[33], oldweap[33]
  55. new g_hasZoom[33]
  56. new gmsgWeaponList
  57.  
  58. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  59. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_deagle", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  60. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  61. "weapon_ak47", "weapon_knife", "weapon_p90" }
  62.  
  63. public plugin_init()
  64. {
  65. register_plugin("[ZP] Pistols", "1.0", "Crock / SaS")
  66. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  67. register_event("CurWeapon","CurrentWeapon","be","1=1")
  68. RegisterHam(Ham_Item_AddToPlayer, "weapon_deagle", "fw_cobra_AddToPlayer")
  69. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  70. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  71. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  72. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  73. for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  74. if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  75. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_cobra_PrimaryAttack")
  76. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_cobra_PrimaryAttack_Post", 1)
  77. RegisterHam(Ham_Item_PostFrame, "weapon_deagle", "cobra_ItemPostFrame")
  78. RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "cobra_Reload")
  79. RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "cobra_Reload_Post", 1)
  80. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  81. register_forward(FM_SetModel, "fw_SetModel")
  82. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  83. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  84. register_forward(FM_CmdStart, "fw_CmdStart")
  85.  
  86. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  87. RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  88. RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  89. RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  90. RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  91. RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  92. RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  93.  
  94. cvar_dmg_cobra = register_cvar("zp_cobra_dmg", "1.2")
  95. cvar_recoil_cobra = register_cvar("zp_cobra_recoil", "1.0")
  96. cvar_clip_cobra = register_cvar("zp_cobra_clip", "7")
  97. cvar_spd_cobra = register_cvar("zp_cobra_spd", "0.7")
  98. cvar_cobra_ammo = register_cvar("zp_cobra_ammo", "70")
  99.  
  100. g_itemid_cobra = zp_register_extra_item("Colt King Cobra", 1, ZP_TEAM_HUMAN)
  101. g_MaxPlayers = get_maxplayers()
  102. gmsgWeaponList = get_user_msgid("WeaponList")
  103. }
  104.  
  105. public plugin_precache()
  106. {
  107. precache_model(cobra_V_MODEL)
  108. precache_model(cobra_P_MODEL)
  109. precache_model(cobra_W_MODEL)
  110. for(new i = 0; i < sizeof Fire_Sounds; i++)
  111. precache_sound(Fire_Sounds[i])
  112. precache_sound(Sound_Zoom)
  113. precache_sound("weapons/kingcobra_clipin.wav")
  114. precache_sound("weapons/kingcobra_clipout.wav")
  115. precache_sound("weapons/kingcobra_draw.wav")
  116. precache_sound("weapons/kingcobra_shot_empty.wav")
  117. m_iBlood[0] = precache_model("sprites/blood.spr")
  118. m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  119. precache_generic("sprites/weapon_cobra.txt")
  120. precache_generic("sprites/cobra_scope.spr")
  121. precache_generic("sprites/640hud77.spr")
  122. precache_generic("sprites/640hud7.spr")
  123.  
  124. register_clcmd("weapon_cobra", "weapon_hook")
  125.  
  126. register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  127. }
  128.  
  129. public weapon_hook(id)
  130. {
  131. engclient_cmd(id, "weapon_deagle")
  132. return PLUGIN_HANDLED
  133. }
  134.  
  135. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  136. {
  137. if(!is_user_alive(iAttacker))
  138. return
  139.  
  140. new g_currentweapon = get_user_weapon(iAttacker)
  141.  
  142. if(g_currentweapon != CSW_DEAGLE) return
  143.  
  144. if(!g_has_cobra[iAttacker]) return
  145.  
  146. static Float:flEnd[3]
  147. get_tr2(ptr, TR_vecEndPos, flEnd)
  148.  
  149. if(iEnt)
  150. {
  151. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  152. write_byte(TE_DECAL)
  153. write_coord_f(flEnd[0])
  154. write_coord_f(flEnd[1])
  155. write_coord_f(flEnd[2])
  156. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  157. write_short(iEnt)
  158. message_end()
  159. }
  160. else
  161. {
  162. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  163. write_byte(TE_WORLDDECAL)
  164. write_coord_f(flEnd[0])
  165. write_coord_f(flEnd[1])
  166. write_coord_f(flEnd[2])
  167. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  168. message_end()
  169. }
  170. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  171. write_byte(TE_GUNSHOTDECAL)
  172. write_coord_f(flEnd[0])
  173. write_coord_f(flEnd[1])
  174. write_coord_f(flEnd[2])
  175. write_short(iAttacker)
  176. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  177. message_end()
  178. }
  179.  
  180. public zp_user_humanized_post(id)
  181. {
  182. g_has_cobra[id] = false
  183. }
  184.  
  185. public plugin_natives ()
  186. {
  187. register_native("give_weapon_cobra", "native_give_weapon_add", 1)
  188. }
  189. public native_give_weapon_add(id)
  190. {
  191. give_cobra(id)
  192. }
  193.  
  194. public fwPrecacheEvent_Post(type, const name[])
  195. {
  196. if (equal("events/deagle.sc", name))
  197. {
  198. g_orig_event_cobra = get_orig_retval()
  199. return FMRES_HANDLED
  200. }
  201. return FMRES_IGNORED
  202. }
  203.  
  204. public client_connect(id)
  205. {
  206. g_has_cobra[id] = false
  207. }
  208.  
  209. public client_disconnect(id)
  210. {
  211. g_has_cobra[id] = false
  212. }
  213.  
  214. public zp_user_infected_post(id)
  215. {
  216. if (zp_get_user_zombie(id))
  217. {
  218. g_has_cobra[id] = false
  219. }
  220. }
  221.  
  222. public fw_SetModel(entity, model[])
  223. {
  224. if(!is_valid_ent(entity))
  225. return FMRES_IGNORED
  226.  
  227. static szClassName[33]
  228. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  229.  
  230. if(!equal(szClassName, "weaponbox"))
  231. return FMRES_IGNORED
  232.  
  233. static iOwner
  234.  
  235. iOwner = entity_get_edict(entity, EV_ENT_owner)
  236.  
  237. if(equal(model, "models/w_deagle.mdl"))
  238. {
  239. static iStoredAugID
  240.  
  241. iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_deagle", entity)
  242.  
  243. if(!is_valid_ent(iStoredAugID))
  244. return FMRES_IGNORED
  245.  
  246. if(g_has_cobra[iOwner])
  247. {
  248. entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, cobra_WEAPONKEY)
  249.  
  250. g_has_cobra[iOwner] = false
  251.  
  252. entity_set_model(entity, cobra_W_MODEL)
  253.  
  254. return FMRES_SUPERCEDE
  255. }
  256. }
  257. return FMRES_IGNORED
  258. }
  259.  
  260. public give_cobra(id)
  261. {
  262. drop_weapons(id, 2)
  263. new iWep2 = give_item(id,"weapon_deagle")
  264. if( iWep2 > 0 )
  265. {
  266. cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_cobra))
  267. cs_set_user_bpammo (id, CSW_DEAGLE, get_pcvar_num(cvar_cobra_ammo))
  268. UTIL_PlayWeaponAnimation(id, cobra_DRAW)
  269. set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  270.  
  271. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  272. write_string("weapon_cobra")
  273. write_byte(8)
  274. write_byte(35)
  275. write_byte(-1)
  276. write_byte(-1)
  277. write_byte(1)
  278. write_byte(1)
  279. write_byte(CSW_DEAGLE)
  280. message_end()
  281. }
  282. g_has_cobra[id] = true
  283. }
  284.  
  285. public zp_extra_item_selected(id, itemid)
  286. {
  287. if(itemid != g_itemid_cobra)
  288. return
  289.  
  290. give_cobra(id)
  291. }
  292.  
  293. public fw_cobra_AddToPlayer(cobra, id)
  294. {
  295. if(!is_valid_ent(cobra) || !is_user_connected(id))
  296. return HAM_IGNORED
  297.  
  298. if(entity_get_int(cobra, EV_INT_WEAPONKEY) == cobra_WEAPONKEY)
  299. {
  300. g_has_cobra[id] = true
  301.  
  302. entity_set_int(cobra, EV_INT_WEAPONKEY, 0)
  303.  
  304. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  305. write_string("weapon_cobra")
  306. write_byte(8)
  307. write_byte(35)
  308. write_byte(-1)
  309. write_byte(-1)
  310. write_byte(1)
  311. write_byte(1)
  312. write_byte(CSW_DEAGLE)
  313. message_end()
  314.  
  315. return HAM_HANDLED
  316. }
  317. else
  318. {
  319. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  320. write_string("weapon_deagle")
  321. write_byte(8)
  322. write_byte(35)
  323. write_byte(-1)
  324. write_byte(-1)
  325. write_byte(1)
  326. write_byte(1)
  327. write_byte(CSW_DEAGLE)
  328. message_end()
  329. }
  330. return HAM_IGNORED
  331. }
  332.  
  333. public fw_UseStationary_Post(entity, caller, activator, use_type)
  334. {
  335. if (use_type == USE_STOPPED && is_user_connected(caller))
  336. replace_weapon_models(caller, get_user_weapon(caller))
  337. }
  338.  
  339. public fw_Item_Deploy_Post(weapon_ent)
  340. {
  341. static owner
  342. owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  343.  
  344. static weaponid
  345. weaponid = cs_get_weapon_id(weapon_ent)
  346.  
  347. replace_weapon_models(owner, weaponid)
  348. }
  349.  
  350. public CurrentWeapon(id)
  351. {
  352. replace_weapon_models(id, read_data(2))
  353.  
  354. if(read_data(2) != CSW_DEAGLE || !g_has_cobra[id])
  355. return
  356.  
  357. static Float:iSpeed
  358. if(g_has_cobra[id])
  359. iSpeed = get_pcvar_float(cvar_spd_cobra)
  360.  
  361. static weapon[32],Ent
  362. get_weaponname(read_data(2),weapon,31)
  363. Ent = find_ent_by_owner(-1,weapon,id)
  364. if(Ent)
  365. {
  366. static Float:Delay
  367. Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  368. if (Delay > 0.0)
  369. {
  370. set_pdata_float(Ent, 46, Delay, 4)
  371. }
  372. }
  373. }
  374.  
  375. replace_weapon_models(id, weaponid)
  376. {
  377. switch (weaponid)
  378. {
  379. case CSW_DEAGLE:
  380. {
  381. if (zp_get_user_zombie(id) || zp_get_user_survivor(id))
  382. return
  383.  
  384. if(g_has_cobra[id])
  385. {
  386. set_pev(id, pev_viewmodel2, cobra_V_MODEL)
  387. set_pev(id, pev_weaponmodel2, cobra_P_MODEL)
  388. if(oldweap[id] != CSW_DEAGLE)
  389. {
  390. UTIL_PlayWeaponAnimation(id, cobra_DRAW)
  391. set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  392.  
  393. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  394. write_string("weapon_cobra")
  395. write_byte(8)
  396. write_byte(35)
  397. write_byte(-1)
  398. write_byte(-1)
  399. write_byte(1)
  400. write_byte(1)
  401. write_byte(CSW_DEAGLE)
  402. message_end()
  403. }
  404. }
  405. }
  406. }
  407. oldweap[id] = weaponid
  408. }
  409.  
  410. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  411. {
  412. if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_DEAGLE || !g_has_cobra[Player]))
  413. return FMRES_IGNORED
  414.  
  415. set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  416. return FMRES_HANDLED
  417. }
  418.  
  419. public fw_cobra_PrimaryAttack(Weapon)
  420. {
  421. new Player = get_pdata_cbase(Weapon, 41, 4)
  422.  
  423. if (!g_has_cobra[Player])
  424. return
  425.  
  426. g_IsInPrimaryAttack = 1
  427. pev(Player,pev_punchangle,cl_pushangle[Player])
  428.  
  429. g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  430. g_iClip = cs_get_weapon_ammo(Weapon)
  431. }
  432.  
  433. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  434. {
  435. if ((eventid != g_orig_event_cobra) || !g_IsInPrimaryAttack)
  436. return FMRES_IGNORED
  437. if (!(1 <= invoker <= g_MaxPlayers))
  438. return FMRES_IGNORED
  439.  
  440. playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  441. return FMRES_SUPERCEDE
  442. }
  443.  
  444. public fw_cobra_PrimaryAttack_Post(Weapon)
  445. {
  446. g_IsInPrimaryAttack = 0
  447. new Player = get_pdata_cbase(Weapon, 41, 4)
  448.  
  449. new szClip, szAmmo
  450. get_user_weapon(Player, szClip, szAmmo)
  451.  
  452. if(!is_user_alive(Player))
  453. return
  454.  
  455. if (g_iClip <= cs_get_weapon_ammo(Weapon))
  456. return
  457.  
  458. if(g_has_cobra[Player])
  459. {
  460. if (!g_clip_ammo[Player])
  461. return
  462.  
  463. new Float:push[3]
  464. pev(Player,pev_punchangle,push)
  465. xs_vec_sub(push,cl_pushangle[Player],push)
  466.  
  467. xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_cobra),push)
  468. xs_vec_add(push,cl_pushangle[Player],push)
  469. set_pev(Player,pev_punchangle,push)
  470.  
  471. emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  472. if(szClip > 1) UTIL_PlayWeaponAnimation(Player, random_num(cobra_SHOOT1,cobra_SHOOT2))
  473. if(szClip == 1) UTIL_PlayWeaponAnimation(Player, cobra_SHOOT_EMPTY)
  474. }
  475. }
  476.  
  477. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  478. {
  479. if (victim != attacker && is_user_connected(attacker))
  480. {
  481. if(get_user_weapon(attacker) == CSW_DEAGLE)
  482. {
  483. if(g_has_cobra[attacker])
  484. SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_cobra))
  485. }
  486. }
  487. }
  488.  
  489. public message_DeathMsg(msg_id, msg_dest, id)
  490. {
  491. static szTruncatedWeapon[33], iAttacker, iVictim
  492.  
  493. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  494.  
  495. iAttacker = get_msg_arg_int(1)
  496. iVictim = get_msg_arg_int(2)
  497.  
  498. if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  499. return PLUGIN_CONTINUE
  500.  
  501. if(equal(szTruncatedWeapon, "deagle") && get_user_weapon(iAttacker) == CSW_DEAGLE)
  502. {
  503. if(g_has_cobra[iAttacker])
  504. set_msg_arg_string(4, "deagle")
  505. }
  506. return PLUGIN_CONTINUE
  507. }
  508.  
  509. stock fm_cs_get_current_weapon_ent(id)
  510. {
  511. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  512. }
  513.  
  514. stock fm_cs_get_weapon_ent_owner(ent)
  515. {
  516. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  517. }
  518.  
  519. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  520. {
  521. set_pev(Player, pev_weaponanim, Sequence)
  522.  
  523. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  524. write_byte(Sequence)
  525. write_byte(pev(Player, pev_body))
  526. message_end()
  527. }
  528.  
  529. public fw_CmdStart(id, uc_handle, seed)
  530. {
  531. if(!is_user_alive(id))
  532. return PLUGIN_HANDLED
  533.  
  534. if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
  535. {
  536. new szClip, szAmmo
  537. new szWeapID = get_user_weapon(id, szClip, szAmmo)
  538.  
  539. if(szWeapID == CSW_DEAGLE && g_has_cobra[id] && !g_hasZoom[id] == true)
  540. {
  541. g_hasZoom[id] = true
  542. cs_set_user_zoom(id, CS_SET_FIRST_ZOOM, 1)
  543. emit_sound(id, CHAN_ITEM, Sound_Zoom, 0.20, 2.40, 0, 100)
  544. }
  545.  
  546. else if(szWeapID == CSW_DEAGLE && g_has_cobra[id] && g_hasZoom[id])
  547. {
  548. g_hasZoom[id] = false
  549. cs_set_user_zoom(id, CS_SET_NO_ZOOM, 0)
  550.  
  551. }
  552.  
  553. }
  554.  
  555. if (g_hasZoom[ id ] && (pev(id, pev_button) & IN_RELOAD))
  556. {
  557. g_hasZoom[ id ] = false
  558. cs_set_user_zoom( id, CS_SET_NO_ZOOM, 0 )
  559. }
  560. return PLUGIN_HANDLED
  561. }
  562.  
  563. public cobra_ItemPostFrame(weapon_entity)
  564. {
  565. new id = pev(weapon_entity, pev_owner)
  566. if (!is_user_connected(id))
  567. return HAM_IGNORED
  568.  
  569. if (!g_has_cobra[id])
  570. return HAM_IGNORED
  571.  
  572. static iClipExtra
  573.  
  574. iClipExtra = get_pcvar_num(cvar_clip_cobra)
  575. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  576.  
  577. new iBpAmmo = cs_get_user_bpammo(id, CSW_DEAGLE);
  578. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  579.  
  580. new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  581.  
  582. if( fInReload && flNextAttack <= 0.0 )
  583. {
  584. new j = min(iClipExtra - iClip, iBpAmmo)
  585.  
  586. set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  587. cs_set_user_bpammo(id, CSW_DEAGLE, iBpAmmo-j)
  588.  
  589. set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  590. fInReload = 0
  591. }
  592. return HAM_IGNORED
  593. }
  594.  
  595. public cobra_Reload(weapon_entity)
  596. {
  597. new id = pev(weapon_entity, pev_owner)
  598. if (!is_user_connected(id))
  599. return HAM_IGNORED
  600.  
  601. if (!g_has_cobra[id])
  602. return HAM_IGNORED
  603.  
  604. static iClipExtra
  605.  
  606. if(g_has_cobra[id])
  607. iClipExtra = get_pcvar_num(cvar_clip_cobra)
  608.  
  609. g_cobra_TmpClip[id] = -1
  610.  
  611. new iBpAmmo = cs_get_user_bpammo(id, CSW_DEAGLE)
  612. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  613.  
  614. if (iBpAmmo <= 0)
  615. return HAM_SUPERCEDE
  616.  
  617. if (iClip >= iClipExtra)
  618. return HAM_SUPERCEDE
  619.  
  620. g_cobra_TmpClip[id] = iClip
  621.  
  622. return HAM_IGNORED
  623. }
  624.  
  625. public cobra_Reload_Post(weapon_entity)
  626. {
  627. new id = pev(weapon_entity, pev_owner)
  628. if (!is_user_connected(id))
  629. return HAM_IGNORED
  630.  
  631. if (!g_has_cobra[id])
  632. return HAM_IGNORED
  633.  
  634. if (g_cobra_TmpClip[id] == -1)
  635. return HAM_IGNORED
  636.  
  637. set_pdata_int(weapon_entity, m_iClip, g_cobra_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  638.  
  639. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, cobra_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  640.  
  641. set_pdata_float(id, m_flNextAttack, cobra_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  642.  
  643. set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  644.  
  645. UTIL_PlayWeaponAnimation(id, cobra_RELOAD)
  646.  
  647. return HAM_IGNORED
  648. }
  649.  
  650. stock drop_weapons(id, dropwhat)
  651. {
  652. static weapons[32], num, i, weaponid
  653. num = 0
  654. get_user_weapons(id, weapons, num)
  655.  
  656. for (i = 0; i < num; i++)
  657. {
  658. weaponid = weapons[i]
  659.  
  660. if (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  661. {
  662. static wname[32]
  663. get_weaponname(weaponid, wname, sizeof wname - 1)
  664. engclient_cmd(id, "drop", wname)
  665. }
  666. }
  667. }

_________________
[mozgo]Bogdan for President[/mozgo]
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 17:09 
Offline
Senior Tag

Csatlakozott: 2012.07.09. 11:57
Hozzászólások: 234
Megköszönt másnak: 20 alkalommal
Megköszönték neki: 12 alkalommal
Ja meg a tomit nem alakítjá át:/
SMA Forráskód: [ Mindet kijelol ]
  1. thompson.sma(1) : error 010: invalid function or declaration
  2. amx/include/engine.inc(16) : error 017: undefined symbol "AMXX_VERSION_NUM"


SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <hamsandwich>
  6. #include <xs>
  7. #include <cstrike>
  8.  
  9.  
  10. enum
  11. {
  12. anim_idle,
  13. anim_reload,
  14. anim_draw,
  15. anim_shoot1,
  16. anim_shoot2,
  17. anim_shoot3
  18. }
  19.  
  20. #define ENG_NULLENT -1
  21. #define EV_INT_WEAPONKEY EV_INT_impulse
  22. #define tomi_WEAPONKEY 9142
  23. #define MAX_PLAYERS 32
  24. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  25. #define AMXX_VERSION_NUM
  26.  
  27. const USE_STOPPED = 0
  28. const OFFSET_ACTIVE_ITEM = 373
  29. const OFFSET_WEAPONOWNER = 41
  30. const OFFSET_LINUX = 5
  31. const OFFSET_LINUX_WEAPONS = 5
  32.  
  33. #define WEAP_LINUX_XTRA_OFF 4
  34. #define m_fKnown 44
  35. #define m_flNextPrimaryAttack 46
  36. #define m_flTimeWeaponIdle 48
  37. #define m_iClip 51
  38. #define m_fInReload 54
  39. #define PLAYER_LINUX_XTRA_OFF 5
  40. #define m_flNextAttack 83
  41.  
  42. #define tomi_RELOAD_TIME 4.0
  43.  
  44. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_P90)|(1<<CSW_P90)|(1<<CSW_P90)|(1<<CSW_SG550)|(1<<CSW_P90)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_P90)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_P90)|(1<<CSW_AK47)|(1<<CSW_P90)
  45. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_p90",
  46. "weapon_p90", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_p90", "weapon_sg550",
  47. "weapon_p90", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_p90", "weapon_m249",
  48. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_p90",
  49. "weapon_ak47", "weapon_knife", "weapon_p90" }
  50.  
  51. new const Fire_Sounds[][] = { "weapons/thompson-1.wav" }
  52.  
  53. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  54.  
  55. new tomi_V_MODEL[64] = "models/cso_wpn/vth.mdl"
  56. new tomi_P_MODEL[64] = "models/cso_wpn/pth.mdl"
  57. new tomi_W_MODEL[64] = "models/cso_wpn/wth.mdl"
  58.  
  59. new cvar_dmg_tomi, cvar_recoil_tomi, cvar_clip_tomi, cvar_tomi_ammo , cvar_dmg_tomi2
  60. new g_has_tomi[33]
  61. new g_MaxPlayers, g_orig_event_tomi, g_clip_ammo[33] , g_reload[33]
  62. new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
  63. new g_tomi_TmpClip[33]
  64. new g_mode[33] , g_mode2[33]
  65. new g_hasZoom[33]
  66. public plugin_init()
  67. {
  68. register_plugin("[CSO:tomi(2 Regimes)]", "1.0", "ololo XD")
  69. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  70. register_event("CurWeapon","CurrentWeapon","be","1=1")
  71. RegisterHam(Ham_Item_AddToPlayer, "weapon_p90", "fw_tomi_AddToPlayer")
  72. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  73. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  74. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  75. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  76. for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  77. if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  78. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_p90", "fw_tomi_PrimaryAttack")
  79. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_p90", "fw_tomi_PrimaryAttack_Post", 1)
  80. RegisterHam(Ham_Item_PostFrame, "weapon_p90", "tomi__ItemPostFrame");
  81. RegisterHam(Ham_Weapon_Reload, "weapon_p90", "tomi__Reload");
  82. RegisterHam(Ham_Weapon_Reload, "weapon_p90", "tomi__Reload_Post", 1);
  83. register_forward(FM_CmdStart, "fw_CmdStart")
  84. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  85. register_forward(FM_SetModel, "fw_SetModel")
  86. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  87. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  88.  
  89. cvar_dmg_tomi = register_cvar("tomi_dmg", "2.1")
  90. cvar_dmg_tomi2 = register_cvar("tomi_dmg_sniper", "3.0")
  91. cvar_recoil_tomi = register_cvar("tomi_recoil", "0.6")
  92. cvar_clip_tomi = register_cvar("tomi_clip", "50")
  93. cvar_tomi_ammo = register_cvar("tomi_ammo", "100")
  94. register_concmd("thompson","give_tomi")
  95.  
  96. g_MaxPlayers = get_maxplayers()
  97. }
  98.  
  99. public plugin_precache()
  100. {
  101. precache_model(tomi_V_MODEL)
  102. precache_model(tomi_P_MODEL)
  103. precache_model(tomi_W_MODEL)
  104.  
  105. precache_sound(Fire_Sounds[0])
  106. m_iBlood[0] = precache_model("sprites/blood.spr")
  107. m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  108. precache_model("sprites/640hud5.spr")
  109. register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  110. }
  111.  
  112. public plugin_natives ()
  113. {
  114. register_native("give_cso_tomi", "native_give_weapon_add", 1)
  115. register_native("get_user_tomi", "native_give_weapon_add2", 1)
  116. }
  117.  
  118. public native_give_weapon_add(id)
  119. {
  120. give_tomi(id)
  121. }
  122.  
  123. public native_give_weapon_add2(id)
  124. {
  125. return g_has_tomi[id]
  126. }
  127.  
  128. public fwPrecacheEvent_Post(type, const name[])
  129. {
  130. if (equal("events/p90.sc", name))
  131. {
  132. g_orig_event_tomi = get_orig_retval()
  133. return FMRES_HANDLED
  134. }
  135.  
  136. return FMRES_IGNORED
  137. }
  138.  
  139. public client_connect(id)
  140. {
  141. g_has_tomi[id] = false
  142. }
  143.  
  144. public client_disconnect(id)
  145. {
  146. g_has_tomi[id] = false
  147. }
  148.  
  149. public fw_SetModel(entity, model[])
  150. {
  151. if(!is_valid_ent(entity))
  152. return FMRES_IGNORED;
  153.  
  154. static szClassName[33]
  155. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  156.  
  157. if(!equal(szClassName, "weaponbox"))
  158. return FMRES_IGNORED;
  159.  
  160. static iOwner
  161.  
  162. iOwner = entity_get_edict(entity, EV_ENT_owner)
  163.  
  164. if(equal(model, "models/w_p90.mdl"))
  165. {
  166. static iStoredSVDID
  167.  
  168. iStoredSVDID = find_ent_by_owner(ENG_NULLENT, "weapon_p90", entity)
  169.  
  170. if(!is_valid_ent(iStoredSVDID))
  171. return FMRES_IGNORED;
  172.  
  173. if(g_has_tomi[iOwner])
  174. {
  175. entity_set_int(iStoredSVDID, EV_INT_WEAPONKEY, tomi_WEAPONKEY)
  176. g_has_tomi[iOwner] = false
  177.  
  178. entity_set_model(entity, tomi_W_MODEL)
  179.  
  180. return FMRES_SUPERCEDE;
  181. }
  182. }
  183.  
  184.  
  185. return FMRES_IGNORED;
  186. }
  187.  
  188. public give_tomi(id)
  189. {
  190. drop_weapons(id, 1);
  191. new iWep2 = give_item(id,"weapon_p90")
  192. if( iWep2 > 0 )
  193. {
  194. cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_tomi))
  195. cs_set_user_bpammo (id, CSW_P90, get_pcvar_num(cvar_tomi_ammo))
  196. }
  197. g_has_tomi[id] = true;
  198. }
  199.  
  200. public fw_tomi_AddToPlayer(tomi, id)
  201. {
  202. if(!is_valid_ent(tomi) || !is_user_connected(id))
  203. return HAM_IGNORED;
  204.  
  205. if(entity_get_int(tomi, EV_INT_WEAPONKEY) == tomi_WEAPONKEY)
  206. {
  207. g_has_tomi[id] = true
  208.  
  209. entity_set_int(tomi, EV_INT_WEAPONKEY, 0)
  210.  
  211. return HAM_HANDLED;
  212. }
  213.  
  214. return HAM_IGNORED;
  215. }
  216.  
  217. public fw_CmdStart(id, uc_handle, seed)
  218. {
  219. if(id > 0 && id < 33)
  220. {
  221. if(!is_user_alive(id))
  222. return PLUGIN_HANDLED
  223. if(get_user_weapon(id) == CSW_P90 && g_has_tomi[id])
  224. {
  225. if((get_uc(uc_handle, UC_Buttons) & IN_USE) && !(pev(id, pev_oldbuttons) & IN_USE) && g_reload[id] == 0 && g_mode2[id] == 0)
  226. {
  227. if(!g_hasZoom[id])
  228. {
  229. g_hasZoom[id] = true
  230. cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
  231. }else{
  232. g_hasZoom[ id ] = false
  233. cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
  234. }
  235. if (!g_mode[id])
  236. {
  237. g_hasZoom[id] = false
  238. cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
  239. }
  240. }
  241.  
  242. if (g_hasZoom[ id ] && (pev(id, pev_button) & IN_RELOAD))
  243. {
  244. g_hasZoom[ id ] = false
  245. cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
  246. }
  247.  
  248. if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2) && !g_mode2[id] && !g_reload[id])
  249. {
  250. g_hasZoom[ id ] = false
  251. cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
  252. if(g_mode[id] == 0) make_mode2(id)
  253. if(g_mode[id] == 2) make_mode1(id)
  254. }
  255. }
  256. return HAM_SUPERCEDE;
  257. }
  258. return PLUGIN_HANDLED
  259. }
  260.  
  261. public make_mode2(id)
  262. {
  263. set_task(0.000001,"mode_new2",id)
  264. g_mode2[id] = 1
  265. UTIL_PlayWeaponAnimation(id, 6)
  266. set_pdata_float(id, m_flNextAttack, 0.000001, PLAYER_LINUX_XTRA_OFF)
  267. }
  268.  
  269. public make_mode1(id)
  270. {
  271. set_task(0.000001,"mode_new1",id)
  272. g_mode2[id] = 1
  273. UTIL_PlayWeaponAnimation(id, 6)
  274. set_pdata_float(id, m_flNextAttack, 0.000001, PLAYER_LINUX_XTRA_OFF)
  275. }
  276.  
  277. public mode_new2(id)
  278. {
  279. if(g_mode2[id] == 1 && is_user_alive(id))
  280. {
  281. g_mode2[id] = 0
  282. g_mode[id] = 2
  283. client_print(id,print_center,"[Pontozott]")
  284. }
  285. }
  286.  
  287. public mode_new1(id)
  288. {
  289. if(g_mode2[id] == 1 && is_user_alive(id))
  290. {
  291. g_mode2[id] = 0
  292. g_mode[id] = 0
  293. client_print(id,print_center,"[Automata]")
  294. }
  295. }
  296.  
  297. public fw_UseStationary_Post(entity, caller, activator, use_type)
  298. {
  299. if (use_type == USE_STOPPED && is_user_connected(caller))
  300. replace_weapon_models(caller, get_user_weapon(caller))
  301. }
  302.  
  303. public fw_Item_Deploy_Post(weapon_ent)
  304. {
  305. static owner
  306. owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  307.  
  308. static weaponid
  309. weaponid = cs_get_weapon_id(weapon_ent)
  310.  
  311. replace_weapon_models(owner, weaponid)
  312. }
  313.  
  314. public CurrentWeapon(id)
  315. {
  316. replace_weapon_models(id, read_data(2))
  317. remove_task(id)
  318. g_reload[id] = 0
  319. g_mode2[id] = 0
  320. }
  321.  
  322. replace_weapon_models(id, weaponid)
  323. {
  324. switch (weaponid)
  325. {
  326. case CSW_P90:
  327. {
  328. if(g_has_tomi[id])
  329. {
  330. if(g_mode[id] == 0) set_pev(id, pev_viewmodel2, tomi_V_MODEL)
  331. if(g_mode[id] == 2) set_pev(id, pev_viewmodel2, tomi_V_MODEL)
  332. set_pev(id, pev_weaponmodel2, tomi_P_MODEL)
  333. }
  334. }
  335. }
  336. }
  337.  
  338. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  339. {
  340. if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_P90) || !g_has_tomi[Player])
  341. return FMRES_IGNORED
  342.  
  343. set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.00001)
  344. return FMRES_HANDLED
  345. }
  346.  
  347. public fw_tomi_PrimaryAttack(Weapon)
  348. {
  349. new Player = get_pdata_cbase(Weapon, 41, 4)
  350.  
  351. if (!g_has_tomi[Player])
  352. return;
  353.  
  354. pev(Player,pev_punchangle,cl_pushangle[Player])
  355.  
  356. g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  357. }
  358.  
  359. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  360. {
  361. if ((eventid != g_orig_event_tomi))
  362. return FMRES_IGNORED
  363. if (!(1 <= invoker <= g_MaxPlayers))
  364. return FMRES_IGNORED
  365.  
  366. playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  367. return FMRES_SUPERCEDE
  368. }
  369.  
  370. public fw_tomi_PrimaryAttack_Post(Weapon)
  371. {
  372. new Player = get_pdata_cbase(Weapon, 41, 4)
  373.  
  374. new szClip, szAmmo
  375. get_user_weapon(Player, szClip, szAmmo)
  376. if(Player > 0 && Player < 33)
  377. {
  378. if(!g_has_tomi[Player])
  379. {
  380. if(szClip > 0) emit_sound(Player, CHAN_WEAPON, "weapons/p90-1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  381. }
  382. if(g_has_tomi[Player])
  383. {
  384. new Float:push[3]
  385. pev(Player,pev_punchangle,push)
  386. xs_vec_sub(push,cl_pushangle[Player],push)
  387.  
  388. xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_tomi),push)
  389. xs_vec_add(push,cl_pushangle[Player],push)
  390. set_pev(Player,pev_punchangle,push)
  391.  
  392. if (!g_clip_ammo[Player])
  393. return
  394.  
  395. emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  396. UTIL_PlayWeaponAnimation(Player, 3)
  397.  
  398. make_blood_and_bulletholes(Player)
  399. if(g_mode[Player] == 2) set_pdata_float(Player, m_flNextAttack, 0.3, PLAYER_LINUX_XTRA_OFF)
  400. }
  401. }
  402. }
  403.  
  404. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  405. {
  406. if (victim != attacker && is_user_connected(attacker))
  407. {
  408. if(get_user_weapon(attacker) == CSW_P90)
  409. {
  410. if(g_has_tomi[attacker])
  411. {
  412. if(g_mode[attacker] == 2) SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_tomi2))
  413. if(g_mode[attacker] == 0) SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_tomi))
  414. }
  415. }
  416. }
  417. }
  418.  
  419. public message_DeathMsg(msg_id, msg_dest, id)
  420. {
  421. static szTruncatedWeapon[33], iAttacker, iVictim
  422.  
  423. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  424.  
  425. iAttacker = get_msg_arg_int(1)
  426. iVictim = get_msg_arg_int(2)
  427.  
  428. if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  429. return PLUGIN_CONTINUE
  430.  
  431. if(equal(szTruncatedWeapon, "p90") && get_user_weapon(iAttacker) == CSW_P90)
  432. {
  433. if(g_has_tomi[iAttacker])
  434. set_msg_arg_string(4, "p90")
  435. }
  436.  
  437. return PLUGIN_CONTINUE
  438. }
  439.  
  440. stock fm_cs_get_current_weapon_ent(id)
  441. {
  442. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
  443. }
  444.  
  445. stock fm_cs_get_weapon_ent_owner(ent)
  446. {
  447. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
  448. }
  449.  
  450. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  451. {
  452. set_pev(Player, pev_weaponanim, Sequence)
  453.  
  454. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  455. write_byte(Sequence)
  456. write_byte(pev(Player, pev_body))
  457. message_end()
  458. }
  459.  
  460. stock make_blood_and_bulletholes(id)
  461. {
  462. new aimOrigin[3], target, body
  463. get_user_origin(id, aimOrigin, 3)
  464. get_user_aiming(id, target, body)
  465.  
  466. if(target > 0 && target <= g_MaxPlayers)
  467. {
  468. new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
  469. pev(id, pev_origin, fStart)
  470.  
  471. velocity_by_aim(id, 64, fVel)
  472.  
  473. fStart[0] = float(aimOrigin[0])
  474. fStart[1] = float(aimOrigin[1])
  475. fStart[2] = float(aimOrigin[2])
  476. fEnd[0] = fStart[0]+fVel[0]
  477. fEnd[1] = fStart[1]+fVel[1]
  478. fEnd[2] = fStart[2]+fVel[2]
  479.  
  480. new res
  481. engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
  482. get_tr2(res, TR_vecEndPos, fRes)
  483.  
  484. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  485. write_byte(TE_BLOODSPRITE)
  486. write_coord(floatround(fStart[0]))
  487. write_coord(floatround(fStart[1]))
  488. write_coord(floatround(fStart[2]))
  489. write_short( m_iBlood [ 1 ])
  490. write_short( m_iBlood [ 0 ] )
  491. write_byte(70)
  492. write_byte(random_num(1,2))
  493. message_end()
  494.  
  495.  
  496. }
  497. else if(!is_user_connected(target))
  498. {
  499. if(target)
  500. {
  501. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  502. write_byte(TE_DECAL)
  503. write_coord(aimOrigin[0])
  504. write_coord(aimOrigin[1])
  505. write_coord(aimOrigin[2])
  506. write_byte(GUNSHOT_DECALS[random_num ( 0, sizeof GUNSHOT_DECALS -1 ) ] )
  507. write_short(target)
  508. message_end()
  509. }
  510. else
  511. {
  512. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  513. write_byte(TE_WORLDDECAL)
  514. write_coord(aimOrigin[0])
  515. write_coord(aimOrigin[1])
  516. write_coord(aimOrigin[2])
  517. write_byte(GUNSHOT_DECALS[random_num ( 0, sizeof GUNSHOT_DECALS -1 ) ] )
  518. message_end()
  519. }
  520.  
  521. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  522. write_byte(TE_GUNSHOTDECAL)
  523. write_coord(aimOrigin[0])
  524. write_coord(aimOrigin[1])
  525. write_coord(aimOrigin[2])
  526. write_short(id)
  527. write_byte(GUNSHOT_DECALS[random_num ( 0, sizeof GUNSHOT_DECALS -1 ) ] )
  528. message_end()
  529. }
  530. }
  531.  
  532. public tomi__ItemPostFrame(weapon_entity) {
  533. new id = pev(weapon_entity, pev_owner)
  534. if (!is_user_connected(id))
  535. return HAM_IGNORED;
  536.  
  537. if (!g_has_tomi[id])
  538. return HAM_IGNORED;
  539.  
  540. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  541.  
  542. new iBpAmmo = cs_get_user_bpammo(id, CSW_P90);
  543. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  544.  
  545. new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  546.  
  547. if( fInReload && flNextAttack <= 0.0 )
  548. {
  549. new j = min(get_pcvar_num(cvar_clip_tomi) - iClip, iBpAmmo)
  550.  
  551. set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  552. cs_set_user_bpammo(id, CSW_P90, iBpAmmo-j);
  553.  
  554. set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  555. fInReload = 0
  556. g_reload[id] = 0
  557. }
  558.  
  559. return HAM_IGNORED;
  560. }
  561.  
  562. public tomi__Reload(weapon_entity) {
  563. new id = pev(weapon_entity, pev_owner)
  564. if (!is_user_connected(id))
  565. return HAM_IGNORED;
  566.  
  567. if (!g_has_tomi[id])
  568. return HAM_IGNORED;
  569.  
  570. g_tomi_TmpClip[id] = -1;
  571.  
  572. new iBpAmmo = cs_get_user_bpammo(id, CSW_P90);
  573. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  574.  
  575. if (iBpAmmo <= 0)
  576. return HAM_SUPERCEDE;
  577.  
  578. if (iClip >= get_pcvar_num(cvar_clip_tomi))
  579. return HAM_SUPERCEDE;
  580.  
  581.  
  582. g_tomi_TmpClip[id] = iClip;
  583.  
  584. g_reload[id] = 1
  585.  
  586. return HAM_IGNORED;
  587. }
  588.  
  589. public tomi__Reload_Post(weapon_entity) {
  590. new id = pev(weapon_entity, pev_owner)
  591. if (!is_user_connected(id))
  592. return HAM_IGNORED;
  593.  
  594. if (!g_has_tomi[id])
  595. return HAM_IGNORED;
  596.  
  597. if (g_tomi_TmpClip[id] == -1)
  598. return HAM_IGNORED;
  599.  
  600. set_pdata_int(weapon_entity, m_iClip, g_tomi_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  601.  
  602. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, tomi_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  603.  
  604. set_pdata_float(id, m_flNextAttack, tomi_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  605.  
  606. set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  607.  
  608. // relaod animation
  609. UTIL_PlayWeaponAnimation(id, 1)
  610.  
  611. return HAM_IGNORED;
  612. }
  613.  
  614. stock drop_weapons(id, dropwhat)
  615. {
  616. static weapons[32], num, i, weaponid
  617. num = 0
  618. get_user_weapons(id, weapons, num)
  619.  
  620. for (i = 0; i < num; i++)
  621. {
  622. weaponid = weapons[i]
  623.  
  624. if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  625. {
  626. static wname[32]
  627. get_weaponname(weaponid, wname, sizeof wname - 1)
  628. engclient_cmd(id, "drop", wname)
  629. }
  630. }
  631. }

_________________
[mozgo]Bogdan for President[/mozgo]
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 17:17 
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: 85 alkalommal
Gombok! cobra parancsra jön!

SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <fun>
  5. #include <hamsandwich>
  6. #include <xs>
  7. #include <cstrike>
  8. #include <zombieplague>
  9.  
  10. #define ENG_NULLENT -1
  11. #define EV_INT_WEAPONKEY EV_INT_impulse
  12. #define cobra_WEAPONKEY 820
  13. #define MAX_PLAYERS 32
  14. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  15.  
  16. #pragma tabsize 0
  17.  
  18. const USE_STOPPED = 0
  19. const OFFSET_ACTIVE_ITEM = 373
  20. const OFFSET_WEAPONOWNER = 41
  21. const OFFSET_LINUX = 5
  22. const OFFSET_LINUX_WEAPONS = 4
  23.  
  24. #define WEAP_LINUX_XTRA_OFF 4
  25. #define m_fKnown 44
  26. #define m_flNextPrimaryAttack 46
  27. #define m_flTimeWeaponIdle 48
  28. #define m_iClip 51
  29. #define m_fInReload 54
  30. #define PLAYER_LINUX_XTRA_OFF 5
  31. #define m_flNextAttack 83
  32.  
  33. #define cobra_RELOAD_TIME 2.4
  34. #define cobra_SHOOT1 1
  35. #define cobra_SHOOT2 2
  36. #define cobra_SHOOT_EMPTY 3
  37. #define cobra_RELOAD 4
  38. #define cobra_DRAW 5
  39.  
  40. #define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
  41.  
  42. new const Fire_Sounds[][] = { "weapons/kingcobra-1.wav" }
  43. new const Sound_Zoom[] = { "weapons/zoom.wav" }
  44.  
  45. new cobra_V_MODEL[64] = "models/v_kingcobra.mdl"
  46. new cobra_P_MODEL[64] = "models/p_kingcobra.mdl"
  47. new cobra_W_MODEL[64] = "models/w_kingcobra.mdl"
  48.  
  49. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  50.  
  51. new cvar_dmg_cobra, cvar_recoil_cobra, g_itemid_cobra, cvar_clip_cobra, cvar_spd_cobra, cvar_cobra_ammo
  52. new g_MaxPlayers, g_orig_event_cobra, g_IsInPrimaryAttack, g_iClip
  53. new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
  54. new g_has_cobra[33], g_clip_ammo[33], g_cobra_TmpClip[33], oldweap[33]
  55. new g_hasZoom[33]
  56. new gmsgWeaponList
  57.  
  58. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  59. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_deagle", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  60. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  61. "weapon_ak47", "weapon_knife", "weapon_p90" }
  62.  
  63. public plugin_init()
  64. {
  65. register_plugin("[ZP] Pistols", "1.0", "Crock / SaS")
  66. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  67. register_event("CurWeapon","CurrentWeapon","be","1=1")
  68. RegisterHam(Ham_Item_AddToPlayer, "weapon_deagle", "fw_cobra_AddToPlayer")
  69. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  70. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  71. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  72. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  73. for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  74. if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  75. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_cobra_PrimaryAttack")
  76. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_cobra_PrimaryAttack_Post", 1)
  77. RegisterHam(Ham_Item_PostFrame, "weapon_deagle", "cobra_ItemPostFrame")
  78. RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "cobra_Reload")
  79. RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "cobra_Reload_Post", 1)
  80. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  81. register_forward(FM_SetModel, "fw_SetModel")
  82. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  83. register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  84. register_forward(FM_CmdStart, "fw_CmdStart")
  85.  
  86. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  87. RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  88. RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  89. RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  90. RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  91. RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  92. RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  93.  
  94. cvar_dmg_cobra = register_cvar("zp_cobra_dmg", "1.2")
  95. cvar_recoil_cobra = register_cvar("zp_cobra_recoil", "1.0")
  96. cvar_clip_cobra = register_cvar("zp_cobra_clip", "7")
  97. cvar_spd_cobra = register_cvar("zp_cobra_spd", "0.7")
  98. cvar_cobra_ammo = register_cvar("zp_cobra_ammo", "70")
  99.  
  100. g_itemid_cobra = zp_register_extra_item("Colt King Cobra", 1, ZP_TEAM_HUMAN)
  101. g_MaxPlayers = get_maxplayers()
  102. gmsgWeaponList = get_user_msgid("WeaponList")
  103. }
  104.  
  105. public plugin_precache()
  106. {
  107. precache_model(cobra_V_MODEL)
  108. precache_model(cobra_P_MODEL)
  109. precache_model(cobra_W_MODEL)
  110. for(new i = 0; i < sizeof Fire_Sounds; i++)
  111. precache_sound(Fire_Sounds[i])
  112. precache_sound(Sound_Zoom)
  113. precache_sound("weapons/kingcobra_clipin.wav")
  114. precache_sound("weapons/kingcobra_clipout.wav")
  115. precache_sound("weapons/kingcobra_draw.wav")
  116. precache_sound("weapons/kingcobra_shot_empty.wav")
  117. m_iBlood[0] = precache_model("sprites/blood.spr")
  118. m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  119. precache_generic("sprites/weapon_cobra.txt")
  120. precache_generic("sprites/cobra_scope.spr")
  121. precache_generic("sprites/640hud77.spr")
  122. precache_generic("sprites/640hud7.spr")
  123.  
  124. register_clcmd("cobra", "weapon_hook")
  125.  
  126. register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  127. }
  128.  
  129. public weapon_hook(id)
  130. {
  131. engclient_cmd(id, "weapon_deagle")
  132. return PLUGIN_HANDLED
  133. }
  134.  
  135. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  136. {
  137. if(!is_user_alive(iAttacker))
  138. return
  139.  
  140. new g_currentweapon = get_user_weapon(iAttacker)
  141.  
  142. if(g_currentweapon != CSW_DEAGLE) return
  143.  
  144. if(!g_has_cobra[iAttacker]) return
  145.  
  146. static Float:flEnd[3]
  147. get_tr2(ptr, TR_vecEndPos, flEnd)
  148.  
  149. if(iEnt)
  150. {
  151. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  152. write_byte(TE_DECAL)
  153. write_coord_f(flEnd[0])
  154. write_coord_f(flEnd[1])
  155. write_coord_f(flEnd[2])
  156. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  157. write_short(iEnt)
  158. message_end()
  159. }
  160. else
  161. {
  162. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  163. write_byte(TE_WORLDDECAL)
  164. write_coord_f(flEnd[0])
  165. write_coord_f(flEnd[1])
  166. write_coord_f(flEnd[2])
  167. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  168. message_end()
  169. }
  170. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  171. write_byte(TE_GUNSHOTDECAL)
  172. write_coord_f(flEnd[0])
  173. write_coord_f(flEnd[1])
  174. write_coord_f(flEnd[2])
  175. write_short(iAttacker)
  176. write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  177. message_end()
  178. }
  179.  
  180. public zp_user_humanized_post(id)
  181. {
  182. g_has_cobra[id] = false
  183. }
  184.  
  185. public plugin_natives ()
  186. {
  187. register_native("give_weapon_cobra", "native_give_weapon_add", 1)
  188. }
  189. public native_give_weapon_add(id)
  190. {
  191. give_cobra(id)
  192. }
  193.  
  194. public fwPrecacheEvent_Post(type, const name[])
  195. {
  196. if (equal("events/deagle.sc", name))
  197. {
  198. g_orig_event_cobra = get_orig_retval()
  199. return FMRES_HANDLED
  200. }
  201. return FMRES_IGNORED
  202. }
  203.  
  204. public client_connect(id)
  205. {
  206. g_has_cobra[id] = false
  207. }
  208.  
  209. public client_disconnect(id)
  210. {
  211. g_has_cobra[id] = false
  212. }
  213.  
  214. public zp_user_infected_post(id)
  215. {
  216. if (zp_get_user_zombie(id))
  217. {
  218. g_has_cobra[id] = false
  219. }
  220. }
  221.  
  222. public fw_SetModel(entity, model[])
  223. {
  224. if(!is_valid_ent(entity))
  225. return FMRES_IGNORED
  226.  
  227. static szClassName[33]
  228. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  229.  
  230. if(!equal(szClassName, "weaponbox"))
  231. return FMRES_IGNORED
  232.  
  233. static iOwner
  234.  
  235. iOwner = entity_get_edict(entity, EV_ENT_owner)
  236.  
  237. if(equal(model, "models/w_deagle.mdl"))
  238. {
  239. static iStoredAugID
  240.  
  241. iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_deagle", entity)
  242.  
  243. if(!is_valid_ent(iStoredAugID))
  244. return FMRES_IGNORED
  245.  
  246. if(g_has_cobra[iOwner])
  247. {
  248. entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, cobra_WEAPONKEY)
  249.  
  250. g_has_cobra[iOwner] = false
  251.  
  252. entity_set_model(entity, cobra_W_MODEL)
  253.  
  254. return FMRES_SUPERCEDE
  255. }
  256. }
  257. return FMRES_IGNORED
  258. }
  259.  
  260. public give_cobra(id)
  261. {
  262. drop_weapons(id, 2)
  263. new iWep2 = give_item(id,"weapon_deagle")
  264. if( iWep2 > 0 )
  265. {
  266. cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_cobra))
  267. cs_set_user_bpammo (id, CSW_DEAGLE, get_pcvar_num(cvar_cobra_ammo))
  268. UTIL_PlayWeaponAnimation(id, cobra_DRAW)
  269. set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  270.  
  271. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  272. write_string("weapon_cobra")
  273. write_byte(8)
  274. write_byte(35)
  275. write_byte(-1)
  276. write_byte(-1)
  277. write_byte(1)
  278. write_byte(1)
  279. write_byte(CSW_DEAGLE)
  280. message_end()
  281. }
  282. g_has_cobra[id] = true
  283. }
  284.  
  285. public zp_extra_item_selected(id, itemid)
  286. {
  287. if(itemid != g_itemid_cobra)
  288. return
  289.  
  290. give_cobra(id)
  291. }
  292.  
  293. public fw_cobra_AddToPlayer(cobra, id)
  294. {
  295. if(!is_valid_ent(cobra) || !is_user_connected(id))
  296. return HAM_IGNORED
  297.  
  298. if(entity_get_int(cobra, EV_INT_WEAPONKEY) == cobra_WEAPONKEY)
  299. {
  300. g_has_cobra[id] = true
  301.  
  302. entity_set_int(cobra, EV_INT_WEAPONKEY, 0)
  303.  
  304. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  305. write_string("weapon_cobra")
  306. write_byte(8)
  307. write_byte(35)
  308. write_byte(-1)
  309. write_byte(-1)
  310. write_byte(1)
  311. write_byte(1)
  312. write_byte(CSW_DEAGLE)
  313. message_end()
  314.  
  315. return HAM_HANDLED
  316. }
  317. else
  318. {
  319. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  320. write_string("weapon_deagle")
  321. write_byte(8)
  322. write_byte(35)
  323. write_byte(-1)
  324. write_byte(-1)
  325. write_byte(1)
  326. write_byte(1)
  327. write_byte(CSW_DEAGLE)
  328. message_end()
  329. }
  330. return HAM_IGNORED
  331. }
  332.  
  333. public fw_UseStationary_Post(entity, caller, activator, use_type)
  334. {
  335. if (use_type == USE_STOPPED && is_user_connected(caller))
  336. replace_weapon_models(caller, get_user_weapon(caller))
  337. }
  338.  
  339. public fw_Item_Deploy_Post(weapon_ent)
  340. {
  341. static owner
  342. owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  343.  
  344. static weaponid
  345. weaponid = cs_get_weapon_id(weapon_ent)
  346.  
  347. replace_weapon_models(owner, weaponid)
  348. }
  349.  
  350. public CurrentWeapon(id)
  351. {
  352. replace_weapon_models(id, read_data(2))
  353.  
  354. if(read_data(2) != CSW_DEAGLE || !g_has_cobra[id])
  355. return
  356.  
  357. static Float:iSpeed
  358. if(g_has_cobra[id])
  359. iSpeed = get_pcvar_float(cvar_spd_cobra)
  360.  
  361. static weapon[32],Ent
  362. get_weaponname(read_data(2),weapon,31)
  363. Ent = find_ent_by_owner(-1,weapon,id)
  364. if(Ent)
  365. {
  366. static Float:Delay
  367. Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  368. if (Delay > 0.0)
  369. {
  370. set_pdata_float(Ent, 46, Delay, 4)
  371. }
  372. }
  373. }
  374.  
  375. replace_weapon_models(id, weaponid)
  376. {
  377. switch (weaponid)
  378. {
  379. case CSW_DEAGLE:
  380. {
  381. if (zp_get_user_zombie(id) || zp_get_user_survivor(id))
  382. return
  383.  
  384. if(g_has_cobra[id])
  385. {
  386. set_pev(id, pev_viewmodel2, cobra_V_MODEL)
  387. set_pev(id, pev_weaponmodel2, cobra_P_MODEL)
  388. if(oldweap[id] != CSW_DEAGLE)
  389. {
  390. UTIL_PlayWeaponAnimation(id, cobra_DRAW)
  391. set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
  392.  
  393. message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  394. write_string("weapon_cobra")
  395. write_byte(8)
  396. write_byte(35)
  397. write_byte(-1)
  398. write_byte(-1)
  399. write_byte(1)
  400. write_byte(1)
  401. write_byte(CSW_DEAGLE)
  402. message_end()
  403. }
  404. }
  405. }
  406. }
  407. oldweap[id] = weaponid
  408. }
  409.  
  410. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  411. {
  412. if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_DEAGLE || !g_has_cobra[Player]))
  413. return FMRES_IGNORED
  414.  
  415. set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  416. return FMRES_HANDLED
  417. }
  418.  
  419. public fw_cobra_PrimaryAttack(Weapon)
  420. {
  421. new Player = get_pdata_cbase(Weapon, 41, 4)
  422.  
  423. if (!g_has_cobra[Player])
  424. return
  425.  
  426. g_IsInPrimaryAttack = 1
  427. pev(Player,pev_punchangle,cl_pushangle[Player])
  428.  
  429. g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  430. g_iClip = cs_get_weapon_ammo(Weapon)
  431. }
  432.  
  433. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  434. {
  435. if ((eventid != g_orig_event_cobra) || !g_IsInPrimaryAttack)
  436. return FMRES_IGNORED
  437. if (!(1 <= invoker <= g_MaxPlayers))
  438. return FMRES_IGNORED
  439.  
  440. playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  441. return FMRES_SUPERCEDE
  442. }
  443.  
  444. public fw_cobra_PrimaryAttack_Post(Weapon)
  445. {
  446. g_IsInPrimaryAttack = 0
  447. new Player = get_pdata_cbase(Weapon, 41, 4)
  448.  
  449. new szClip, szAmmo
  450. get_user_weapon(Player, szClip, szAmmo)
  451.  
  452. if(!is_user_alive(Player))
  453. return
  454.  
  455. if (g_iClip <= cs_get_weapon_ammo(Weapon))
  456. return
  457.  
  458. if(g_has_cobra[Player])
  459. {
  460. if (!g_clip_ammo[Player])
  461. return
  462.  
  463. new Float:push[3]
  464. pev(Player,pev_punchangle,push)
  465. xs_vec_sub(push,cl_pushangle[Player],push)
  466.  
  467. xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_cobra),push)
  468. xs_vec_add(push,cl_pushangle[Player],push)
  469. set_pev(Player,pev_punchangle,push)
  470.  
  471. emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  472. if(szClip > 1) UTIL_PlayWeaponAnimation(Player, random_num(cobra_SHOOT1,cobra_SHOOT2))
  473. if(szClip == 1) UTIL_PlayWeaponAnimation(Player, cobra_SHOOT_EMPTY)
  474. }
  475. }
  476.  
  477. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  478. {
  479. if (victim != attacker && is_user_connected(attacker))
  480. {
  481. if(get_user_weapon(attacker) == CSW_DEAGLE)
  482. {
  483. if(g_has_cobra[attacker])
  484. SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_cobra))
  485. }
  486. }
  487. }
  488.  
  489. public message_DeathMsg(msg_id, msg_dest, id)
  490. {
  491. static szTruncatedWeapon[33], iAttacker, iVictim
  492.  
  493. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  494.  
  495. iAttacker = get_msg_arg_int(1)
  496. iVictim = get_msg_arg_int(2)
  497.  
  498. if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  499. return PLUGIN_CONTINUE
  500.  
  501. if(equal(szTruncatedWeapon, "deagle") && get_user_weapon(iAttacker) == CSW_DEAGLE)
  502. {
  503. if(g_has_cobra[iAttacker])
  504. set_msg_arg_string(4, "deagle")
  505. }
  506. return PLUGIN_CONTINUE
  507. }
  508.  
  509. stock fm_cs_get_current_weapon_ent(id)
  510. {
  511. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  512. }
  513.  
  514. stock fm_cs_get_weapon_ent_owner(ent)
  515. {
  516. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  517. }
  518.  
  519. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  520. {
  521. set_pev(Player, pev_weaponanim, Sequence)
  522.  
  523. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  524. write_byte(Sequence)
  525. write_byte(pev(Player, pev_body))
  526. message_end()
  527. }
  528.  
  529. public fw_CmdStart(id, uc_handle, seed)
  530. {
  531. if(!is_user_alive(id))
  532. return PLUGIN_HANDLED
  533.  
  534. if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
  535. {
  536. new szClip, szAmmo
  537. new szWeapID = get_user_weapon(id, szClip, szAmmo)
  538.  
  539. if(szWeapID == CSW_DEAGLE && g_has_cobra[id] && !g_hasZoom[id] == true)
  540. {
  541. g_hasZoom[id] = true
  542. cs_set_user_zoom(id, CS_SET_FIRST_ZOOM, 1)
  543. emit_sound(id, CHAN_ITEM, Sound_Zoom, 0.20, 2.40, 0, 100)
  544. }
  545.  
  546. else if(szWeapID == CSW_DEAGLE && g_has_cobra[id] && g_hasZoom[id])
  547. {
  548. g_hasZoom[id] = false
  549. cs_set_user_zoom(id, CS_SET_NO_ZOOM, 0)
  550.  
  551. }
  552.  
  553. }
  554.  
  555. if (g_hasZoom[ id ] && (pev(id, pev_button) & IN_RELOAD))
  556. {
  557. g_hasZoom[ id ] = false
  558. cs_set_user_zoom( id, CS_SET_NO_ZOOM, 0 )
  559. }
  560. return PLUGIN_HANDLED
  561. }
  562.  
  563. public cobra_ItemPostFrame(weapon_entity)
  564. {
  565. new id = pev(weapon_entity, pev_owner)
  566. if (!is_user_connected(id))
  567. return HAM_IGNORED
  568.  
  569. if (!g_has_cobra[id])
  570. return HAM_IGNORED
  571.  
  572. static iClipExtra
  573.  
  574. iClipExtra = get_pcvar_num(cvar_clip_cobra)
  575. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  576.  
  577. new iBpAmmo = cs_get_user_bpammo(id, CSW_DEAGLE);
  578. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  579.  
  580. new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  581.  
  582. if( fInReload && flNextAttack <= 0.0 )
  583. {
  584. new j = min(iClipExtra - iClip, iBpAmmo)
  585.  
  586. set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  587. cs_set_user_bpammo(id, CSW_DEAGLE, iBpAmmo-j)
  588.  
  589. set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  590. fInReload = 0
  591. }
  592. return HAM_IGNORED
  593. }
  594.  
  595. public cobra_Reload(weapon_entity)
  596. {
  597. new id = pev(weapon_entity, pev_owner)
  598. if (!is_user_connected(id))
  599. return HAM_IGNORED
  600.  
  601. if (!g_has_cobra[id])
  602. return HAM_IGNORED
  603.  
  604. static iClipExtra
  605.  
  606. if(g_has_cobra[id])
  607. iClipExtra = get_pcvar_num(cvar_clip_cobra)
  608.  
  609. g_cobra_TmpClip[id] = -1
  610.  
  611. new iBpAmmo = cs_get_user_bpammo(id, CSW_DEAGLE)
  612. new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  613.  
  614. if (iBpAmmo <= 0)
  615. return HAM_SUPERCEDE
  616.  
  617. if (iClip >= iClipExtra)
  618. return HAM_SUPERCEDE
  619.  
  620. g_cobra_TmpClip[id] = iClip
  621.  
  622. return HAM_IGNORED
  623. }
  624.  
  625. public cobra_Reload_Post(weapon_entity)
  626. {
  627. new id = pev(weapon_entity, pev_owner)
  628. if (!is_user_connected(id))
  629. return HAM_IGNORED
  630.  
  631. if (!g_has_cobra[id])
  632. return HAM_IGNORED
  633.  
  634. if (g_cobra_TmpClip[id] == -1)
  635. return HAM_IGNORED
  636.  
  637. set_pdata_int(weapon_entity, m_iClip, g_cobra_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  638.  
  639. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, cobra_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
  640.  
  641. set_pdata_float(id, m_flNextAttack, cobra_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
  642.  
  643. set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  644.  
  645. UTIL_PlayWeaponAnimation(id, cobra_RELOAD)
  646.  
  647. return HAM_IGNORED
  648. }
  649.  
  650. stock drop_weapons(id, dropwhat)
  651. {
  652. static weapons[32], num, i, weaponid
  653. num = 0
  654. get_user_weapons(id, weapons, num)
  655.  
  656. for (i = 0; i < num; i++)
  657. {
  658. weaponid = weapons[i]
  659.  
  660. if (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  661. {
  662. static wname[32]
  663. get_weaponname(weaponid, wname, sizeof wname - 1)
  664. engclient_cmd(id, "drop", wname)
  665. }
  666. }
  667. }

Ők köszönték meg stupid nek ezt a hozzászólást: JAck (2013.09.01. 17:20)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 17:19 
Offline
Senior Tag

Csatlakozott: 2012.07.09. 11:57
Hozzászólások: 234
Megköszönt másnak: 20 alkalommal
Megköszönték neki: 12 alkalommal
Nyomom a gombokat csak először letesztelem őket:D

_________________
[mozgo]Bogdan for President[/mozgo]
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Dual Infinity
HozzászólásElküldve: 2013.09.01. 17:20 
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: 85 alkalommal
Nem plugin hiba! Tedd át Ansi kódolásba ne UTF-8 ba legyen! Ha nem értedakkor tudnék még segíteni.


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  [ 17 hozzászólás ]  Oldal Előző 1 2


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 31 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