hlmod.hu

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



Jelenlévő felhasználók

Jelenleg 293 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 292 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  [ 2 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: [ZP] Extra: Shotgun
HozzászólásElküldve: 2013.06.05. 20:45 
Offline
Minden6ó
Avatar

Csatlakozott: 2011.01.19. 12:14
Hozzászólások: 4280
Megköszönt másnak: 218 alkalommal
Megköszönték neki: 285 alkalommal
Hali! Valaki lefordítani?
SMA Forráskód: [ Mindet kijelol ]
  1. /*================================================================================
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. [ZP] Extra Item: Sawn-Off Shotgun
  10.  
  11.  
  12.  
  13. Copyright (C) 2009 by meTaLiCroSS
  14.  
  15.  
  16.  
  17. Request maded by Clear
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. This program is free software: you can redistribute it and/or modify
  26.  
  27.  
  28.  
  29. it under the terms of the GNU General Public License as published by
  30.  
  31.  
  32.  
  33. the Free Software Foundation, either version 3 of the License, or
  34.  
  35.  
  36.  
  37. (at your option) any later version.
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. This program is distributed in the hope that it will be useful,
  46.  
  47.  
  48.  
  49. but WITHOUT ANY WARRANTY; without even the implied warranty of
  50.  
  51.  
  52.  
  53. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  54.  
  55.  
  56.  
  57. GNU General Public License for more details.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. You should have received a copy of the GNU General Public License
  66.  
  67.  
  68.  
  69. along with this program. If not, see <http://www.gnu.org/licenses/>.
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. In addition, as a special exception, the author gives permission to
  78.  
  79.  
  80.  
  81. link the code of this program with the Half-Life Game Engine ("HL
  82.  
  83.  
  84.  
  85. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  86.  
  87.  
  88.  
  89. L.L.C ("Valve"). You must obey the GNU General Public License in all
  90.  
  91.  
  92.  
  93. respects for all of the code used other than the HL Engine and MODs
  94.  
  95.  
  96.  
  97. from Valve. If you modify this file, you may extend this exception
  98.  
  99.  
  100.  
  101. to your version of the file, but you are not obligated to do so. If
  102.  
  103.  
  104.  
  105. you do not wish to do so, delete this exception statement from your
  106.  
  107.  
  108.  
  109. version.
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. =================================================================================*/
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. #include <amxmodx>
  126.  
  127.  
  128.  
  129. #include <fakemeta>
  130.  
  131.  
  132.  
  133. #include <engine>
  134.  
  135.  
  136.  
  137. #include <hamsandwich>
  138.  
  139.  
  140.  
  141. #include <xs>
  142.  
  143.  
  144.  
  145. #include <zombieplague>
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. /*================================================================================
  154.  
  155.  
  156.  
  157.  [Customization]
  158.  
  159.  
  160.  
  161. =================================================================================*/
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. // Item Cost
  170.  
  171.  
  172.  
  173. new const g_SawnOff_Cost = 30
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181. // Models
  182.  
  183.  
  184.  
  185. new const sawnoff_model_v[] = "models/v_sawn_off_shotgun.mdl"
  186.  
  187.  
  188.  
  189. new const sawnoff_model_p[] = "models/p_sawn_off_shotgun.mdl"
  190.  
  191.  
  192.  
  193. new const sawnoff_model_w[] = "models/w_sawn_off_shotgun.mdl"
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. // ---------------------------------------------------------------
  202.  
  203.  
  204.  
  205. // ------------------ Customization ends here!! ------------------
  206.  
  207.  
  208.  
  209. // ---------------------------------------------------------------
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. // Offsets
  218.  
  219.  
  220.  
  221. #if cellbits == 32
  222.  
  223.  
  224.  
  225. const OFFSET_CLIPAMMO = 51
  226.  
  227.  
  228.  
  229. #else
  230.  
  231.  
  232.  
  233. const OFFSET_CLIPAMMO = 65
  234.  
  235.  
  236.  
  237. #endif
  238.  
  239.  
  240.  
  241. const OFFSET_LINUX = 5
  242.  
  243.  
  244.  
  245. const OFFSET_LINUX_WEAPONS = 4
  246.  
  247.  
  248.  
  249. const OFFSET_LASTPRIMARYITEM = 368
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257. // Version
  258.  
  259.  
  260.  
  261. #define VERSION "0.4.5"
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269. // Arrays
  270.  
  271.  
  272.  
  273. new g_sawnoff_shotgun[33], g_currentweapon[33]
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281. // Variables
  282.  
  283.  
  284.  
  285. new g_SawnOff, g_MaxPlayers
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293. // Cvar Pointers
  294.  
  295.  
  296.  
  297. new cvar_enable, cvar_oneround, cvar_knockback, cvar_knockbackpower, cvar_uclip, cvar_damage
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. /*================================================================================
  306.  
  307.  
  308.  
  309.  [Init and Precache]
  310.  
  311.  
  312.  
  313. =================================================================================*/
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321. public plugin_init()
  322.  
  323.  
  324.  
  325. {
  326.  
  327.  
  328.  
  329. // Plugin Info
  330.  
  331.  
  332.  
  333. register_plugin("[ZP] Extra Item: Sawn-Off Shotgun", VERSION, "meTaLiCroSS")
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341. // Ham Forwards
  342.  
  343.  
  344.  
  345. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  346.  
  347.  
  348.  
  349. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  350.  
  351.  
  352.  
  353. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361. // Fakemeta Forwards
  362.  
  363.  
  364.  
  365. register_forward(FM_SetModel, "fw_SetModel")
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373. // Event: Round Start
  374.  
  375.  
  376.  
  377. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385. // Message: Cur Weapon
  386.  
  387.  
  388.  
  389. register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397. // CVARS
  398.  
  399.  
  400.  
  401. register_cvar("zp_extra_sawnoff", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  402.  
  403.  
  404.  
  405. cvar_enable = register_cvar("zp_sawnoff_enable", "1")
  406.  
  407.  
  408.  
  409. cvar_uclip = register_cvar("zp_sawnoff_unlimited_clip", "1")
  410.  
  411.  
  412.  
  413. cvar_damage = register_cvar("zp_sawnoff_damage_mult", "4.0")
  414.  
  415.  
  416.  
  417. cvar_oneround = register_cvar("zp_sawnoff_oneround", "0")
  418.  
  419.  
  420.  
  421. cvar_knockback = register_cvar("zp_sawnoff_knockback", "1")
  422.  
  423.  
  424.  
  425. cvar_knockbackpower = register_cvar("zp_sawnoff_kbackpower", "10.0")
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433. // Variables
  434.  
  435.  
  436.  
  437. g_MaxPlayers = get_maxplayers()
  438.  
  439.  
  440.  
  441. g_SawnOff = zp_register_extra_item("Sawn-Off Shotgun", g_SawnOff_Cost, ZP_TEAM_HUMAN)
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449. }
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. public plugin_precache()
  458.  
  459.  
  460.  
  461. {
  462.  
  463.  
  464.  
  465. // Precaching models
  466.  
  467.  
  468.  
  469. precache_model(sawnoff_model_v)
  470.  
  471.  
  472.  
  473. precache_model(sawnoff_model_p)
  474.  
  475.  
  476.  
  477. precache_model(sawnoff_model_w)
  478.  
  479.  
  480.  
  481. }
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489. /*================================================================================
  490.  
  491.  
  492.  
  493.  [Main Functions]
  494.  
  495.  
  496.  
  497. =================================================================================*/
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. // Round Start Event
  506.  
  507.  
  508.  
  509. public event_round_start()
  510.  
  511.  
  512.  
  513. {
  514.  
  515.  
  516.  
  517. // Get all the players
  518.  
  519.  
  520.  
  521. for(new id = 1; id <= g_MaxPlayers; id++)
  522.  
  523.  
  524.  
  525. {
  526.  
  527.  
  528.  
  529. // Check
  530.  
  531.  
  532.  
  533. if(get_pcvar_num(cvar_oneround) || !get_pcvar_num(cvar_enable))
  534.  
  535.  
  536.  
  537. {
  538.  
  539.  
  540.  
  541. // Striping Sawn Off
  542.  
  543.  
  544.  
  545. if(g_sawnoff_shotgun[id])
  546.  
  547.  
  548.  
  549. {
  550.  
  551.  
  552.  
  553. g_sawnoff_shotgun[id] = false;
  554.  
  555.  
  556.  
  557. ham_strip_weapon(id, "weapon_m3")
  558.  
  559.  
  560.  
  561. }
  562.  
  563.  
  564.  
  565. }
  566.  
  567.  
  568.  
  569. }
  570.  
  571.  
  572.  
  573. }
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581. // Message Current Weapon
  582.  
  583.  
  584.  
  585. public message_cur_weapon(msg_id, msg_dest, id)
  586.  
  587.  
  588.  
  589. {
  590.  
  591.  
  592.  
  593. // Doesn't have a Sawn Off
  594.  
  595.  
  596.  
  597. if (!g_sawnoff_shotgun[id])
  598.  
  599.  
  600.  
  601. return PLUGIN_CONTINUE
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609. // Isn't alive / not active weapon
  610.  
  611.  
  612.  
  613. if (!is_user_alive(id) || get_msg_arg_int(1) != 1)
  614.  
  615.  
  616.  
  617. return PLUGIN_CONTINUE
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625. // Get Weapon Clip
  626.  
  627.  
  628.  
  629. new clip = get_msg_arg_int(3)
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637. // Update Weapon Array
  638.  
  639.  
  640.  
  641. g_currentweapon[id] = get_msg_arg_int(2) // get weapon ID
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649. // Weapon isn't M3
  650.  
  651.  
  652.  
  653. if(g_currentweapon[id] != CSW_M3)
  654.  
  655.  
  656.  
  657. return PLUGIN_CONTINUE;
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. // Replace Models
  666.  
  667.  
  668.  
  669. entity_set_string(id, EV_SZ_viewmodel, sawnoff_model_v)
  670.  
  671.  
  672.  
  673. entity_set_string(id, EV_SZ_weaponmodel, sawnoff_model_p)
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681. // Check cvar
  682.  
  683.  
  684.  
  685. if(get_pcvar_num(cvar_uclip))
  686.  
  687.  
  688.  
  689. {
  690.  
  691.  
  692.  
  693. // Set Ammo HUD in 8
  694.  
  695.  
  696.  
  697. set_msg_arg_int(3, get_msg_argtype(3), 8)
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705. // Check clip if more than 2
  706.  
  707.  
  708.  
  709. if (clip < 2)
  710.  
  711.  
  712.  
  713. {
  714.  
  715.  
  716.  
  717. // Update weapon ammo
  718.  
  719.  
  720.  
  721. fm_set_weapon_ammo(find_ent_by_owner(-1, "weapon_m3", id), 8)
  722.  
  723.  
  724.  
  725. }
  726.  
  727.  
  728.  
  729. }
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737. return PLUGIN_CONTINUE;
  738.  
  739.  
  740.  
  741. }
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749. // Touch fix (when user drop the Sawn off, already has the Sawn off.
  750.  
  751.  
  752.  
  753. public touch_fix(id)
  754.  
  755.  
  756.  
  757. {
  758.  
  759.  
  760.  
  761. if(g_sawnoff_shotgun[id])
  762.  
  763.  
  764.  
  765. g_sawnoff_shotgun[id] = false;
  766.  
  767.  
  768.  
  769. }
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777. /*================================================================================
  778.  
  779.  
  780.  
  781.  [Main Forwards]
  782.  
  783.  
  784.  
  785. =================================================================================*/
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793. public fw_PlayerKilled(victim, attacker, shouldgib)
  794.  
  795.  
  796.  
  797. {
  798.  
  799.  
  800.  
  801. // Victim has a Sawn off
  802.  
  803.  
  804.  
  805. if(g_sawnoff_shotgun[victim])
  806.  
  807.  
  808.  
  809. g_sawnoff_shotgun[victim] = false;
  810.  
  811.  
  812.  
  813. }
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821. public fw_SetModel(entity, model[])
  822.  
  823.  
  824.  
  825. {
  826.  
  827.  
  828.  
  829. // Entity is not valid
  830.  
  831.  
  832.  
  833. if(!is_valid_ent(entity))
  834.  
  835.  
  836.  
  837. return FMRES_IGNORED;
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845. // Entity model is not a M3
  846.  
  847.  
  848.  
  849. if(!equali(model, "models/w_m3.mdl"))
  850.  
  851.  
  852.  
  853. return FMRES_IGNORED;
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861. // Get owner and entity classname
  862.  
  863.  
  864.  
  865. new owner = entity_get_edict(entity, EV_ENT_owner)
  866.  
  867.  
  868.  
  869. new classname[33]
  870.  
  871.  
  872.  
  873. entity_get_string(entity, EV_SZ_classname, classname, charsmax(classname))
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881. // Entity classname is a weaponbox
  882.  
  883.  
  884.  
  885. if(equal(classname, "weaponbox"))
  886.  
  887.  
  888.  
  889. {
  890.  
  891.  
  892.  
  893. // The weapon owner has a Sawn Off
  894.  
  895.  
  896.  
  897. if(g_sawnoff_shotgun[owner])
  898.  
  899.  
  900.  
  901. {
  902.  
  903.  
  904.  
  905. // Striping Sawn off and set New Model
  906.  
  907.  
  908.  
  909. g_sawnoff_shotgun[owner] = false;
  910.  
  911.  
  912.  
  913. entity_set_model(entity, sawnoff_model_w)
  914.  
  915.  
  916.  
  917. set_task(0.1, "touch_fix", owner)
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925. return FMRES_SUPERCEDE
  926.  
  927.  
  928.  
  929. }
  930.  
  931.  
  932.  
  933. }
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941. return FMRES_IGNORED
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949. }
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  958.  
  959.  
  960.  
  961. {
  962.  
  963.  
  964.  
  965. // Attacker isn't a Player (1 in 32)
  966.  
  967.  
  968.  
  969. if(!(1 <= attacker <= g_MaxPlayers))
  970.  
  971.  
  972.  
  973. return HAM_IGNORED;
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981. // Attacker's weapon isn't a M3
  982.  
  983.  
  984.  
  985. if(g_currentweapon[attacker] != CSW_M3)
  986.  
  987.  
  988.  
  989. return HAM_IGNORED;
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997. // User doesn't have a Sawn Off
  998.  
  999.  
  1000.  
  1001. if(!g_sawnoff_shotgun[attacker])
  1002.  
  1003.  
  1004.  
  1005. return HAM_IGNORED;
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013. SetHamParamFloat(4, damage * get_pcvar_float(cvar_damage) )
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021. return HAM_IGNORED;
  1022.  
  1023.  
  1024.  
  1025. }
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033. public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
  1034.  
  1035.  
  1036.  
  1037. {
  1038.  
  1039.  
  1040.  
  1041. // Player is allowed to make a Knockback
  1042.  
  1043.  
  1044.  
  1045. if(!allowed_knockback(victim, attacker))
  1046.  
  1047.  
  1048.  
  1049. return HAM_IGNORED;
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057. // Check damage type
  1058.  
  1059.  
  1060.  
  1061. if(!(damage_type & DMG_BULLET))
  1062.  
  1063.  
  1064.  
  1065. return HAM_IGNORED;
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073. // Make Knockback...
  1074.  
  1075.  
  1076.  
  1077. new Float:velocity[3]; pev(victim, pev_velocity, velocity)
  1078.  
  1079.  
  1080.  
  1081. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_knockbackpower), direction)
  1082.  
  1083.  
  1084.  
  1085. xs_vec_add(velocity, direction, direction)
  1086.  
  1087.  
  1088.  
  1089. entity_set_vector(victim, EV_VEC_velocity, direction)
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097. return HAM_IGNORED;
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105. }
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113. public pfn_touch(entity, toucher)
  1114.  
  1115.  
  1116.  
  1117. {
  1118.  
  1119.  
  1120.  
  1121. new model[33], toucherclass[33], entityclass[33]
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129. // Get toucher Classname
  1130.  
  1131.  
  1132.  
  1133. if((toucher > 0) && is_valid_ent(toucher)) entity_get_string(toucher, EV_SZ_classname, toucherclass, charsmax(toucherclass))
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141. // Get entity Classname
  1142.  
  1143.  
  1144.  
  1145. if((entity > 0) && is_valid_ent(entity)) entity_get_string(entity, EV_SZ_classname, entityclass, charsmax(entityclass))
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153. // Now check if is a Weapon and is a Player
  1154.  
  1155.  
  1156.  
  1157. if(equali(toucherclass, "player") && equali(entityclass, "weaponbox"))
  1158.  
  1159.  
  1160.  
  1161. {
  1162.  
  1163.  
  1164.  
  1165. // Get Model
  1166.  
  1167.  
  1168.  
  1169. entity_get_string(entity, EV_SZ_model, model, charsmax(model))
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177. // Check Model
  1178.  
  1179.  
  1180.  
  1181. if(equali(model, sawnoff_model_w))
  1182.  
  1183.  
  1184.  
  1185. if(allowed_touch(toucher)) // Player is allowed to pickup the weapon
  1186.  
  1187.  
  1188.  
  1189. g_sawnoff_shotgun[toucher] = true // Set Weapon
  1190.  
  1191.  
  1192.  
  1193. }
  1194.  
  1195.  
  1196.  
  1197. }
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205. /*================================================================================
  1206.  
  1207.  
  1208.  
  1209.  [Internal Functions]
  1210.  
  1211.  
  1212.  
  1213. =================================================================================*/
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221. allowed_knockback(victim, attacker)
  1222.  
  1223.  
  1224.  
  1225. {
  1226.  
  1227.  
  1228.  
  1229. // Obviously, doesn't is allowed to be Knockbacked (WTF)
  1230.  
  1231.  
  1232.  
  1233. if(!g_sawnoff_shotgun[attacker] || !get_pcvar_num(cvar_knockback) || g_currentweapon[attacker] != CSW_M3 || !zp_get_user_zombie(victim))
  1234.  
  1235.  
  1236.  
  1237. return false;
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245. return true;
  1246.  
  1247.  
  1248.  
  1249. }
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257. allowed_touch(toucher)
  1258.  
  1259.  
  1260.  
  1261. {
  1262.  
  1263.  
  1264.  
  1265. // Can't touch the Weapon
  1266.  
  1267.  
  1268.  
  1269. if(zp_get_user_survivor(toucher) || zp_get_user_zombie(toucher) || fm_get_user_lastprimaryitem(toucher) || g_sawnoff_shotgun[toucher])
  1270.  
  1271.  
  1272.  
  1273. return false;
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281. return true;
  1282.  
  1283.  
  1284.  
  1285. }
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293. /*================================================================================
  1294.  
  1295.  
  1296.  
  1297.  [Zombie Plague Forwards]
  1298.  
  1299.  
  1300.  
  1301. =================================================================================*/
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309. public zp_extra_item_selected(id, itemid)
  1310.  
  1311.  
  1312.  
  1313. {
  1314.  
  1315.  
  1316.  
  1317. // Item is the Sawn-Off
  1318.  
  1319.  
  1320.  
  1321. if(itemid == g_SawnOff)
  1322.  
  1323.  
  1324.  
  1325. {
  1326.  
  1327.  
  1328.  
  1329. if(!get_pcvar_num(cvar_enable))
  1330.  
  1331.  
  1332.  
  1333. {
  1334.  
  1335.  
  1336.  
  1337. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + g_SawnOff_Cost)
  1338.  
  1339.  
  1340.  
  1341. client_print(id, print_chat, "[ZP] The Sawn-Off Shotgun is Disabled")
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349. return;
  1350.  
  1351.  
  1352.  
  1353. }
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361. // Already has an M3
  1362.  
  1363.  
  1364.  
  1365. if(g_sawnoff_shotgun[id] && user_has_weapon(id, CSW_M3))
  1366.  
  1367.  
  1368.  
  1369. {
  1370.  
  1371.  
  1372.  
  1373. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + g_SawnOff_Cost)
  1374.  
  1375.  
  1376.  
  1377. client_print(id, print_chat, "[ZP] You already have a Sawn-Off Shotgun")
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385. return;
  1386.  
  1387.  
  1388.  
  1389. }
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. // Array
  1398.  
  1399.  
  1400.  
  1401. g_sawnoff_shotgun[id] = true
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409. // Weapon
  1410.  
  1411.  
  1412.  
  1413. ham_give_weapon(id, "weapon_m3")
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421. // Message
  1422.  
  1423.  
  1424.  
  1425. client_print(id, print_chat, "[ZP] You now have a Sawn-Off Shotgun")
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433. }
  1434.  
  1435.  
  1436.  
  1437. }
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445. public zp_user_infected_post(infected, infector)
  1446.  
  1447.  
  1448.  
  1449. {
  1450.  
  1451.  
  1452.  
  1453. // Infected has a M3
  1454.  
  1455.  
  1456.  
  1457. if(g_sawnoff_shotgun[infected])
  1458.  
  1459.  
  1460.  
  1461. g_sawnoff_shotgun[infected] = false;
  1462.  
  1463.  
  1464.  
  1465. }
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473. public zp_user_humanized_post(player)
  1474.  
  1475.  
  1476.  
  1477. {
  1478.  
  1479.  
  1480.  
  1481. // Is Survivor
  1482.  
  1483.  
  1484.  
  1485. if(zp_get_user_survivor(player) && g_sawnoff_shotgun[player])
  1486.  
  1487.  
  1488.  
  1489. g_sawnoff_shotgun[player] = false;
  1490.  
  1491.  
  1492.  
  1493. }
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501. /*================================================================================
  1502.  
  1503.  
  1504.  
  1505.  [Stocks]
  1506.  
  1507.  
  1508.  
  1509. =================================================================================*/
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517. stock ham_give_weapon(id, weapon[])
  1518.  
  1519.  
  1520.  
  1521. {
  1522.  
  1523.  
  1524.  
  1525. if(!equal(weapon,"weapon_",7))
  1526.  
  1527.  
  1528.  
  1529. return 0
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537. new wEnt = create_entity(weapon)
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545. if(!is_valid_ent(wEnt))
  1546.  
  1547.  
  1548.  
  1549. return 0
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557. entity_set_int(wEnt, EV_INT_spawnflags, SF_NORESPAWN)
  1558.  
  1559.  
  1560.  
  1561. DispatchSpawn(wEnt)
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569. if(!ExecuteHamB(Ham_AddPlayerItem,id,wEnt))
  1570.  
  1571.  
  1572.  
  1573. {
  1574.  
  1575.  
  1576.  
  1577. if(is_valid_ent(wEnt)) entity_set_int(wEnt, EV_INT_flags, entity_get_int(wEnt, EV_INT_flags) | FL_KILLME)
  1578.  
  1579.  
  1580.  
  1581. return 0
  1582.  
  1583.  
  1584.  
  1585. }
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593. ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)
  1594.  
  1595.  
  1596.  
  1597. return 1
  1598.  
  1599.  
  1600.  
  1601. }
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609. stock ham_strip_weapon(id, weapon[])
  1610.  
  1611.  
  1612.  
  1613. {
  1614.  
  1615.  
  1616.  
  1617. if(!equal(weapon,"weapon_",7))
  1618.  
  1619.  
  1620.  
  1621. return 0
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629. new wId = get_weaponid(weapon)
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637. if(!wId) return 0
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645. new wEnt
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653. while((wEnt = find_ent_by_class(wEnt, weapon)) && entity_get_edict(wEnt, EV_ENT_owner) != id) {}
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661. if(!wEnt) return 0
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669. if(get_user_weapon(id) == wId)
  1670.  
  1671.  
  1672.  
  1673. ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681. if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt))
  1682.  
  1683.  
  1684.  
  1685. return 0
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693. ExecuteHamB(Ham_Item_Kill, wEnt)
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701. entity_set_int(id, EV_INT_weapons, entity_get_int(id, EV_INT_weapons) & ~(1<<wId))
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709. return 1
  1710.  
  1711.  
  1712.  
  1713. }
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721. stock fm_set_weapon_ammo(entity, amount)
  1722.  
  1723.  
  1724.  
  1725. {
  1726.  
  1727.  
  1728.  
  1729. set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
  1730.  
  1731.  
  1732.  
  1733. }
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741. stock fm_get_user_lastprimaryitem(id) // Thanks to joaquimandrade
  1742.  
  1743.  
  1744.  
  1745. {
  1746.  
  1747.  
  1748.  
  1749. if(get_pdata_cbase(id, OFFSET_LASTPRIMARYITEM) != -1)
  1750.  
  1751.  
  1752.  
  1753. return 1;
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761. return 0;
  1762.  
  1763.  
  1764.  
  1765. }
  1766.  
  1767.  
  1768.  
  1769.  

