hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.05.02. 07:41



Jelenlévő felhasználók

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

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

Regisztrált felhasználók: nincs regisztrált felhasználó 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  [ 4 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: ZM Vip
HozzászólásElküldve: 2013.04.04. 15:28 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
A zombi viphez hogy lehet több extrát hozzáadni pl vizipuskát,gépfegyvert?

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZM Vip
HozzászólásElküldve: 2013.04.05. 12:21 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
http://forums.alliedmods.net/showpost.p ... stcount=99


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZM Vip
HozzászólásElküldve: 2013.04.05. 13:15 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
HuBaBuBa írta:
http://forums.alliedmods.net/showpost.php?p=1159076&postcount=99

Ezt megtudod csinálni hogy lássam hogy kell?
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <fakemeta_util>
  5. #include <hamsandwich>
  6. #include <fun>
  7. #include <engine>
  8. #include <cstrike>
  9. #include <zombieplague>
  10. #define EWEAPON_W_MODEL "models/cso_wpn/w_waterpistol.mdl"
  11. #define EWEAPON_V_MODEL "models/cso_wpn/v_waterpistol.mdl"
  12. #define EWEAPON_P_MODEL "models/cso_wpn/p_waterpistol.mdl"
  13. #define EWEAPON_SOUND_FIRE "weapons/water-1.wav"
  14. #define EWEAPON_SOUND_EMPTY "weapons/ak47_clipout.wav"
  15.  
  16. #define EWEAPON_LOGNAME "watergun"
  17.  
  18. #define EWEAPON_WEAPONKEY 1200788
  19. #define EWEAPON_BASE_WEAPON "weapon_ump45"
  20.  
  21. #define EWEAPON_CLIPSIZE 70
  22. #define EWEAPON_START_AMMO 300
  23.  
  24. #define EWEAPON_SHOOT_NEXTATTACKTIME 0.1
  25. #define EWEAPON_SHOOT_NEXTIDLETIME 0.1
  26. #define EWEAPON_SHOOTEMPTY_NEXTATTACKTIME 0.2
  27. #define EWEAPON_SHOOTEMPTY_NEXTIDLETIME 0.2
  28. #define EWEAPON_RELOAD_TIME 2.3
  29. #define EWEAPON_BASE_DAMAGE 70.0
  30.  
  31. #define EWEAPON_HORIZONTAL_RECOIL 150
  32. #define EWEAPON_VERTICAL_RECOIL 1
  33.  
  34. #define ANIM_IDLE 0
  35. #define ANIM_IDLE_EMPTY 3
  36. #define ANIM_RELOAD 4
  37. #define ANIM_DRAW 5
  38. #define ANIM_DRAW_EMPTY 2
  39. #define ANIM_FIRE1 1
  40. #define ANIM_FIRE2 1
  41. #define ANIM_FIRE3 1
  42.  
  43. #define ANIM_PLAYER_POSTFIX "rifle"
  44.  
  45. #define FIRE_WATERSPRAY
  46. /* ------------------------------------------------- */
  47.  
  48. new g_EWeaponId = 0;
  49. new g_OriginalWModel[128];
  50. #define EV_INT_WEAPONKEY EV_INT_impulse
  51. #define MAX_PLAYERS 32
  52.  
  53. new DecalsShot[5] = {41, 42, 43, 44, 45};
  54. new g_BloodDecals[6];
  55. new g_BloodSprite[2];
  56.  
  57. enum _:e_EWepState
  58. {
  59. bool:wep_have,
  60. bool:wep_active,
  61. wep_ent,
  62. wep_TmpClip,
  63. };
  64.  
  65. new g_EWepPlayerData[MAX_PLAYERS+1][e_EWepState];
  66.  
  67. //CBaseWeapon fields
  68. #define m_fKnown 44
  69. #define m_flNextPrimaryAttack 46
  70. #define m_flTimeWeaponIdle 48
  71. #define m_iClip 51
  72. #define m_fInReload 54
  73. #define m_flNextAttack 83
  74. #define CBASEWEAPON_LINUX_XTRA_OFF 4
  75.  
  76. new const g_item_name[] = { "\wVizipisztoly\r[CSO]" };
  77. new g_itemid_guitar;
  78. const g_item_cost = 18;
  79.  
  80. #if defined FIRE_WATERSPRAY
  81. new tracer_sprite;
  82. new tracer_sprite2;
  83. #endif //FIRE_WATERSPRAY
  84.  
  85. public plugin_init() {
  86. register_plugin("[ZP] Extra: Guitar!", "0.7.0", "Crock");
  87. g_itemid_guitar = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN);
  88.  
  89. InitDecals();
  90.  
  91. RegisterHam(Ham_Weapon_PrimaryAttack, EWEAPON_BASE_WEAPON, "CWeapon__PrimaryAttack");
  92. RegisterHam(Ham_Item_Deploy, EWEAPON_BASE_WEAPON, "CWeapon__Deploy", 1);
  93. RegisterHam(Ham_Item_AddToPlayer, EWEAPON_BASE_WEAPON, "CWeapon__AddToPlayer");
  94. RegisterHam(Ham_Item_AttachToPlayer, EWEAPON_BASE_WEAPON, "CWeapon__AttachToPlayer");
  95. RegisterHam(Ham_Item_PostFrame, EWEAPON_BASE_WEAPON, "CWeapon__ItemPostFrame");
  96. RegisterHam(Ham_Weapon_Reload, EWEAPON_BASE_WEAPON, "CWeapon__Reload");
  97. RegisterHam(Ham_Weapon_Reload, EWEAPON_BASE_WEAPON, "CWeapon__Reload_Post", 1);
  98.  
  99. register_forward(FM_SetModel, "CWeapon__SetModel");
  100. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1);
  101. register_event("CurWeapon", "event_curweapon", "be", "1=1");
  102. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
  103.  
  104. g_EWeaponId = get_weaponid(EWEAPON_BASE_WEAPON);
  105. }
  106.  
  107. stock InitDecals()
  108. {
  109. g_BloodDecals[0] = get_decal_index("{blood1");
  110. g_BloodDecals[1] = get_decal_index("{blood2");
  111. g_BloodDecals[2] = get_decal_index("{blood3");
  112. g_BloodDecals[3] = get_decal_index("{blood4");
  113. g_BloodDecals[4] = get_decal_index("{blood5");
  114. g_BloodDecals[5] = get_decal_index("{blood6");
  115. }
  116.  
  117. public plugin_precache() {
  118. precache_model(EWEAPON_W_MODEL);
  119. precache_model(EWEAPON_V_MODEL);
  120. precache_model(EWEAPON_P_MODEL);
  121.  
  122. precache_sound(EWEAPON_SOUND_FIRE);
  123. precache_sound(EWEAPON_SOUND_EMPTY);
  124.  
  125. g_BloodSprite[0] = precache_model("sprites/blood.spr")
  126. g_BloodSprite[1] = precache_model("sprites/bloodspray.spr")
  127.  
  128. #if defined FIRE_WATERSPRAY
  129. tracer_sprite = precache_model("sprites/bluejet1.spr");
  130. tracer_sprite2 = precache_model("sprites/blueflare2.spr");
  131. #endif
  132. }
  133.  
  134. public CWeapon__PrimaryAttack(weapon_entity) {
  135. if(!is_valid_ent(weapon_entity))
  136. return HAM_IGNORED;
  137.  
  138. new id = pev(weapon_entity, pev_owner)
  139. if (!is_user_connected(id))
  140. return HAM_IGNORED;
  141.  
  142. if (!g_EWepPlayerData[id][wep_have])
  143. return HAM_IGNORED;
  144.  
  145. static szClassName[33]
  146. entity_get_string(weapon_entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  147.  
  148. new iClip = get_pdata_int(weapon_entity, m_iClip, CBASEWEAPON_LINUX_XTRA_OFF)
  149. if (iClip <= 0) {
  150. send_weapon_animation(id, ANIM_IDLE_EMPTY)
  151. engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, EWEAPON_SOUND_EMPTY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  152.  
  153. set_pdata_float(weapon_entity, m_flNextPrimaryAttack, EWEAPON_SHOOTEMPTY_NEXTATTACKTIME, CBASEWEAPON_LINUX_XTRA_OFF)
  154. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, EWEAPON_SHOOTEMPTY_NEXTIDLETIME, CBASEWEAPON_LINUX_XTRA_OFF)
  155.  
  156. return HAM_SUPERCEDE;
  157. }
  158. iClip--;
  159. set_pdata_int(weapon_entity, m_iClip, iClip, CBASEWEAPON_LINUX_XTRA_OFF);
  160.  
  161. new anim;
  162. switch (random_num(0,2)) {
  163. case 0: anim = ANIM_FIRE1;
  164. case 1: anim = ANIM_FIRE2;
  165. default: anim = ANIM_FIRE3;
  166. }
  167. send_weapon_animation(id, anim);
  168.  
  169.  
  170. /* player model animation */
  171.  
  172. engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, EWEAPON_SOUND_FIRE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  173.  
  174.  
  175. static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3];
  176. pev(id, pev_v_angle, plrViewAngles);
  177.  
  178. static Float:VecSrc[3], Float:VecDst[3];
  179.  
  180. //VecSrc = pev->origin + pev->view_ofs;
  181. pev(id, pev_origin, PlrOrigin)
  182. pev(id, pev_view_ofs, VecSrc)
  183. xs_vec_add(VecSrc, PlrOrigin, VecSrc)
  184.  
  185. //VecDst = VecDir * 8192.0;
  186. angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
  187. xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
  188. xs_vec_add(VecDst, VecSrc, VecDst);
  189.  
  190. new hTrace = create_tr2()
  191. engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, id, hTrace)
  192. new hitEnt = get_tr2(hTrace, TR_pHit);
  193. get_tr2(hTrace, TR_vecEndPos, VecEnd);
  194.  
  195. #if defined FIRE_WATERSPRAY
  196. create_tracer_water(id, VecSrc, VecEnd)
  197. #endif //FIRE_WATERSPRAY
  198.  
  199. new bool:bNeedDrawShot = true;
  200.  
  201. if (pev_valid(hitEnt)) {
  202. new Float:takeDamage;
  203. pev(hitEnt, pev_takedamage, takeDamage);
  204.  
  205. if (takeDamage != 0.0) {
  206. bNeedDrawShot = false;
  207.  
  208. new Float:dmg = EWEAPON_BASE_DAMAGE;
  209.  
  210. new hitGroup = get_tr2(hTrace, TR_iHitgroup);
  211.  
  212. switch (hitGroup) {
  213. case HIT_HEAD: { dmg *= 1.0; }
  214. case HIT_LEFTARM: { dmg *= 0.5; }
  215. case HIT_RIGHTARM: { dmg *= 0.5; }
  216. case HIT_LEFTLEG: { dmg *= 0.5; }
  217. case HIT_RIGHTLEG: { dmg *= 0.5; }
  218. }
  219.  
  220. if (is_user_connected(hitEnt) && zp_get_user_zombie(hitEnt)) {
  221. ExecuteHamB(Ham_TakeDamage, hitEnt, id, id, dmg, DMG_BULLET | DMG_NEVERGIB);
  222. ExecuteHamB(Ham_TraceBleed, hitEnt, dmg, VecDir, hTrace, DMG_BULLET | DMG_NEVERGIB);
  223. make_blood(VecEnd, dmg, hitEnt);
  224. }
  225.  
  226. }
  227.  
  228. new solid = pev(hitEnt, pev_solid);
  229. if (solid != SOLID_BSP)
  230. bNeedDrawShot = false;
  231.  
  232. }
  233.  
  234. static Float:punchAngle[3];
  235. punchAngle[0] = float(random_num(-EWEAPON_VERTICAL_RECOIL, EWEAPON_VERTICAL_RECOIL)) / 100.0;
  236.  
  237. punchAngle[1] = float(random_num(-EWEAPON_HORIZONTAL_RECOIL, EWEAPON_HORIZONTAL_RECOIL)) / 100.0;
  238. punchAngle[2] = 0.0;
  239. set_pev(id, pev_punchangle, punchAngle);
  240.  
  241.  
  242. /* draw decal if needed */
  243.  
  244. if (bNeedDrawShot == true) {
  245. #if defined FIRE_WATERSPRAY
  246. #else
  247. create_shot(VecEnd, hitEnt);
  248. #endif //FIRE_WATERSPRAY
  249. } else {
  250. if (pev_valid(hitEnt)) {
  251. // engfunc(EngFunc_EmitAmbientSound, 0, VecEnd, "hit_body.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  252. }
  253. }
  254.  
  255. set_pdata_float(weapon_entity, m_flNextPrimaryAttack, EWEAPON_SHOOT_NEXTATTACKTIME, CBASEWEAPON_LINUX_XTRA_OFF)
  256. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, EWEAPON_SHOOT_NEXTIDLETIME, CBASEWEAPON_LINUX_XTRA_OFF)
  257.  
  258. free_tr2(hTrace);
  259.  
  260. return HAM_SUPERCEDE;
  261. }
  262.  
  263. public CWeapon__SetModel(entity, model[]) {
  264. if(!is_valid_ent(entity))
  265. return FMRES_IGNORED;
  266.  
  267. static szClassName[33]
  268. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  269.  
  270. // save original W_ model
  271. if (equal(szClassName, EWEAPON_BASE_WEAPON)) {
  272. copy(g_OriginalWModel, 127, model)
  273. }
  274.  
  275.  
  276. if (!equal(szClassName, "weaponbox")) {
  277. return FMRES_IGNORED;
  278. }
  279.  
  280. if (!g_OriginalWModel[0] || !equal(g_OriginalWModel, model)) {
  281. return FMRES_IGNORED;
  282. }
  283.  
  284. new entOwner = entity_get_edict(entity, EV_ENT_owner)
  285. new entStoredEWep = find_ent_by_owner(FM_NULLENT, EWEAPON_BASE_WEAPON, entity)
  286.  
  287. if(is_user_connected(entOwner) && \
  288. g_EWepPlayerData[entOwner][wep_have] == true &&
  289. is_valid_ent(entStoredEWep)) \
  290. {
  291. entity_set_int(entStoredEWep, EV_INT_WEAPONKEY, EWEAPON_WEAPONKEY)
  292.  
  293. // save ammo
  294. new bpammos = cs_get_user_bpammo(entOwner, g_EWeaponId);
  295. entity_set_int(entStoredEWep, EV_INT_weapons, bpammos);
  296. cs_set_user_bpammo(entOwner, g_EWeaponId, 0);
  297.  
  298. CWeapon__RemoveFromPlayer(entOwner)
  299.  
  300. entity_set_model(entity, EWEAPON_W_MODEL);
  301.  
  302. return FMRES_SUPERCEDE;
  303. }
  304.  
  305. return FMRES_IGNORED;
  306. }
  307.  
  308. stock CWeapon__RemoveFromPlayer(id) {
  309. g_EWepPlayerData[id][wep_have] = false;
  310. g_EWepPlayerData[id][wep_active] = false;
  311. g_EWepPlayerData[id][wep_ent] = 0;
  312. }
  313.  
  314. public CWeapon__Deploy(weapon_entity) {
  315. if (!is_valid_ent(weapon_entity))
  316. return HAM_IGNORED;
  317.  
  318. static szClassName[33]
  319. entity_get_string(weapon_entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  320.  
  321. new i, id = 0;
  322. for (i = 1; i < (MAX_PLAYERS+1); i++) {
  323. if (g_EWepPlayerData[i][wep_have] && g_EWepPlayerData[i][wep_ent] == weapon_entity)
  324. id = i;
  325. }
  326.  
  327.  
  328. if (!is_user_connected(id))
  329. return HAM_IGNORED;
  330.  
  331. if (!g_EWepPlayerData[id][wep_have])
  332. return HAM_IGNORED;
  333.  
  334. if (!equal(szClassName, EWEAPON_BASE_WEAPON)) {
  335. g_EWepPlayerData[id][wep_active] = false;
  336. return HAM_IGNORED;
  337. }
  338.  
  339. new iClip = get_pdata_int(weapon_entity, m_iClip, CBASEWEAPON_LINUX_XTRA_OFF)
  340.  
  341. set_pev(id, pev_viewmodel2, EWEAPON_V_MODEL);
  342. set_pev(id, pev_weaponmodel2, EWEAPON_P_MODEL);
  343.  
  344. g_EWepPlayerData[id][wep_active] = true;
  345.  
  346. if (iClip > 0)
  347. send_weapon_animation(id, ANIM_DRAW)
  348. else
  349. send_weapon_animation(id, ANIM_DRAW_EMPTY)
  350.  
  351. return HAM_IGNORED;
  352. }
  353.  
  354.  
  355. public CWeapon__AttachToPlayer(weapon_entity, id) {
  356. if (!is_valid_ent(weapon_entity))
  357. return HAM_IGNORED;
  358.  
  359. if (!is_user_connected(id))
  360. return HAM_IGNORED;
  361.  
  362. if (!g_EWepPlayerData[id][wep_have])
  363. return HAM_IGNORED;
  364.  
  365. if(get_pdata_int(weapon_entity, m_fKnown, CBASEWEAPON_LINUX_XTRA_OFF)) {
  366. return HAM_IGNORED;
  367. }
  368.  
  369. set_pdata_int(weapon_entity, m_iClip, EWEAPON_CLIPSIZE, CBASEWEAPON_LINUX_XTRA_OFF)
  370.  
  371. return HAM_IGNORED;
  372. }
  373.  
  374. public CWeapon__AddToPlayer(weapon_entity, id) {
  375. if (!is_valid_ent(weapon_entity))
  376. return HAM_IGNORED;
  377.  
  378. if (!is_user_connected(id))
  379. return HAM_IGNORED;
  380.  
  381. if(entity_get_int(weapon_entity, EV_INT_WEAPONKEY) == EWEAPON_WEAPONKEY && g_EWepPlayerData[id][wep_have] == false) {
  382.  
  383. entity_set_int(weapon_entity, EV_INT_WEAPONKEY, 0)
  384.  
  385. //restore ammo
  386. new bpammos = entity_get_int(weapon_entity, EV_INT_weapons);
  387. cs_set_user_bpammo(id, g_EWeaponId, bpammos);
  388.  
  389. g_EWepPlayerData[id][wep_have] = true;
  390. g_EWepPlayerData[id][wep_ent] = weapon_entity;
  391. return HAM_HANDLED;
  392. }
  393.  
  394. if (g_EWepPlayerData[id][wep_have] == true) {
  395. g_EWepPlayerData[id][wep_ent] = weapon_entity;
  396. }
  397.  
  398. return HAM_IGNORED;
  399. }
  400.  
  401. public CWeapon__ItemPostFrame(weapon_entity) {
  402. new id = pev(weapon_entity, pev_owner)
  403. if (!is_user_connected(id))
  404. return FMRES_IGNORED;
  405.  
  406. if (!g_EWepPlayerData[id][wep_have])
  407. return FMRES_IGNORED;
  408.  
  409. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack)
  410.  
  411. new iBpAmmo = cs_get_user_bpammo(id, g_EWeaponId);
  412. new iClip = get_pdata_int(weapon_entity, m_iClip)
  413.  
  414. new fInReload = get_pdata_int(weapon_entity, m_fInReload, CBASEWEAPON_LINUX_XTRA_OFF)
  415.  
  416. if (fInReload && flNextAttack <= 0.0) {
  417. new j = min(EWEAPON_CLIPSIZE - iClip, iBpAmmo)
  418.  
  419. set_pdata_int(weapon_entity, m_iClip, iClip + j, CBASEWEAPON_LINUX_XTRA_OFF)
  420. cs_set_user_bpammo(id, g_EWeaponId, iBpAmmo-j);
  421.  
  422. set_pdata_int(weapon_entity, m_fInReload, 0, CBASEWEAPON_LINUX_XTRA_OFF)
  423. fInReload = 0
  424. }
  425.  
  426. return FMRES_IGNORED;
  427. }
  428.  
  429. public CWeapon__Reload(weapon_entity) {
  430. new id = pev(weapon_entity, pev_owner)
  431. if (!is_user_connected(id))
  432. return FMRES_IGNORED;
  433.  
  434. if (!g_EWepPlayerData[id][wep_have])
  435. return FMRES_IGNORED;
  436.  
  437. g_EWepPlayerData[id][wep_TmpClip] = -1;
  438.  
  439. new iBpAmmo = cs_get_user_bpammo(id, g_EWeaponId);
  440. new iClip = get_pdata_int(weapon_entity, m_iClip, CBASEWEAPON_LINUX_XTRA_OFF)
  441.  
  442. if (iBpAmmo <= 0)
  443. return FMRES_SUPERCEDE;
  444.  
  445. if (iClip >= EWEAPON_CLIPSIZE)
  446. return FMRES_SUPERCEDE;
  447.  
  448.  
  449. g_EWepPlayerData[id][wep_TmpClip] = iClip;
  450.  
  451. set_pdata_int(weapon_entity, m_iClip, 0, CBASEWEAPON_LINUX_XTRA_OFF)
  452.  
  453. return FMRES_IGNORED;
  454. }
  455.  
  456. public CWeapon__Reload_Post(weapon_entity) {
  457. new id = pev(weapon_entity, pev_owner)
  458. if (!is_user_connected(id))
  459. return FMRES_IGNORED;
  460.  
  461. if (!g_EWepPlayerData[id][wep_have])
  462. return FMRES_IGNORED;
  463.  
  464. if (g_EWepPlayerData[id][wep_TmpClip] == -1)
  465. return FMRES_IGNORED;
  466.  
  467. set_pdata_int(weapon_entity, m_iClip, g_EWepPlayerData[id][wep_TmpClip], CBASEWEAPON_LINUX_XTRA_OFF)
  468.  
  469. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, EWEAPON_RELOAD_TIME, CBASEWEAPON_LINUX_XTRA_OFF)
  470.  
  471. set_pdata_float(id, m_flNextAttack, EWEAPON_RELOAD_TIME)
  472.  
  473. set_pdata_int(weapon_entity, m_fInReload, 1)
  474.  
  475. send_weapon_animation( id, ANIM_RELOAD )
  476.  
  477. g_EWepPlayerData[id][wep_TmpClip] = -1;
  478.  
  479. return FMRES_IGNORED;
  480. }
  481.  
  482. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle) {
  483. if(!is_user_alive(Player))
  484. return FMRES_IGNORED;
  485.  
  486. if(!g_EWepPlayerData[Player][wep_active])
  487. return FMRES_IGNORED;
  488.  
  489. set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  490. return FMRES_HANDLED
  491. }
  492.  
  493. public event_curweapon(id) {
  494. if(!is_user_alive(id))
  495. return PLUGIN_CONTINUE;
  496.  
  497. if(read_data(2) == g_EWeaponId && g_EWepPlayerData[id][wep_have] == true) {
  498. } else {
  499. g_EWepPlayerData[id][wep_active] = false;
  500. }
  501. return PLUGIN_HANDLED;
  502. }
  503.  
  504. public client_connect(id) {
  505. g_EWepPlayerData[id][wep_active] = false;
  506. g_EWepPlayerData[id][wep_have] = false;
  507. }
  508.  
  509. public client_disconnect(id) {
  510. if (g_EWepPlayerData[id][wep_have] == true) {
  511. CWeapon__RemoveFromPlayer(id)
  512. }
  513. }
  514.  
  515. public message_DeathMsg(msg_id, msg_dest, id) {
  516. static szTruncatedWeapon[33], iAttacker;
  517.  
  518. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon));
  519.  
  520. iAttacker = get_msg_arg_int(1);
  521.  
  522. if(is_user_connected(iAttacker) && g_EWepPlayerData[iAttacker][wep_have] == true && equal(szTruncatedWeapon, EWEAPON_BASE_WEAPON)) {
  523. set_msg_arg_string(4, EWEAPON_LOGNAME);
  524. }
  525.  
  526. return PLUGIN_CONTINUE;
  527. }
  528.  
  529. #if defined FIRE_WATERSPRAY
  530. stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3]) {
  531. static iVec1[3];
  532. FVecIVec(fVec1, iVec1);
  533.  
  534. static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3];
  535. pev(id, pev_v_angle, angles);
  536. engfunc(EngFunc_MakeVectors, angles);
  537. global_get(glb_v_forward, v_forward);
  538. global_get(glb_v_right, v_right);
  539. global_get(glb_v_up, v_up);
  540.  
  541. //m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
  542. pev(id, pev_origin, player_origin);
  543. pev(id, pev_view_ofs, player_view_offset);
  544. xs_vec_add(player_origin, player_view_offset, gun_position);
  545.  
  546. xs_vec_mul_scalar(v_forward, 24.0, v_forward);
  547. xs_vec_mul_scalar(v_right, 3.0, v_right);
  548.  
  549. if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
  550. xs_vec_mul_scalar(v_up, 6.0, v_up);
  551. else
  552. xs_vec_mul_scalar(v_up, -2.0, v_up);
  553.  
  554. xs_vec_add(gun_position, v_forward, origin);
  555. xs_vec_add(origin, v_right, origin);
  556. xs_vec_add(origin, v_up, origin);
  557.  
  558. vSrc[0] = origin[0];
  559. vSrc[1] = origin[1];
  560. vSrc[2] = origin[2];
  561.  
  562.  
  563. new Float:dist = get_distance_f(vSrc, fVec2);
  564. new CountDrops = floatround(dist / 50.0);
  565.  
  566. if (CountDrops > 20)
  567. CountDrops = 20;
  568.  
  569. if (CountDrops < 2)
  570. CountDrops = 2;
  571.  
  572. message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1);
  573. write_byte(TE_SPRITETRAIL);
  574. engfunc(EngFunc_WriteCoord, vSrc[0]);
  575. engfunc(EngFunc_WriteCoord, vSrc[1]);
  576. engfunc(EngFunc_WriteCoord, vSrc[2]);
  577. engfunc(EngFunc_WriteCoord, fVec2[0]);
  578. engfunc(EngFunc_WriteCoord, fVec2[1]);
  579. engfunc(EngFunc_WriteCoord, fVec2[2]);
  580. write_short(tracer_sprite2);
  581. write_byte(CountDrops); //count
  582. write_byte(0); //life
  583. write_byte(1); //scale
  584. write_byte(60); //velocity
  585. write_byte(10); //rand_velocity
  586. message_end();
  587.  
  588.  
  589. message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1);
  590. write_byte(TE_BEAMPOINTS);
  591. engfunc(EngFunc_WriteCoord, fVec2[0]);
  592. engfunc(EngFunc_WriteCoord, fVec2[1]);
  593. engfunc(EngFunc_WriteCoord, fVec2[2]);
  594. engfunc(EngFunc_WriteCoord, vSrc[0]);
  595. engfunc(EngFunc_WriteCoord, vSrc[1]);
  596. engfunc(EngFunc_WriteCoord, vSrc[2]);
  597. write_short(tracer_sprite);
  598. write_byte(6); //starting_frame
  599. write_byte(200); //framerate
  600. write_byte(1); //life
  601. write_byte(100); //line width
  602. write_byte(0); //noise ampl
  603. write_byte(64); write_byte(64); write_byte(192); //color
  604. write_byte(192); //brightness
  605. write_byte(250); //scroll speed
  606. message_end();
  607. }
  608. #endif //FIRE_WATERSPRAY
  609.  
  610. stock send_weapon_animation(id, iAnim) {
  611. set_pev(id, pev_weaponanim, iAnim);
  612. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id);
  613. write_byte(iAnim);
  614. write_byte(pev(id,pev_body));
  615. message_end();
  616. }
  617.  
  618. stock create_shot(Float:fOrigin[3], entity = 0) {
  619. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  620. write_byte(TE_GUNSHOTDECAL);
  621. engfunc(EngFunc_WriteCoord, fOrigin[0]);
  622. engfunc(EngFunc_WriteCoord, fOrigin[1]);
  623. engfunc(EngFunc_WriteCoord, fOrigin[2]);
  624. if(!pev_valid(entity)) {
  625. write_short(0);
  626. } else {
  627. write_short(entity);
  628. }
  629. write_byte(DecalsShot[random_num(0,4)]);
  630. message_end();
  631. }
  632.  
  633. stock make_blood(const Float:vTraceEnd[3], Float:Damage, hitEnt) {
  634. new bloodColor = ExecuteHam(Ham_BloodColor, hitEnt);
  635. if (bloodColor == -1)
  636. return;
  637.  
  638. new amount = floatround(Damage);
  639.  
  640. amount *= 2; //according to HLSDK
  641.  
  642. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  643. write_byte(TE_BLOODSPRITE);
  644. write_coord(floatround(vTraceEnd[0]));
  645. write_coord(floatround(vTraceEnd[1]));
  646. write_coord(floatround(vTraceEnd[2]));
  647. write_short(g_BloodSprite[1]);
  648. write_short(g_BloodSprite[0]);
  649. write_byte(bloodColor);
  650. write_byte(min(max(3, amount/10), 16));
  651. message_end();
  652. }
  653.  
  654. public zp_extra_item_selected(id, itemid) {
  655. if(itemid == g_itemid_guitar) {
  656. if (user_has_weapon(id, g_EWeaponId))
  657. engclient_cmd(id, "drop", EWEAPON_BASE_WEAPON);
  658.  
  659. g_EWepPlayerData[id][wep_have] = true;
  660. give_item(id, EWEAPON_BASE_WEAPON);
  661.  
  662. cs_set_user_bpammo (id, g_EWeaponId, EWEAPON_START_AMMO);
  663. }
  664. }
  665.  
  666. public zp_user_infected_post(id) {
  667. if (g_EWepPlayerData[id][wep_have] == true) {
  668. CWeapon__RemoveFromPlayer(id)
  669. }
  670. }
  671.  
  672. public zp_user_humanized_post(id, survivor) {
  673. if (survivor && g_EWepPlayerData[id][wep_have] == true) {
  674. CWeapon__RemoveFromPlayer(id)
  675. }
  676. }
  677.  

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZM Vip
HozzászólásElküldve: 2013.04.05. 14:01 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
Tessék..

SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <fakemeta_util>
  5. #include <hamsandwich>
  6. #include <fun>
  7. #include <engine>
  8. #include <cstrike>
  9. #include <zombieplague>
  10. #include <zmvip>
  11. #define EWEAPON_W_MODEL "models/cso_wpn/w_waterpistol.mdl"
  12. #define EWEAPON_V_MODEL "models/cso_wpn/v_waterpistol.mdl"
  13. #define EWEAPON_P_MODEL "models/cso_wpn/p_waterpistol.mdl"
  14. #define EWEAPON_SOUND_FIRE "weapons/water-1.wav"
  15. #define EWEAPON_SOUND_EMPTY "weapons/ak47_clipout.wav"
  16.  
  17. #define EWEAPON_LOGNAME "watergun"
  18.  
  19. #define EWEAPON_WEAPONKEY 1200788
  20. #define EWEAPON_BASE_WEAPON "weapon_ump45"
  21.  
  22. #define EWEAPON_CLIPSIZE 70
  23. #define EWEAPON_START_AMMO 300
  24.  
  25. #define EWEAPON_SHOOT_NEXTATTACKTIME 0.1
  26. #define EWEAPON_SHOOT_NEXTIDLETIME 0.1
  27. #define EWEAPON_SHOOTEMPTY_NEXTATTACKTIME 0.2
  28. #define EWEAPON_SHOOTEMPTY_NEXTIDLETIME 0.2
  29. #define EWEAPON_RELOAD_TIME 2.3
  30. #define EWEAPON_BASE_DAMAGE 70.0
  31.  
  32. #define EWEAPON_HORIZONTAL_RECOIL 150
  33. #define EWEAPON_VERTICAL_RECOIL 1
  34.  
  35. #define ANIM_IDLE 0
  36. #define ANIM_IDLE_EMPTY 3
  37. #define ANIM_RELOAD 4
  38. #define ANIM_DRAW 5
  39. #define ANIM_DRAW_EMPTY 2
  40. #define ANIM_FIRE1 1
  41. #define ANIM_FIRE2 1
  42. #define ANIM_FIRE3 1
  43.  
  44. #define ANIM_PLAYER_POSTFIX "rifle"
  45.  
  46. #define FIRE_WATERSPRAY
  47. /* ------------------------------------------------- */
  48.  
  49. new g_EWeaponId = 0;
  50. new g_OriginalWModel[128];
  51. #define EV_INT_WEAPONKEY EV_INT_impulse
  52. #define MAX_PLAYERS 32
  53.  
  54. new DecalsShot[5] = {41, 42, 43, 44, 45};
  55. new g_BloodDecals[6];
  56. new g_BloodSprite[2];
  57.  
  58. enum _:e_EWepState
  59. {
  60. bool:wep_have,
  61. bool:wep_active,
  62. wep_ent,
  63. wep_TmpClip,
  64. };
  65.  
  66. new g_EWepPlayerData[MAX_PLAYERS+1][e_EWepState];
  67.  
  68. //CBaseWeapon fields
  69. #define m_fKnown 44
  70. #define m_flNextPrimaryAttack 46
  71. #define m_flTimeWeaponIdle 48
  72. #define m_iClip 51
  73. #define m_fInReload 54
  74. #define m_flNextAttack 83
  75. #define CBASEWEAPON_LINUX_XTRA_OFF 4
  76.  
  77. new g_itemid_guitar;
  78. const g_item_cost = 18;
  79.  
  80. #if defined FIRE_WATERSPRAY
  81. new tracer_sprite;
  82. new tracer_sprite2;
  83. #endif //FIRE_WATERSPRAY
  84.  
  85. public plugin_init() {
  86. register_plugin("[ZP] Extra: Guitar!", "0.7.0", "Crock");
  87. g_itemid_guitar = zv_register_extra_item("Vizipityula", "Leiras", 12, ZV_TEAM_HUMAN);
  88.  
  89. InitDecals();
  90.  
  91. RegisterHam(Ham_Weapon_PrimaryAttack, EWEAPON_BASE_WEAPON, "CWeapon__PrimaryAttack");
  92. RegisterHam(Ham_Item_Deploy, EWEAPON_BASE_WEAPON, "CWeapon__Deploy", 1);
  93. RegisterHam(Ham_Item_AddToPlayer, EWEAPON_BASE_WEAPON, "CWeapon__AddToPlayer");
  94. RegisterHam(Ham_Item_AttachToPlayer, EWEAPON_BASE_WEAPON, "CWeapon__AttachToPlayer");
  95. RegisterHam(Ham_Item_PostFrame, EWEAPON_BASE_WEAPON, "CWeapon__ItemPostFrame");
  96. RegisterHam(Ham_Weapon_Reload, EWEAPON_BASE_WEAPON, "CWeapon__Reload");
  97. RegisterHam(Ham_Weapon_Reload, EWEAPON_BASE_WEAPON, "CWeapon__Reload_Post", 1);
  98.  
  99. register_forward(FM_SetModel, "CWeapon__SetModel");
  100. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1);
  101. register_event("CurWeapon", "event_curweapon", "be", "1=1");
  102. register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
  103.  
  104. g_EWeaponId = get_weaponid(EWEAPON_BASE_WEAPON);
  105. }
  106.  
  107. stock InitDecals()
  108. {
  109. g_BloodDecals[0] = get_decal_index("{blood1");
  110. g_BloodDecals[1] = get_decal_index("{blood2");
  111. g_BloodDecals[2] = get_decal_index("{blood3");
  112. g_BloodDecals[3] = get_decal_index("{blood4");
  113. g_BloodDecals[4] = get_decal_index("{blood5");
  114. g_BloodDecals[5] = get_decal_index("{blood6");
  115. }
  116.  
  117. public plugin_precache() {
  118. precache_model(EWEAPON_W_MODEL);
  119. precache_model(EWEAPON_V_MODEL);
  120. precache_model(EWEAPON_P_MODEL);
  121.  
  122. precache_sound(EWEAPON_SOUND_FIRE);
  123. precache_sound(EWEAPON_SOUND_EMPTY);
  124.  
  125. g_BloodSprite[0] = precache_model("sprites/blood.spr")
  126. g_BloodSprite[1] = precache_model("sprites/bloodspray.spr")
  127.  
  128. #if defined FIRE_WATERSPRAY
  129. tracer_sprite = precache_model("sprites/bluejet1.spr");
  130. tracer_sprite2 = precache_model("sprites/blueflare2.spr");
  131. #endif
  132. }
  133.  
  134. public CWeapon__PrimaryAttack(weapon_entity) {
  135. if(!is_valid_ent(weapon_entity))
  136. return HAM_IGNORED;
  137.  
  138. new id = pev(weapon_entity, pev_owner)
  139. if (!is_user_connected(id))
  140. return HAM_IGNORED;
  141.  
  142. if (!g_EWepPlayerData[id][wep_have])
  143. return HAM_IGNORED;
  144.  
  145. static szClassName[33]
  146. entity_get_string(weapon_entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  147.  
  148. new iClip = get_pdata_int(weapon_entity, m_iClip, CBASEWEAPON_LINUX_XTRA_OFF)
  149. if (iClip <= 0) {
  150. send_weapon_animation(id, ANIM_IDLE_EMPTY)
  151. engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, EWEAPON_SOUND_EMPTY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  152.  
  153. set_pdata_float(weapon_entity, m_flNextPrimaryAttack, EWEAPON_SHOOTEMPTY_NEXTATTACKTIME, CBASEWEAPON_LINUX_XTRA_OFF)
  154. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, EWEAPON_SHOOTEMPTY_NEXTIDLETIME, CBASEWEAPON_LINUX_XTRA_OFF)
  155.  
  156. return HAM_SUPERCEDE;
  157. }
  158. iClip--;
  159. set_pdata_int(weapon_entity, m_iClip, iClip, CBASEWEAPON_LINUX_XTRA_OFF);
  160.  
  161. new anim;
  162. switch (random_num(0,2)) {
  163. case 0: anim = ANIM_FIRE1;
  164. case 1: anim = ANIM_FIRE2;
  165. default: anim = ANIM_FIRE3;
  166. }
  167. send_weapon_animation(id, anim);
  168.  
  169.  
  170. /* player model animation */
  171.  
  172. engfunc(EngFunc_EmitSound, id, CHAN_WEAPON, EWEAPON_SOUND_FIRE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  173.  
  174.  
  175. static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3];
  176. pev(id, pev_v_angle, plrViewAngles);
  177.  
  178. static Float:VecSrc[3], Float:VecDst[3];
  179.  
  180. //VecSrc = pev->origin + pev->view_ofs;
  181. pev(id, pev_origin, PlrOrigin)
  182. pev(id, pev_view_ofs, VecSrc)
  183. xs_vec_add(VecSrc, PlrOrigin, VecSrc)
  184.  
  185. //VecDst = VecDir * 8192.0;
  186. angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
  187. xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
  188. xs_vec_add(VecDst, VecSrc, VecDst);
  189.  
  190. new hTrace = create_tr2()
  191. engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, id, hTrace)
  192. new hitEnt = get_tr2(hTrace, TR_pHit);
  193. get_tr2(hTrace, TR_vecEndPos, VecEnd);
  194.  
  195. #if defined FIRE_WATERSPRAY
  196. create_tracer_water(id, VecSrc, VecEnd)
  197. #endif //FIRE_WATERSPRAY
  198.  
  199. new bool:bNeedDrawShot = true;
  200.  
  201. if (pev_valid(hitEnt)) {
  202. new Float:takeDamage;
  203. pev(hitEnt, pev_takedamage, takeDamage);
  204.  
  205. if (takeDamage != 0.0) {
  206. bNeedDrawShot = false;
  207.  
  208. new Float:dmg = EWEAPON_BASE_DAMAGE;
  209.  
  210. new hitGroup = get_tr2(hTrace, TR_iHitgroup);
  211.  
  212. switch (hitGroup) {
  213. case HIT_HEAD: { dmg *= 1.0; }
  214. case HIT_LEFTARM: { dmg *= 0.5; }
  215. case HIT_RIGHTARM: { dmg *= 0.5; }
  216. case HIT_LEFTLEG: { dmg *= 0.5; }
  217. case HIT_RIGHTLEG: { dmg *= 0.5; }
  218. }
  219.  
  220. if (is_user_connected(hitEnt) && zp_get_user_zombie(hitEnt)) {
  221. ExecuteHamB(Ham_TakeDamage, hitEnt, id, id, dmg, DMG_BULLET | DMG_NEVERGIB);
  222. ExecuteHamB(Ham_TraceBleed, hitEnt, dmg, VecDir, hTrace, DMG_BULLET | DMG_NEVERGIB);
  223. make_blood(VecEnd, dmg, hitEnt);
  224. }
  225.  
  226. }
  227.  
  228. new solid = pev(hitEnt, pev_solid);
  229. if (solid != SOLID_BSP)
  230. bNeedDrawShot = false;
  231.  
  232. }
  233.  
  234. static Float:punchAngle[3];
  235. punchAngle[0] = float(random_num(-EWEAPON_VERTICAL_RECOIL, EWEAPON_VERTICAL_RECOIL)) / 100.0;
  236.  
  237. punchAngle[1] = float(random_num(-EWEAPON_HORIZONTAL_RECOIL, EWEAPON_HORIZONTAL_RECOIL)) / 100.0;
  238. punchAngle[2] = 0.0;
  239. set_pev(id, pev_punchangle, punchAngle);
  240.  
  241.  
  242. /* draw decal if needed */
  243.  
  244. if (bNeedDrawShot == true) {
  245. #if defined FIRE_WATERSPRAY
  246. #else
  247. create_shot(VecEnd, hitEnt);
  248. #endif //FIRE_WATERSPRAY
  249. } else {
  250. if (pev_valid(hitEnt)) {
  251. // engfunc(EngFunc_EmitAmbientSound, 0, VecEnd, "hit_body.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  252. }
  253. }
  254.  
  255. set_pdata_float(weapon_entity, m_flNextPrimaryAttack, EWEAPON_SHOOT_NEXTATTACKTIME, CBASEWEAPON_LINUX_XTRA_OFF)
  256. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, EWEAPON_SHOOT_NEXTIDLETIME, CBASEWEAPON_LINUX_XTRA_OFF)
  257.  
  258. free_tr2(hTrace);
  259.  
  260. return HAM_SUPERCEDE;
  261. }
  262.  
  263. public CWeapon__SetModel(entity, model[]) {
  264. if(!is_valid_ent(entity))
  265. return FMRES_IGNORED;
  266.  
  267. static szClassName[33]
  268. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  269.  
  270. // save original W_ model
  271. if (equal(szClassName, EWEAPON_BASE_WEAPON)) {
  272. copy(g_OriginalWModel, 127, model)
  273. }
  274.  
  275.  
  276. if (!equal(szClassName, "weaponbox")) {
  277. return FMRES_IGNORED;
  278. }
  279.  
  280. if (!g_OriginalWModel[0] || !equal(g_OriginalWModel, model)) {
  281. return FMRES_IGNORED;
  282. }
  283.  
  284. new entOwner = entity_get_edict(entity, EV_ENT_owner)
  285. new entStoredEWep = find_ent_by_owner(FM_NULLENT, EWEAPON_BASE_WEAPON, entity)
  286.  
  287. if(is_user_connected(entOwner) && \
  288. g_EWepPlayerData[entOwner][wep_have] == true &&
  289. is_valid_ent(entStoredEWep)) \
  290. {
  291. entity_set_int(entStoredEWep, EV_INT_WEAPONKEY, EWEAPON_WEAPONKEY)
  292.  
  293. // save ammo
  294. new bpammos = cs_get_user_bpammo(entOwner, g_EWeaponId);
  295. entity_set_int(entStoredEWep, EV_INT_weapons, bpammos);
  296. cs_set_user_bpammo(entOwner, g_EWeaponId, 0);
  297.  
  298. CWeapon__RemoveFromPlayer(entOwner)
  299.  
  300. entity_set_model(entity, EWEAPON_W_MODEL);
  301.  
  302. return FMRES_SUPERCEDE;
  303. }
  304.  
  305. return FMRES_IGNORED;
  306. }
  307.  
  308. stock CWeapon__RemoveFromPlayer(id) {
  309. g_EWepPlayerData[id][wep_have] = false;
  310. g_EWepPlayerData[id][wep_active] = false;
  311. g_EWepPlayerData[id][wep_ent] = 0;
  312. }
  313.  
  314. public CWeapon__Deploy(weapon_entity) {
  315. if (!is_valid_ent(weapon_entity))
  316. return HAM_IGNORED;
  317.  
  318. static szClassName[33]
  319. entity_get_string(weapon_entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  320.  
  321. new i, id = 0;
  322. for (i = 1; i < (MAX_PLAYERS+1); i++) {
  323. if (g_EWepPlayerData[i][wep_have] && g_EWepPlayerData[i][wep_ent] == weapon_entity)
  324. id = i;
  325. }
  326.  
  327.  
  328. if (!is_user_connected(id))
  329. return HAM_IGNORED;
  330.  
  331. if (!g_EWepPlayerData[id][wep_have])
  332. return HAM_IGNORED;
  333.  
  334. if (!equal(szClassName, EWEAPON_BASE_WEAPON)) {
  335. g_EWepPlayerData[id][wep_active] = false;
  336. return HAM_IGNORED;
  337. }
  338.  
  339. new iClip = get_pdata_int(weapon_entity, m_iClip, CBASEWEAPON_LINUX_XTRA_OFF)
  340.  
  341. set_pev(id, pev_viewmodel2, EWEAPON_V_MODEL);
  342. set_pev(id, pev_weaponmodel2, EWEAPON_P_MODEL);
  343.  
  344. g_EWepPlayerData[id][wep_active] = true;
  345.  
  346. if (iClip > 0)
  347. send_weapon_animation(id, ANIM_DRAW)
  348. else
  349. send_weapon_animation(id, ANIM_DRAW_EMPTY)
  350.  
  351. return HAM_IGNORED;
  352. }
  353.  
  354.  
  355. public CWeapon__AttachToPlayer(weapon_entity, id) {
  356. if (!is_valid_ent(weapon_entity))
  357. return HAM_IGNORED;
  358.  
  359. if (!is_user_connected(id))
  360. return HAM_IGNORED;
  361.  
  362. if (!g_EWepPlayerData[id][wep_have])
  363. return HAM_IGNORED;
  364.  
  365. if(get_pdata_int(weapon_entity, m_fKnown, CBASEWEAPON_LINUX_XTRA_OFF)) {
  366. return HAM_IGNORED;
  367. }
  368.  
  369. set_pdata_int(weapon_entity, m_iClip, EWEAPON_CLIPSIZE, CBASEWEAPON_LINUX_XTRA_OFF)
  370.  
  371. return HAM_IGNORED;
  372. }
  373.  
  374. public CWeapon__AddToPlayer(weapon_entity, id) {
  375. if (!is_valid_ent(weapon_entity))
  376. return HAM_IGNORED;
  377.  
  378. if (!is_user_connected(id))
  379. return HAM_IGNORED;
  380.  
  381. if(entity_get_int(weapon_entity, EV_INT_WEAPONKEY) == EWEAPON_WEAPONKEY && g_EWepPlayerData[id][wep_have] == false) {
  382.  
  383. entity_set_int(weapon_entity, EV_INT_WEAPONKEY, 0)
  384.  
  385. //restore ammo
  386. new bpammos = entity_get_int(weapon_entity, EV_INT_weapons);
  387. cs_set_user_bpammo(id, g_EWeaponId, bpammos);
  388.  
  389. g_EWepPlayerData[id][wep_have] = true;
  390. g_EWepPlayerData[id][wep_ent] = weapon_entity;
  391. return HAM_HANDLED;
  392. }
  393.  
  394. if (g_EWepPlayerData[id][wep_have] == true) {
  395. g_EWepPlayerData[id][wep_ent] = weapon_entity;
  396. }
  397.  
  398. return HAM_IGNORED;
  399. }
  400.  
  401. public CWeapon__ItemPostFrame(weapon_entity) {
  402. new id = pev(weapon_entity, pev_owner)
  403. if (!is_user_connected(id))
  404. return FMRES_IGNORED;
  405.  
  406. if (!g_EWepPlayerData[id][wep_have])
  407. return FMRES_IGNORED;
  408.  
  409. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack)
  410.  
  411. new iBpAmmo = cs_get_user_bpammo(id, g_EWeaponId);
  412. new iClip = get_pdata_int(weapon_entity, m_iClip)
  413.  
  414. new fInReload = get_pdata_int(weapon_entity, m_fInReload, CBASEWEAPON_LINUX_XTRA_OFF)
  415.  
  416. if (fInReload && flNextAttack <= 0.0) {
  417. new j = min(EWEAPON_CLIPSIZE - iClip, iBpAmmo)
  418.  
  419. set_pdata_int(weapon_entity, m_iClip, iClip + j, CBASEWEAPON_LINUX_XTRA_OFF)
  420. cs_set_user_bpammo(id, g_EWeaponId, iBpAmmo-j);
  421.  
  422. set_pdata_int(weapon_entity, m_fInReload, 0, CBASEWEAPON_LINUX_XTRA_OFF)
  423. fInReload = 0
  424. }
  425.  
  426. return FMRES_IGNORED;
  427. }
  428.  
  429. public CWeapon__Reload(weapon_entity) {
  430. new id = pev(weapon_entity, pev_owner)
  431. if (!is_user_connected(id))
  432. return FMRES_IGNORED;
  433.  
  434. if (!g_EWepPlayerData[id][wep_have])
  435. return FMRES_IGNORED;
  436.  
  437. g_EWepPlayerData[id][wep_TmpClip] = -1;
  438.  
  439. new iBpAmmo = cs_get_user_bpammo(id, g_EWeaponId);
  440. new iClip = get_pdata_int(weapon_entity, m_iClip, CBASEWEAPON_LINUX_XTRA_OFF)
  441.  
  442. if (iBpAmmo <= 0)
  443. return FMRES_SUPERCEDE;
  444.  
  445. if (iClip >= EWEAPON_CLIPSIZE)
  446. return FMRES_SUPERCEDE;
  447.  
  448.  
  449. g_EWepPlayerData[id][wep_TmpClip] = iClip;
  450.  
  451. set_pdata_int(weapon_entity, m_iClip, 0, CBASEWEAPON_LINUX_XTRA_OFF)
  452.  
  453. return FMRES_IGNORED;
  454. }
  455.  
  456. public CWeapon__Reload_Post(weapon_entity) {
  457. new id = pev(weapon_entity, pev_owner)
  458. if (!is_user_connected(id))
  459. return FMRES_IGNORED;
  460.  
  461. if (!g_EWepPlayerData[id][wep_have])
  462. return FMRES_IGNORED;
  463.  
  464. if (g_EWepPlayerData[id][wep_TmpClip] == -1)
  465. return FMRES_IGNORED;
  466.  
  467. set_pdata_int(weapon_entity, m_iClip, g_EWepPlayerData[id][wep_TmpClip], CBASEWEAPON_LINUX_XTRA_OFF)
  468.  
  469. set_pdata_float(weapon_entity, m_flTimeWeaponIdle, EWEAPON_RELOAD_TIME, CBASEWEAPON_LINUX_XTRA_OFF)
  470.  
  471. set_pdata_float(id, m_flNextAttack, EWEAPON_RELOAD_TIME)
  472.  
  473. set_pdata_int(weapon_entity, m_fInReload, 1)
  474.  
  475. send_weapon_animation( id, ANIM_RELOAD )
  476.  
  477. g_EWepPlayerData[id][wep_TmpClip] = -1;
  478.  
  479. return FMRES_IGNORED;
  480. }
  481.  
  482. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle) {
  483. if(!is_user_alive(Player))
  484. return FMRES_IGNORED;
  485.  
  486. if(!g_EWepPlayerData[Player][wep_active])
  487. return FMRES_IGNORED;
  488.  
  489. set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  490. return FMRES_HANDLED
  491. }
  492.  
  493. public event_curweapon(id) {
  494. if(!is_user_alive(id))
  495. return PLUGIN_CONTINUE;
  496.  
  497. if(read_data(2) == g_EWeaponId && g_EWepPlayerData[id][wep_have] == true) {
  498. } else {
  499. g_EWepPlayerData[id][wep_active] = false;
  500. }
  501. return PLUGIN_HANDLED;
  502. }
  503.  
  504. public client_connect(id) {
  505. g_EWepPlayerData[id][wep_active] = false;
  506. g_EWepPlayerData[id][wep_have] = false;
  507. }
  508.  
  509. public client_disconnect(id) {
  510. if (g_EWepPlayerData[id][wep_have] == true) {
  511. CWeapon__RemoveFromPlayer(id)
  512. }
  513. }
  514.  
  515. public message_DeathMsg(msg_id, msg_dest, id) {
  516. static szTruncatedWeapon[33], iAttacker;
  517.  
  518. get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon));
  519.  
  520. iAttacker = get_msg_arg_int(1);
  521.  
  522. if(is_user_connected(iAttacker) && g_EWepPlayerData[iAttacker][wep_have] == true && equal(szTruncatedWeapon, EWEAPON_BASE_WEAPON)) {
  523. set_msg_arg_string(4, EWEAPON_LOGNAME);
  524. }
  525.  
  526. return PLUGIN_CONTINUE;
  527. }
  528.  
  529. #if defined FIRE_WATERSPRAY
  530. stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3]) {
  531. static iVec1[3];
  532. FVecIVec(fVec1, iVec1);
  533.  
  534. static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3];
  535. pev(id, pev_v_angle, angles);
  536. engfunc(EngFunc_MakeVectors, angles);
  537. global_get(glb_v_forward, v_forward);
  538. global_get(glb_v_right, v_right);
  539. global_get(glb_v_up, v_up);
  540.  
  541. //m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
  542. pev(id, pev_origin, player_origin);
  543. pev(id, pev_view_ofs, player_view_offset);
  544. xs_vec_add(player_origin, player_view_offset, gun_position);
  545.  
  546. xs_vec_mul_scalar(v_forward, 24.0, v_forward);
  547. xs_vec_mul_scalar(v_right, 3.0, v_right);
  548.  
  549. if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
  550. xs_vec_mul_scalar(v_up, 6.0, v_up);
  551. else
  552. xs_vec_mul_scalar(v_up, -2.0, v_up);
  553.  
  554. xs_vec_add(gun_position, v_forward, origin);
  555. xs_vec_add(origin, v_right, origin);
  556. xs_vec_add(origin, v_up, origin);
  557.  
  558. vSrc[0] = origin[0];
  559. vSrc[1] = origin[1];
  560. vSrc[2] = origin[2];
  561.  
  562.  
  563. new Float:dist = get_distance_f(vSrc, fVec2);
  564. new CountDrops = floatround(dist / 50.0);
  565.  
  566. if (CountDrops > 20)
  567. CountDrops = 20;
  568.  
  569. if (CountDrops < 2)
  570. CountDrops = 2;
  571.  
  572. message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1);
  573. write_byte(TE_SPRITETRAIL);
  574. engfunc(EngFunc_WriteCoord, vSrc[0]);
  575. engfunc(EngFunc_WriteCoord, vSrc[1]);
  576. engfunc(EngFunc_WriteCoord, vSrc[2]);
  577. engfunc(EngFunc_WriteCoord, fVec2[0]);
  578. engfunc(EngFunc_WriteCoord, fVec2[1]);
  579. engfunc(EngFunc_WriteCoord, fVec2[2]);
  580. write_short(tracer_sprite2);
  581. write_byte(CountDrops); //count
  582. write_byte(0); //life
  583. write_byte(1); //scale
  584. write_byte(60); //velocity
  585. write_byte(10); //rand_velocity
  586. message_end();
  587.  
  588.  
  589. message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1);
  590. write_byte(TE_BEAMPOINTS);
  591. engfunc(EngFunc_WriteCoord, fVec2[0]);
  592. engfunc(EngFunc_WriteCoord, fVec2[1]);
  593. engfunc(EngFunc_WriteCoord, fVec2[2]);
  594. engfunc(EngFunc_WriteCoord, vSrc[0]);
  595. engfunc(EngFunc_WriteCoord, vSrc[1]);
  596. engfunc(EngFunc_WriteCoord, vSrc[2]);
  597. write_short(tracer_sprite);
  598. write_byte(6); //starting_frame
  599. write_byte(200); //framerate
  600. write_byte(1); //life
  601. write_byte(100); //line width
  602. write_byte(0); //noise ampl
  603. write_byte(64); write_byte(64); write_byte(192); //color
  604. write_byte(192); //brightness
  605. write_byte(250); //scroll speed
  606. message_end();
  607. }
  608. #endif //FIRE_WATERSPRAY
  609.  
  610. stock send_weapon_animation(id, iAnim) {
  611. set_pev(id, pev_weaponanim, iAnim);
  612. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id);
  613. write_byte(iAnim);
  614. write_byte(pev(id,pev_body));
  615. message_end();
  616. }
  617.  
  618. stock create_shot(Float:fOrigin[3], entity = 0) {
  619. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  620. write_byte(TE_GUNSHOTDECAL);
  621. engfunc(EngFunc_WriteCoord, fOrigin[0]);
  622. engfunc(EngFunc_WriteCoord, fOrigin[1]);
  623. engfunc(EngFunc_WriteCoord, fOrigin[2]);
  624. if(!pev_valid(entity)) {
  625. write_short(0);
  626. } else {
  627. write_short(entity);
  628. }
  629. write_byte(DecalsShot[random_num(0,4)]);
  630. message_end();
  631. }
  632.  
  633. stock make_blood(const Float:vTraceEnd[3], Float:Damage, hitEnt) {
  634. new bloodColor = ExecuteHam(Ham_BloodColor, hitEnt);
  635. if (bloodColor == -1)
  636. return;
  637.  
  638. new amount = floatround(Damage);
  639.  
  640. amount *= 2; //according to HLSDK
  641.  
  642. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  643. write_byte(TE_BLOODSPRITE);
  644. write_coord(floatround(vTraceEnd[0]));
  645. write_coord(floatround(vTraceEnd[1]));
  646. write_coord(floatround(vTraceEnd[2]));
  647. write_short(g_BloodSprite[1]);
  648. write_short(g_BloodSprite[0]);
  649. write_byte(bloodColor);
  650. write_byte(min(max(3, amount/10), 16));
  651. message_end();
  652. }
  653.  
  654. public zv_extra_item_selected(id, itemid) {
  655. if(itemid == g_itemid_guitar) {
  656. if (user_has_weapon(id, g_EWeaponId))
  657. engclient_cmd(id, "drop", EWEAPON_BASE_WEAPON);
  658.  
  659. g_EWepPlayerData[id][wep_have] = true;
  660. give_item(id, EWEAPON_BASE_WEAPON);
  661.  
  662. cs_set_user_bpammo (id, g_EWeaponId, EWEAPON_START_AMMO);
  663. }
  664. }
  665.  
  666. public zp_user_infected_post(id) {
  667. if (g_EWepPlayerData[id][wep_have] == true) {
  668. CWeapon__RemoveFromPlayer(id)
  669. }
  670. }
  671.  
  672. public zp_user_humanized_post(id, survivor) {
  673. if (survivor && g_EWepPlayerData[id][wep_have] == true) {
  674. CWeapon__RemoveFromPlayer(id)
  675. }
  676. }


Csatolmányok:
zmvip.inc [2.19 KiB]
Letöltve 44 alkalommal.
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  [ 4 hozzászólás ] 


Ki van itt

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