_________________
<<eb@>>Team Website - Közösség
17Buddies - Általam készített pályák.
GameBanana - Általam készített pályák/vágott hangok.

Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: [ZP] Extra: Shotgun
HozzászólásElküldve: 2013.06.05. 20:52 
Offline
Veterán

Csatlakozott: 2012.11.01. 20:49
Hozzászólások: 1837
Megköszönt másnak: 25 alkalommal
Megköszönték neki: 78 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. /*================================================================================
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. [ZP] Extra Item: Sawn-Off Shotgun
  10.  
  11.  
  12.  
  13. Copyright (C) 2009 by meTaLiCroSS
  14.  
  15.  
  16.  
  17. Request maded by Clear
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. This program is free software: you can redistribute it and/or modify
  26.  
  27.  
  28.  
  29. it under the terms of the GNU General Public License as published by
  30.  
  31.  
  32.  
  33. the Free Software Foundation, either version 3 of the License, or
  34.  
  35.  
  36.  
  37. (at your option) any later version.
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. This program is distributed in the hope that it will be useful,
  46.  
  47.  
  48.  
  49. but WITHOUT ANY WARRANTY; without even the implied warranty of
  50.  
  51.  
  52.  
  53. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  54.  
  55.  
  56.  
  57. GNU General Public License for more details.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. You should have received a copy of the GNU General Public License
  66.  
  67.  
  68.  
  69. along with this program. If not, see <http://www.gnu.org/licenses/>.
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. In addition, as a special exception, the author gives permission to
  78.  
  79.  
  80.  
  81. link the code of this program with the Half-Life Game Engine ("HL
  82.  
  83.  
  84.  
  85. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  86.  
  87.  
  88.  
  89. L.L.C ("Valve"). You must obey the GNU General Public License in all
  90.  
  91.  
  92.  
  93. respects for all of the code used other than the HL Engine and MODs
  94.  
  95.  
  96.  
  97. from Valve. If you modify this file, you may extend this exception
  98.  
  99.  
  100.  
  101. to your version of the file, but you are not obligated to do so. If
  102.  
  103.  
  104.  
  105. you do not wish to do so, delete this exception statement from your
  106.  
  107.  
  108.  
  109. version.
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. =================================================================================*/
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. #include <amxmodx>
  126.  
  127.  
  128.  
  129. #include <fakemeta>
  130.  
  131.  
  132.  
  133. #include <engine>
  134.  
  135.  
  136.  
  137. #include <hamsandwich>
  138.  
  139.  
  140.  
  141. #include <xs>
  142.  
  143.  
  144.  
  145. #include <zombieplague>
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. /*================================================================================
  154.  
  155.  
  156.  
  157.  [Customization]
  158.  
  159.  
  160.  
  161. =================================================================================*/
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. // Item Cost
  170.  
  171.  
  172.  
  173. new const g_SawnOff_Cost = 30
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181. // Models
  182.  
  183.  
  184.  
  185. new const sawnoff_model_v[] = "models/v_sawn_off_shotgun.mdl"
  186.  
  187.  
  188.  
  189. new const sawnoff_model_p[] = "models/p_sawn_off_shotgun.mdl"
  190.  
  191.  
  192.  
  193. new const sawnoff_model_w[] = "models/w_sawn_off_shotgun.mdl"
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. // ---------------------------------------------------------------
  202.  
  203.  
  204.  
  205. // ------------------ Customization ends here!! ------------------
  206.  
  207.  
  208.  
  209. // ---------------------------------------------------------------
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. // Offsets
  218.  
  219.  
  220.  
  221. #if cellbits == 32
  222.  
  223.  
  224.  
  225. const OFFSET_CLIPAMMO = 51
  226.  
  227.  
  228.  
  229. #else
  230.  
  231.  
  232.  
  233. const OFFSET_CLIPAMMO = 65
  234.  
  235.  
  236.  
  237. #endif
  238.  
  239.  
  240.  
  241. const OFFSET_LINUX = 5
  242.  
  243.  
  244.  
  245. const OFFSET_LINUX_WEAPONS = 4
  246.  
  247.  
  248.  
  249. const OFFSET_LASTPRIMARYITEM = 368
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257. // Version
  258.  
  259.  
  260.  
  261. #define VERSION "0.4.5"
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269. // Arrays
  270.  
  271.  
  272.  
  273. new g_sawnoff_shotgun[33], g_currentweapon[33]
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281. // Variables
  282.  
  283.  
  284.  
  285. new g_SawnOff, g_MaxPlayers
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293. // Cvar Pointers
  294.  
  295.  
  296.  
  297. new cvar_enable, cvar_oneround, cvar_knockback, cvar_knockbackpower, cvar_uclip, cvar_damage
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. /*================================================================================
  306.  
  307.  
  308.  
  309.  [Init and Precache]
  310.  
  311.  
  312.  
  313. =================================================================================*/
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321. public plugin_init()
  322.  
  323.  
  324.  
  325. {
  326.  
  327.  
  328.  
  329. // Plugin Info
  330.  
  331.  
  332.  
  333. register_plugin("[ZP] Extra Item: Sawn-Off Shotgun", VERSION, "meTaLiCroSS")
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341. // Ham Forwards
  342.  
  343.  
  344.  
  345. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  346.  
  347.  
  348.  
  349. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  350.  
  351.  
  352.  
  353. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361. // Fakemeta Forwards
  362.  
  363.  
  364.  
  365. register_forward(FM_SetModel, "fw_SetModel")
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373. // Event: Round Start
  374.  
  375.  
  376.  
  377. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385. // Message: Cur Weapon
  386.  
  387.  
  388.  
  389. register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397. // CVARS
  398.  
  399.  
  400.  
  401. register_cvar("zp_extra_sawnoff", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  402.  
  403.  
  404.  
  405. cvar_enable = register_cvar("zp_sawnoff_enable", "1")
  406.  
  407.  
  408.  
  409. cvar_uclip = register_cvar("zp_sawnoff_unlimited_clip", "1")
  410.  
  411.  
  412.  
  413. cvar_damage = register_cvar("zp_sawnoff_damage_mult", "4.0")
  414.  
  415.  
  416.  
  417. cvar_oneround = register_cvar("zp_sawnoff_oneround", "0")
  418.  
  419.  
  420.  
  421. cvar_knockback = register_cvar("zp_sawnoff_knockback", "1")
  422.  
  423.  
  424.  
  425. cvar_knockbackpower = register_cvar("zp_sawnoff_kbackpower", "10.0")
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433. // Variables
  434.  
  435.  
  436.  
  437. g_MaxPlayers = get_maxplayers()
  438.  
  439.  
  440.  
  441. g_SawnOff = zp_register_extra_item("Sawn-Off Shotgun", g_SawnOff_Cost, ZP_TEAM_HUMAN)
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449. }
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. public plugin_precache()
  458.  
  459.  
  460.  
  461. {
  462.  
  463.  
  464.  
  465. // Precaching models
  466.  
  467.  
  468.  
  469. precache_model(sawnoff_model_v)
  470.  
  471.  
  472.  
  473. precache_model(sawnoff_model_p)
  474.  
  475.  
  476.  
  477. precache_model(sawnoff_model_w)
  478.  
  479.  
  480.  
  481. }
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489. /*================================================================================
  490.  
  491.  
  492.  
  493.  [Main Functions]
  494.  
  495.  
  496.  
  497. =================================================================================*/
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. // Round Start Event
  506.  
  507.  
  508.  
  509. public event_round_start()
  510.  
  511.  
  512.  
  513. {
  514.  
  515.  
  516.  
  517. // Get all the players
  518.  
  519.  
  520.  
  521. for(new id = 1; id <= g_MaxPlayers; id++)
  522.  
  523.  
  524.  
  525. {
  526.  
  527.  
  528.  
  529. // Check
  530.  
  531.  
  532.  
  533. if(get_pcvar_num(cvar_oneround) || !get_pcvar_num(cvar_enable))
  534.  
  535.  
  536.  
  537. {
  538.  
  539.  
  540.  
  541. // Striping Sawn Off
  542.  
  543.  
  544.  
  545. if(g_sawnoff_shotgun[id])
  546.  
  547.  
  548.  
  549. {
  550.  
  551.  
  552.  
  553. g_sawnoff_shotgun[id] = false;
  554.  
  555.  
  556.  
  557. ham_strip_weapon(id, "weapon_m3")
  558.  
  559.  
  560.  
  561. }
  562.  
  563.  
  564.  
  565. }
  566.  
  567.  
  568.  
  569. }
  570.  
  571.  
  572.  
  573. }
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581. // Message Current Weapon
  582.  
  583.  
  584.  
  585. public message_cur_weapon(msg_id, msg_dest, id)
  586.  
  587.  
  588.  
  589. {
  590.  
  591.  
  592.  
  593. // Doesn't have a Sawn Off
  594.  
  595.  
  596.  
  597. if (!g_sawnoff_shotgun[id])
  598.  
  599.  
  600.  
  601. return PLUGIN_CONTINUE
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609. // Isn't alive / not active weapon
  610.  
  611.  
  612.  
  613. if (!is_user_alive(id) || get_msg_arg_int(1) != 1)
  614.  
  615.  
  616.  
  617. return PLUGIN_CONTINUE
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625. // Get Weapon Clip
  626.  
  627.  
  628.  
  629. new clip = get_msg_arg_int(3)
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637. // Update Weapon Array
  638.  
  639.  
  640.  
  641. g_currentweapon[id] = get_msg_arg_int(2) // get weapon ID
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649. // Weapon isn't M3
  650.  
  651.  
  652.  
  653. if(g_currentweapon[id] != CSW_M3)
  654.  
  655.  
  656.  
  657. return PLUGIN_CONTINUE;
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. // Replace Models
  666.  
  667.  
  668.  
  669. entity_set_string(id, EV_SZ_viewmodel, sawnoff_model_v)
  670.  
  671.  
  672.  
  673. entity_set_string(id, EV_SZ_weaponmodel, sawnoff_model_p)
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681. // Check cvar
  682.  
  683.  
  684.  
  685. if(get_pcvar_num(cvar_uclip))
  686.  
  687.  
  688.  
  689. {
  690.  
  691.  
  692.  
  693. // Set Ammo HUD in 8
  694.  
  695.  
  696.  
  697. set_msg_arg_int(3, get_msg_argtype(3), 8)
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705. // Check clip if more than 2
  706.  
  707.  
  708.  
  709. if (clip < 2)
  710.  
  711.  
  712.  
  713. {
  714.  
  715.  
  716.  
  717. // Update weapon ammo
  718.  
  719.  
  720.  
  721. fm_set_weapon_ammo(find_ent_by_owner(-1, "weapon_m3", id), 8)
  722.  
  723.  
  724.  
  725. }
  726.  
  727.  
  728.  
  729. }
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737. return PLUGIN_CONTINUE;
  738.  
  739.  
  740.  
  741. }
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749. // Touch fix (when user drop the Sawn off, already has the Sawn off.
  750.  
  751.  
  752.  
  753. public touch_fix(id)
  754.  
  755.  
  756.  
  757. {
  758.  
  759.  
  760.  
  761. if(g_sawnoff_shotgun[id])
  762.  
  763.  
  764.  
  765. g_sawnoff_shotgun[id] = false;
  766.  
  767.  
  768.  
  769. }
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777. /*================================================================================
  778.  
  779.  
  780.  
  781.  [Main Forwards]
  782.  
  783.  
  784.  
  785. =================================================================================*/
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793. public fw_PlayerKilled(victim, attacker, shouldgib)
  794.  
  795.  
  796.  
  797. {
  798.  
  799.  
  800.  
  801. // Victim has a Sawn off
  802.  
  803.  
  804.  
  805. if(g_sawnoff_shotgun[victim])
  806.  
  807.  
  808.  
  809. g_sawnoff_shotgun[victim] = false;
  810.  
  811.  
  812.  
  813. }
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821. public fw_SetModel(entity, model[])
  822.  
  823.  
  824.  
  825. {
  826.  
  827.  
  828.  
  829. // Entity is not valid
  830.  
  831.  
  832.  
  833. if(!is_valid_ent(entity))
  834.  
  835.  
  836.  
  837. return FMRES_IGNORED;
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845. // Entity model is not a M3
  846.  
  847.  
  848.  
  849. if(!equali(model, "models/w_m3.mdl"))
  850.  
  851.  
  852.  
  853. return FMRES_IGNORED;
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861. // Get owner and entity classname
  862.  
  863.  
  864.  
  865. new owner = entity_get_edict(entity, EV_ENT_owner)
  866.  
  867.  
  868.  
  869. new classname[33]
  870.  
  871.  
  872.  
  873. entity_get_string(entity, EV_SZ_classname, classname, charsmax(classname))
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881. // Entity classname is a weaponbox
  882.  
  883.  
  884.  
  885. if(equal(classname, "weaponbox"))
  886.  
  887.  
  888.  
  889. {
  890.  
  891.  
  892.  
  893. // The weapon owner has a Sawn Off
  894.  
  895.  
  896.  
  897. if(g_sawnoff_shotgun[owner])
  898.  
  899.  
  900.  
  901. {
  902.  
  903.  
  904.  
  905. // Striping Sawn off and set New Model
  906.  
  907.  
  908.  
  909. g_sawnoff_shotgun[owner] = false;
  910.  
  911.  
  912.  
  913. entity_set_model(entity, sawnoff_model_w)
  914.  
  915.  
  916.  
  917. set_task(0.1, "touch_fix", owner)
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925. return FMRES_SUPERCEDE
  926.  
  927.  
  928.  
  929. }
  930.  
  931.  
  932.  
  933. }
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941. return FMRES_IGNORED
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949. }
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  958.  
  959.  
  960.  
  961. {
  962.  
  963.  
  964.  
  965. // Attacker isn't a Player (1 in 32)
  966.  
  967.  
  968.  
  969. if(!(1 <= attacker <= g_MaxPlayers))
  970.  
  971.  
  972.  
  973. return HAM_IGNORED;
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981. // Attacker's weapon isn't a M3
  982.  
  983.  
  984.  
  985. if(g_currentweapon[attacker] != CSW_M3)
  986.  
  987.  
  988.  
  989. return HAM_IGNORED;
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997. // User doesn't have a Sawn Off
  998.  
  999.  
  1000.  
  1001. if(!g_sawnoff_shotgun[attacker])
  1002.  
  1003.  
  1004.  
  1005. return HAM_IGNORED;
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013. SetHamParamFloat(4, damage * get_pcvar_float(cvar_damage) )
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021. return HAM_IGNORED;
  1022.  
  1023.  
  1024.  
  1025. }
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033. public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
  1034.  
  1035.  
  1036.  
  1037. {
  1038.  
  1039.  
  1040.  
  1041. // Player is allowed to make a Knockback
  1042.  
  1043.  
  1044.  
  1045. if(!allowed_knockback(victim, attacker))
  1046.  
  1047.  
  1048.  
  1049. return HAM_IGNORED;
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057. // Check damage type
  1058.  
  1059.  
  1060.  
  1061. if(!(damage_type & DMG_BULLET))
  1062.  
  1063.  
  1064.  
  1065. return HAM_IGNORED;
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073. // Make Knockback...
  1074.  
  1075.  
  1076.  
  1077. new Float:velocity[3]; pev(victim, pev_velocity, velocity)
  1078.  
  1079.  
  1080.  
  1081. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_knockbackpower), direction)
  1082.  
  1083.  
  1084.  
  1085. xs_vec_add(velocity, direction, direction)
  1086.  
  1087.  
  1088.  
  1089. entity_set_vector(victim, EV_VEC_velocity, direction)
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097. return HAM_IGNORED;
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105. }
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113. public pfn_touch(entity, toucher)
  1114.  
  1115.  
  1116.  
  1117. {
  1118.  
  1119.  
  1120.  
  1121. new model[33], toucherclass[33], entityclass[33]
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129. // Get toucher Classname
  1130.  
  1131.  
  1132.  
  1133. if((toucher > 0) && is_valid_ent(toucher)) entity_get_string(toucher, EV_SZ_classname, toucherclass, charsmax(toucherclass))
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141. // Get entity Classname
  1142.  
  1143.  
  1144.  
  1145. if((entity > 0) && is_valid_ent(entity)) entity_get_string(entity, EV_SZ_classname, entityclass, charsmax(entityclass))
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153. // Now check if is a Weapon and is a Player
  1154.  
  1155.  
  1156.  
  1157. if(equali(toucherclass, "player") && equali(entityclass, "weaponbox"))
  1158.  
  1159.  
  1160.  
  1161. {
  1162.  
  1163.  
  1164.  
  1165. // Get Model
  1166.  
  1167.  
  1168.  
  1169. entity_get_string(entity, EV_SZ_model, model, charsmax(model))
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177. // Check Model
  1178.  
  1179.  
  1180.  
  1181. if(equali(model, sawnoff_model_w))
  1182.  
  1183.  
  1184.  
  1185. if(allowed_touch(toucher)) // Player is allowed to pickup the weapon
  1186.  
  1187.  
  1188.  
  1189. g_sawnoff_shotgun[toucher] = true // Set Weapon
  1190.  
  1191.  
  1192.  
  1193. }
  1194.  
  1195.  
  1196.  
  1197. }
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205. /*================================================================================
  1206.  
  1207.  
  1208.  
  1209.  [Internal Functions]
  1210.  
  1211.  
  1212.  
  1213. =================================================================================*/
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221. allowed_knockback(victim, attacker)
  1222.  
  1223.  
  1224.  
  1225. {
  1226.  
  1227.  
  1228.  
  1229. // Obviously, doesn't is allowed to be Knockbacked (WTF)
  1230.  
  1231.  
  1232.  
  1233. if(!g_sawnoff_shotgun[attacker] || !get_pcvar_num(cvar_knockback) || g_currentweapon[attacker] != CSW_M3 || !zp_get_user_zombie(victim))
  1234.  
  1235.  
  1236.  
  1237. return false;
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245. return true;
  1246.  
  1247.  
  1248.  
  1249. }
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257. allowed_touch(toucher)
  1258.  
  1259.  
  1260.  
  1261. {
  1262.  
  1263.  
  1264.  
  1265. // Can't touch the Weapon
  1266.  
  1267.  
  1268.  
  1269. if(zp_get_user_survivor(toucher) || zp_get_user_zombie(toucher) || fm_get_user_lastprimaryitem(toucher) || g_sawnoff_shotgun[toucher])
  1270.  
  1271.  
  1272.  
  1273. return false;
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281. return true;
  1282.  
  1283.  
  1284.  
  1285. }
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293. /*================================================================================
  1294.  
  1295.  
  1296.  
  1297.  [Zombie Plague Forwards]
  1298.  
  1299.  
  1300.  
  1301. =================================================================================*/
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309. public zp_extra_item_selected(id, itemid)
  1310.  
  1311.  
  1312.  
  1313. {
  1314.  
  1315.  
  1316.  
  1317. // Item is the Sawn-Off
  1318.  
  1319.  
  1320.  
  1321. if(itemid == g_SawnOff)
  1322.  
  1323.  
  1324.  
  1325. {
  1326.  
  1327.  
  1328.  
  1329. if(!get_pcvar_num(cvar_enable))
  1330.  
  1331.  
  1332.  
  1333. {
  1334.  
  1335.  
  1336.  
  1337. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + g_SawnOff_Cost)
  1338.  
  1339.  
  1340.  
  1341. client_print(id, print_chat, "[ZP] A Fűrészelt-Shotgun kikapcsolva!")
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349. return;
  1350.  
  1351.  
  1352.  
  1353. }
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361. // Already has an M3
  1362.  
  1363.  
  1364.  
  1365. if(g_sawnoff_shotgun[id] && user_has_weapon(id, CSW_M3))
  1366.  
  1367.  
  1368.  
  1369. {
  1370.  
  1371.  
  1372.  
  1373. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + g_SawnOff_Cost)
  1374.  
  1375.  
  1376.  
  1377. client_print(id, print_chat, "[ZP] Már van egy Fűrészelt-Shotgunod!")
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385. return;
  1386.  
  1387.  
  1388.  
  1389. }
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. // Array
  1398.  
  1399.  
  1400.  
  1401. g_sawnoff_shotgun[id] = true
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409. // Weapon
  1410.  
  1411.  
  1412.  
  1413. ham_give_weapon(id, "weapon_m3")
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421. // Message
  1422.  
  1423.  
  1424.  
  1425. client_print(id, print_chat, "[ZP] Kaptál egy Fűrészelt-Shotgunt!")
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433. }
  1434.  
  1435.  
  1436.  
  1437. }
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445. public zp_user_infected_post(infected, infector)
  1446.  
  1447.  
  1448.  
  1449. {
  1450.  
  1451.  
  1452.  
  1453. // Infected has a M3
  1454.  
  1455.  
  1456.  
  1457. if(g_sawnoff_shotgun[infected])
  1458.  
  1459.  
  1460.  
  1461. g_sawnoff_shotgun[infected] = false;
  1462.  
  1463.  
  1464.  
  1465. }
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473. public zp_user_humanized_post(player)
  1474.  
  1475.  
  1476.  
  1477. {
  1478.  
  1479.  
  1480.  
  1481. // Is Survivor
  1482.  
  1483.  
  1484.  
  1485. if(zp_get_user_survivor(player) && g_sawnoff_shotgun[player])
  1486.  
  1487.  
  1488.  
  1489. g_sawnoff_shotgun[player] = false;
  1490.  
  1491.  
  1492.  
  1493. }
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501. /*================================================================================
  1502.  
  1503.  
  1504.  
  1505.  [Stocks]
  1506.  
  1507.  
  1508.  
  1509. =================================================================================*/
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517. stock ham_give_weapon(id, weapon[])
  1518.  
  1519.  
  1520.  
  1521. {
  1522.  
  1523.  
  1524.  
  1525. if(!equal(weapon,"weapon_",7))
  1526.  
  1527.  
  1528.  
  1529. return 0
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537. new wEnt = create_entity(weapon)
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545. if(!is_valid_ent(wEnt))
  1546.  
  1547.  
  1548.  
  1549. return 0
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557. entity_set_int(wEnt, EV_INT_spawnflags, SF_NORESPAWN)
  1558.  
  1559.  
  1560.  
  1561. DispatchSpawn(wEnt)
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569. if(!ExecuteHamB(Ham_AddPlayerItem,id,wEnt))
  1570.  
  1571.  
  1572.  
  1573. {
  1574.  
  1575.  
  1576.  
  1577. if(is_valid_ent(wEnt)) entity_set_int(wEnt, EV_INT_flags, entity_get_int(wEnt, EV_INT_flags) | FL_KILLME)
  1578.  
  1579.  
  1580.  
  1581. return 0
  1582.  
  1583.  
  1584.  
  1585. }
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593. ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)
  1594.  
  1595.  
  1596.  
  1597. return 1
  1598.  
  1599.  
  1600.  
  1601. }
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609. stock ham_strip_weapon(id, weapon[])
  1610.  
  1611.  
  1612.  
  1613. {
  1614.  
  1615.  
  1616.  
  1617. if(!equal(weapon,"weapon_",7))
  1618.  
  1619.  
  1620.  
  1621. return 0
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629. new wId = get_weaponid(weapon)
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637. if(!wId) return 0
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645. new wEnt
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653. while((wEnt = find_ent_by_class(wEnt, weapon)) && entity_get_edict(wEnt, EV_ENT_owner) != id) {}
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661. if(!wEnt) return 0
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669. if(get_user_weapon(id) == wId)
  1670.  
  1671.  
  1672.  
  1673. ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681. if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt))
  1682.  
  1683.  
  1684.  
  1685. return 0
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693. ExecuteHamB(Ham_Item_Kill, wEnt)
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701. entity_set_int(id, EV_INT_weapons, entity_get_int(id, EV_INT_weapons) & ~(1<<wId))
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709. return 1
  1710.  
  1711.  
  1712.  
  1713. }
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721. stock fm_set_weapon_ammo(entity, amount)
  1722.  
  1723.  
  1724.  
  1725. {
  1726.  
  1727.  
  1728.  
  1729. set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
  1730.  
  1731.  
  1732.  
  1733. }
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741. stock fm_get_user_lastprimaryitem(id) // Thanks to joaquimandrade
  1742.  
  1743.  
  1744.  
  1745. {
  1746.  
  1747.  
  1748.  
  1749. if(get_pdata_cbase(id, OFFSET_LASTPRIMARYITEM) != -1)
  1750.  
  1751.  
  1752.  
  1753. return 1;
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761. return 0;
  1762.  
  1763.  
  1764.  
  1765. }
  1766.  
  1767.  
  1768.  
  1769.  

Ők köszönték meg m0csy652 nek ezt a hozzászólást: norbee.16 (2013.06.05. 22:02)
  Népszerűség: 2.27%


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


Ki van itt

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