Converted VIP Extra Item: CSO Salamander

Zombies/Humans Extra-Items
Post Reply
shady101852
Member
Member
United States of America
Posts: 27
Joined: 11 Months Ago
Has thanked: 9 times
Been thanked: 2 times
Contact:

VIP Extra Item: CSO Salamander

#1

Post by shady101852 » 11 Months Ago

Description:
  • This is a converted CSO Human extra item. It is a weapon that shoots out fire, so a flamethrower.
Installation & Instructions:
  • Simply install it like any plugin and don't forget to copy the resources.
Screenshots:

Image

Downloads:

CSO Salamander.zip
(873.13 KiB) Downloaded 91 times
CSO Salamander.zip
(873.13 KiB) Downloaded 91 times
Last edited by shady101852 on 12 Oct 2018, 06:11, edited 6 times in total.
These users thanked the author shady101852 for the post (total 2):
Mark (11 Months Ago) • Raheem (11 Months Ago)

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#2

Post by Mark » 11 Months Ago

Nice Thanks!@
These users thanked the author Mark for the post:
shady101852 (11 Months Ago)

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#3

Post by Raheem » 11 Months Ago

NICE, +LIKE.
These users thanked the author Raheem for the post:
shady101852 (11 Months Ago)
You don't know? Learn and you will know.

Papo4ka
Member
Member
Posts: 12
Joined: 1 Month Ago
Has thanked: 1 time
Been thanked: 0
Contact:

#4

Post by Papo4ka » 1 Month Ago

A bug, for example, you have a standard weapon, M4A1, you buy CSO Salamander, and M4A1 simply does not throw out
Image

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#5

Post by Raheem » 1 Month Ago

Not a but, but OK here i used replace:

  1. #include <zombie_escape>
  2. #include <ze_vip>
  3. #include <amxconst>
  4. #include <fakemeta>
  5. #include <fakemeta_util>
  6. #include <cstrike>
  7. #include <xs>
  8. #include <engine>
  9. #include <fun>
  10.  
  11. #define PLUGIN "[CSO] Salamander"
  12. #define VERSION "2015"
  13. #define AUTHOR "Dias Pendragon Leon"
  14.  
  15. #define CSW_SAL CSW_M249
  16. #define weapon_sal "weapon_m249"
  17.  
  18. #define DAMAGE 38
  19. #define FIRE_SPEED 640.0
  20. #define RECOIL 0.0
  21.  
  22. #define MODEL_V "models/v_salamander.mdl"
  23. #define MODEL_P "models/p_salamander.mdl"
  24. #define MODEL_W "models/w_salamander.mdl"
  25. #define DEFAULT_W_MODEL "models/w_m249.mdl"
  26.  
  27. new const WeaponSounds[6][] =
  28. {
  29.     "weapons/flamegun-1.wav",
  30.     "weapons/flamegun_draw.wav",
  31.     "weapons/flamegun_clipin1.wav",
  32.     "weapons/flamegun_clipin2.wav",
  33.     "weapons/flamegun_clipout1.wav",
  34.     "weapons/flamegun_clipout2.wav"
  35. }
  36.  
  37. new const WeaponResources[7][] =
  38. {
  39.     "sprites/flame_puff01.spr",
  40.     "sprites/flame_burn01.spr",
  41.     "sprites/weapon_flamethrower.txt",
  42.     "sprites/640hud7_2.spr",
  43.     "sprites/640hud59_2.spr",
  44.     "sprites/640hud60_2.spr",
  45.     "sprites/smokepuff.spr"
  46. }
  47.  
  48. enum
  49. {
  50.     ANIM_IDLE = 0,
  51.     ANIM_SHOOT,
  52.     ANIM_SHOOT_END,
  53.     ANIM_RELOAD,
  54.     ANIM_DRAW
  55. }
  56.  
  57. // Marcros
  58. #define Get_BitVar(%1,%2)       (%1 & (1 << (%2 & 31)))
  59. #define Set_BitVar(%1,%2)       (%1 |= (1 << (%2 & 31)));
  60. #define UnSet_BitVar(%1,%2)     (%1 &= ~(1 << (%2 & 31)));
  61.  
  62. // Vars
  63. new g_Had_Salamander, g_WeaponEnt, g_SmokePuff_SprID, Float:g_PunchAngles[33]
  64. new g_MsgCurWeapon, g_MsgWeaponList
  65.  
  66. // Safety
  67. new g_HamBot
  68. new g_IsConnected, g_IsAlive, g_PlayerWeapon[33]
  69. new g_iItemId
  70.  
  71. public plugin_init()
  72. {
  73.     register_plugin(PLUGIN, VERSION, AUTHOR)
  74.    
  75.     // Your highness!
  76.     Register_SafetyFunc()
  77.    
  78.     // Forward
  79.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  80.     register_forward(FM_SetModel, "fw_SetModel")
  81.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  82.     register_forward(FM_CmdStart, "fw_CmdStart")
  83.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  84.    
  85.     // Engine
  86.     register_think("fireinsaigon", "fw_Fire_Think")
  87.     register_touch("fireinsaigon", "*", "fw_Fire_Touch")
  88.    
  89.     // Hams
  90.     RegisterHam(Ham_Item_Deploy, weapon_sal, "fw_Item_Deploy_Post", 1) 
  91.     RegisterHam(Ham_Item_AddToPlayer, weapon_sal, "fw_Item_AddToPlayer_Post", 1)
  92.    
  93.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  94.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  95.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_sal, "fw_Weapon_PrimaryAttack")
  96.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_sal, "fw_Weapon_PrimaryAttack_Post", 1)
  97.    
  98.     g_MsgCurWeapon = get_user_msgid("CurWeapon")
  99.     g_MsgWeaponList = get_user_msgid("WeaponList")
  100.    
  101. //  register_clcmd("say /get", "Get_Salamander")
  102.     register_clcmd("weapon_flamethrower", "Hook_Weapon")
  103.    
  104.     g_iItemId = ze_register_item("CSO Salamander", 100, 0)
  105.     ze_set_item_vip(g_iItemId, "VIP_A")
  106. }
  107.  
  108. public plugin_precache()
  109. {
  110.     precache_model(MODEL_V)
  111.     precache_model(MODEL_P)
  112.     precache_model(MODEL_W)
  113.    
  114.     for(new i = 0; i < sizeof(WeaponSounds); i++)
  115.         precache_sound(WeaponSounds[i])
  116.     for(new i = 0; i < sizeof(WeaponResources); i++)
  117.     {
  118.         if(i == 2) precache_generic(WeaponResources[i])
  119.         else if(i == 6) g_SmokePuff_SprID = precache_model(WeaponResources[i])
  120.         else precache_model(WeaponResources[i])
  121.     }
  122. }
  123.  
  124. public fw_PrecacheEvent_Post(type, const name[])
  125. {
  126.     if(equal("events/m249.sc", name))
  127.         g_WeaponEnt = get_orig_retval()
  128. }
  129.  
  130. public client_putinserver(id)
  131. {
  132.     Safety_Connected(id)
  133.     if(!g_HamBot && is_user_bot(id))
  134.     {
  135.         g_HamBot = 1
  136.         set_task(0.1, "Register_HamBot", id)
  137.     }
  138. }
  139.  
  140. public Register_HamBot(id)
  141. {
  142.     Register_SafetyFuncBot(id)
  143.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  144. }
  145.  
  146. public client_disconnected(id)
  147. {
  148.     Safety_Disconnected(id)
  149. }
  150.  
  151. public Hook_Weapon(id)
  152. {
  153.     engclient_cmd(id, weapon_sal)
  154.     return PLUGIN_HANDLED
  155. }
  156.  
  157. public Get_Salamander(id)
  158. {
  159.     Set_BitVar(g_Had_Salamander, id)
  160.     rg_give_item(id, weapon_sal, GT_REPLACE)
  161.    
  162.     message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
  163.     write_byte(1)
  164.     write_byte(CSW_SAL)
  165.     write_byte(100)
  166.     message_end()
  167.    
  168.     cs_set_user_bpammo(id, CSW_SAL, 200)
  169. }
  170.  
  171. public Remove_Salamander(id)
  172. {
  173.     UnSet_BitVar(g_Had_Salamander, id)
  174. }
  175.  
  176. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  177. {
  178.     if(!is_alive(id))
  179.         return FMRES_IGNORED
  180.     if(get_player_weapon(id) != CSW_SAL || !Get_BitVar(g_Had_Salamander, id))
  181.         return FMRES_IGNORED
  182.    
  183.     set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  184.    
  185.     return FMRES_HANDLED
  186. }
  187.  
  188. public fw_SetModel(entity, model[])
  189. {
  190.     if(!pev_valid(entity))
  191.         return FMRES_IGNORED
  192.    
  193.     static szClassName[33]
  194.     pev(entity, pev_classname, szClassName, charsmax(szClassName))
  195.    
  196.     if(!equal(szClassName, "weaponbox"))
  197.         return FMRES_IGNORED
  198.    
  199.     static id
  200.     id = pev(entity, pev_owner)
  201.    
  202.     if(equal(model, DEFAULT_W_MODEL))
  203.     {
  204.         static weapon; weapon = fm_find_ent_by_owner(-1, weapon_sal, entity)
  205.        
  206.         if(!pev_valid(weapon))
  207.             return FMRES_IGNORED
  208.        
  209.         if(Get_BitVar(g_Had_Salamander, id))
  210.         {
  211.             set_pev(weapon, pev_impulse, 442015)
  212.             engfunc(EngFunc_SetModel, entity, MODEL_W)
  213.            
  214.             UnSet_BitVar(g_Had_Salamander, id)
  215.            
  216.             return FMRES_SUPERCEDE
  217.         }
  218.     }
  219.  
  220.     return FMRES_IGNORED
  221. }
  222.  
  223. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  224. {
  225.     if(!is_alive(invoker))
  226.         return FMRES_IGNORED
  227.     if(get_player_weapon(invoker) != CSW_SAL || !Get_BitVar(g_Had_Salamander, invoker))
  228.         return FMRES_IGNORED   
  229.     if(eventid == g_WeaponEnt)
  230.     {
  231.         playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  232.         if(pev(invoker, pev_weaponanim) != ANIM_SHOOT) Set_WeaponAnim(invoker, ANIM_SHOOT)
  233.        
  234.         return FMRES_SUPERCEDE
  235.     }
  236.    
  237.     return FMRES_HANDLED
  238. }
  239.  
  240. public fw_CmdStart(id, uc_handle, seed)
  241. {
  242.     if(!is_alive(id))
  243.         return FMRES_IGNORED
  244.     if(get_player_weapon(id) != CSW_SAL || !Get_BitVar(g_Had_Salamander, id))
  245.         return FMRES_IGNORED
  246.        
  247.     static PressedButton
  248.     PressedButton = get_uc(uc_handle, UC_Buttons)
  249.    
  250.     if(!(PressedButton & IN_ATTACK))
  251.     {
  252.         if((pev(id, pev_oldbuttons) & IN_ATTACK) && pev(id, pev_weaponanim) == ANIM_SHOOT)
  253.         {
  254.             static weapon; weapon = fm_get_user_weapon_entity(id, CSW_SAL)
  255.             if(pev_valid(weapon)) set_pdata_float(weapon, 48, 2.0, 4)
  256.            
  257.             Set_WeaponAnim(id, ANIM_SHOOT_END)
  258.             Make_FireSmoke(id)
  259.         }
  260.     }
  261.        
  262.     return FMRES_HANDLED
  263. }
  264.  
  265. public Make_FireSmoke(id)
  266. {
  267.     static Float:Origin[3]
  268.     get_position(id, 40.0, 5.0, -15.0, Origin)
  269.    
  270.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  271.     write_byte(TE_EXPLOSION)
  272.     engfunc(EngFunc_WriteCoord, Origin[0])
  273.     engfunc(EngFunc_WriteCoord, Origin[1])
  274.     engfunc(EngFunc_WriteCoord, Origin[2])
  275.     write_short(g_SmokePuff_SprID)
  276.     write_byte(5)
  277.     write_byte(30)
  278.     write_byte(14)
  279.     message_end()
  280. }
  281.  
  282. public fw_Item_Deploy_Post(Ent)
  283. {
  284.     if(pev_valid(Ent) != 2)
  285.         return
  286.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
  287.     if(get_pdata_cbase(Id, 373) != Ent)
  288.         return
  289.     if(!Get_BitVar(g_Had_Salamander, Id))
  290.         return
  291.    
  292.     set_pev(Id, pev_viewmodel2, MODEL_V)
  293.     set_pev(Id, pev_weaponmodel2, MODEL_P)
  294. }
  295.  
  296. public fw_Item_AddToPlayer_Post(Ent, id)
  297. {
  298.     if(!pev_valid(Ent))
  299.         return HAM_IGNORED
  300.        
  301.     if(pev(Ent, pev_impulse) == 442015)
  302.     {
  303.         Set_BitVar(g_Had_Salamander, id)
  304.         set_pev(Ent, pev_impulse, 0)
  305.     }
  306.    
  307.     if(Get_BitVar(g_Had_Salamander, id))
  308.     {
  309.         message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, _, id)
  310.         write_string("weapon_flamethrower")
  311.         write_byte(3)
  312.         write_byte(200)
  313.         write_byte(-1)
  314.         write_byte(-1)
  315.         write_byte(0)
  316.         write_byte(4)
  317.         write_byte(CSW_SAL)
  318.         write_byte(0)
  319.         message_end()  
  320.     }
  321.    
  322.     return HAM_HANDLED 
  323. }
  324.  
  325. public fw_TraceAttack(Ent, Attacker, Float:Damage, Float:Dir[3], ptr, DamageType)
  326. {
  327.     if(!is_alive(Attacker))
  328.         return HAM_IGNORED
  329.     if(get_player_weapon(Attacker) != CSW_SAL || !Get_BitVar(g_Had_Salamander, Attacker))
  330.         return HAM_IGNORED
  331.    
  332.     return HAM_SUPERCEDE
  333. }
  334.  
  335. public CreateFire(id, Float:Speed)
  336. {
  337.     new iEnt = create_entity("env_sprite")
  338.     if(!pev_valid(iEnt)) return
  339.    
  340.     static Float:vfAngle[3], Float:MyOrigin[3]
  341.     static Float:Origin[3], Float:TargetOrigin[3], Float:Velocity[3]
  342.  
  343.     get_position(id, 40.0, 5.0, -5.0, Origin)
  344.     get_position(id, 1024.0, 0.0, 0.0, TargetOrigin)
  345.    
  346.     pev(id, pev_angles, vfAngle)
  347.     pev(id, pev_origin, MyOrigin)
  348.    
  349.     vfAngle[2] = float(random(18) * 20)
  350.  
  351.     // set info for ent
  352.     set_pev(iEnt, pev_movetype, MOVETYPE_FLY)
  353.     set_pev(iEnt, pev_rendermode, kRenderTransAdd)
  354.     set_pev(iEnt, pev_renderamt, 160.0)
  355.     set_pev(iEnt, pev_fuser1, get_gametime() + 1.0) // time remove
  356.     set_pev(iEnt, pev_scale, 0.25)
  357.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.05)
  358.    
  359.     entity_set_string(iEnt, EV_SZ_classname, "fireinsaigon")
  360.     engfunc(EngFunc_SetModel, iEnt, WeaponResources[0])
  361.     set_pev(iEnt, pev_mins, Float:{-1.0, -1.0, -1.0})
  362.     set_pev(iEnt, pev_maxs, Float:{1.0, 1.0, 1.0})
  363.     set_pev(iEnt, pev_origin, Origin)
  364.     set_pev(iEnt, pev_gravity, 0.01)
  365.     set_pev(iEnt, pev_angles, vfAngle)
  366.     set_pev(iEnt, pev_solid, SOLID_TRIGGER)
  367.     set_pev(iEnt, pev_owner, id)   
  368.     set_pev(iEnt, pev_frame, 0.0)
  369.     set_pev(iEnt, pev_iuser2, get_user_team(id))
  370.  
  371.     get_speed_vector(Origin, TargetOrigin, Speed, Velocity)
  372.     set_pev(iEnt, pev_velocity, Velocity)
  373.    
  374.     emit_sound(iEnt, CHAN_BODY, WeaponSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  375. }
  376.  
  377. public fw_Fire_Think(iEnt)
  378. {
  379.     if(!pev_valid(iEnt))
  380.         return
  381.    
  382.     static Float:fFrame, Float:fScale
  383.     pev(iEnt, pev_frame, fFrame)
  384.     pev(iEnt, pev_scale, fScale)
  385.  
  386.     // effect exp
  387.     if(pev(iEnt, pev_movetype) == MOVETYPE_NONE)
  388.     {
  389.         fFrame += 1.0
  390.         fScale += 0.1
  391.         fScale = floatmin(fScale, 1.75)
  392.  
  393.         if(fFrame > 21.0)
  394.         {
  395.             engfunc(EngFunc_RemoveEntity, iEnt)
  396.             return
  397.         }
  398.        
  399.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.025)
  400.     } else {
  401.         fFrame += 1.25
  402.         fFrame = floatmin(21.0, fFrame)
  403.         fScale += 0.15
  404.         fScale = floatmin(fScale, 1.75)
  405.        
  406.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.05)
  407.     }
  408.  
  409.     set_pev(iEnt, pev_frame, fFrame)
  410.     set_pev(iEnt, pev_scale, fScale)
  411.    
  412.     // time remove
  413.     static Float:fTimeRemove
  414.     pev(iEnt, pev_fuser1, fTimeRemove)
  415.     if (get_gametime() >= fTimeRemove)
  416.     {
  417.         engfunc(EngFunc_RemoveEntity, iEnt)
  418.         return;
  419.     }
  420. }
  421.  
  422. public fw_Fire_Touch(ent, id)
  423. {
  424.     if(!pev_valid(ent))
  425.         return
  426.        
  427.     if(pev_valid(id))
  428.     {
  429.         static Classname[32]
  430.         pev(id, pev_classname, Classname, sizeof(Classname))
  431.        
  432.         if(equal(Classname, "fireinsaigon")) return
  433.         else if(is_alive(id))
  434.         {
  435.             static EntTeam; EntTeam = pev(ent, pev_iuser2)
  436.             if(get_user_team(id) != EntTeam)
  437.             {
  438.                 static Attacker; Attacker = pev(ent, pev_owner)
  439.                 if(is_connected(Attacker))
  440.                 {
  441.                     ExecuteHamB(Ham_TakeDamage, id, 0, Attacker, float(DAMAGE), DMG_BULLET)
  442.                 }
  443.             }
  444.         }
  445.     }
  446.        
  447.     set_pev(ent, pev_movetype, MOVETYPE_NONE)
  448.     set_pev(ent, pev_solid, SOLID_NOT)
  449. }
  450.  
  451. public ze_select_item_pre(id, itemid)
  452. {
  453.     // If it is not the gun the player is willing to buy then just make it available.
  454.     // g_iItemId is the handler you made it before.
  455.     // You can name itemid whatever you like but just not the same handler name.
  456.    
  457.     if (itemid != g_iItemId)
  458.         return ZE_ITEM_AVAILABLE
  459.        
  460.     // In this item we are working on, it will be for humans only so we need to hide it for zombies so they do not get it.
  461.     //If you want it to be for zombies, you need to add the not operator "!" before the native so it's gonna be like this:
  462.     // if (!ze_is_user_zombie(id))
  463.     // If you want an item to be for zombies & humans then just don't add the next code.
  464.    
  465.     if (ze_is_user_zombie(id))
  466.         return ZE_ITEM_DONT_SHOW
  467.        
  468.     // Here we need to return a value so you don't get a warning on compiling.
  469.     return ZE_ITEM_AVAILABLE
  470. }
  471.  
  472. public ze_select_item_post(id, itemid)
  473. {
  474.     // Here we just block buying the gun if it is not the gun the player is willing to buy so we just add return without values.
  475.     if (itemid != g_iItemId)
  476.         return
  477.        
  478.     // Here you can give the item & you can even add a message to notice the player what he bought for example like this:
  479.     ze_colored_print(id, "You have successfully bought the item.")
  480.    
  481.     // Do you remember in public plugin_init(), we found something like this in it:
  482.     // register_clcmd("say /get", "Get_MyWeapon")
  483.     // That line is to allow you to get the gun for free when you type that command.
  484.     // Well, we don't care about it, we care about:
  485.     // Get_MyWeapon
  486.     // This is the function we will use to give the weapon to the player
  487.     // It's like this:
  488.     Get_Salamander(id)
  489. }
  490.  
  491. public fw_Weapon_PrimaryAttack(ent)
  492. {
  493.     static id; id = pev(ent, pev_owner)
  494.     pev(id, pev_punchangle, g_PunchAngles[id])
  495.    
  496.     return HAM_IGNORED 
  497. }
  498.  
  499. public fw_Weapon_PrimaryAttack_Post(ent)
  500. {
  501.     static id; id = pev(ent, pev_owner)
  502.  
  503.     if(get_player_weapon(id) == CSW_SAL && Get_BitVar(g_Had_Salamander, id) && cs_get_weapon_ammo(ent) > 0)
  504.     {
  505.         static Float:push[3]
  506.         pev(id, pev_punchangle, push)
  507.         xs_vec_sub(push, g_PunchAngles[id], push)
  508.        
  509.         xs_vec_mul_scalar(push, RECOIL, push)
  510.         xs_vec_add(push, g_PunchAngles[id], push)
  511.         set_pev(id, pev_punchangle, push)
  512.        
  513.         CreateFire(id, FIRE_SPEED)
  514.     } else {
  515.         static Float:push[3]
  516.         pev(id, pev_punchangle, push)
  517.         xs_vec_sub(push, g_PunchAngles[id], push)
  518.        
  519.         xs_vec_mul_scalar(push, 0.0, push)
  520.         xs_vec_add(push, g_PunchAngles[id], push)
  521.         set_pev(id, pev_punchangle, push)
  522.     }
  523.    
  524.     return HAM_IGNORED 
  525. }
  526.  
  527. stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
  528. {
  529.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  530.     if(!pev_valid(entwpn))
  531.         return
  532.        
  533.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  534.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  535.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, 4)
  536. }
  537.  
  538. stock Set_PlayerNextAttack(id, Float:nexttime)
  539. {
  540.     set_pdata_float(id, 83, nexttime, 5)
  541. }
  542.  
  543. stock Set_WeaponAnim(id, anim)
  544. {
  545.     set_pev(id, pev_weaponanim, anim)
  546.    
  547.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  548.     write_byte(anim)
  549.     write_byte(pev(id, pev_body))
  550.     message_end()
  551. }
  552.  
  553. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  554. {
  555.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  556.    
  557.     pev(id, pev_origin, vOrigin)
  558.     pev(id, pev_view_ofs,vUp) //for player
  559.     xs_vec_add(vOrigin,vUp,vOrigin)
  560.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  561.    
  562.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
  563.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
  564.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
  565.    
  566.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  567.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  568.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  569. }
  570.  
  571. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  572. {
  573.     new_velocity[0] = origin2[0] - origin1[0]
  574.     new_velocity[1] = origin2[1] - origin1[1]
  575.     new_velocity[2] = origin2[2] - origin1[2]
  576.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  577.     new_velocity[0] *= num
  578.     new_velocity[1] *= num
  579.     new_velocity[2] *= num
  580.    
  581.     return 1;
  582. }
  583.  
  584. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  585. {
  586.     static Float:vfEnd[3], viEnd[3]
  587.     get_user_origin(id, viEnd, 3)  
  588.     IVecFVec(viEnd, vfEnd)
  589.    
  590.     static Float:fOrigin[3], Float:fAngle[3]
  591.    
  592.     pev(id, pev_origin, fOrigin)
  593.     pev(id, pev_view_ofs, fAngle)
  594.    
  595.     xs_vec_add(fOrigin, fAngle, fOrigin)
  596.    
  597.     static Float:fAttack[3]
  598.    
  599.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  600.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  601.    
  602.     static Float:fRate
  603.    
  604.     fRate = fDis / vector_length(fAttack)
  605.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  606.    
  607.     xs_vec_add(fOrigin, fAttack, output)
  608. }
  609.  
  610. /* ===============================
  611. ------------- SAFETY -------------
  612. =================================*/
  613. public Register_SafetyFunc()
  614. {
  615.     register_event("CurWeapon", "Safety_CurWeapon", "be", "1=1")
  616.    
  617.     RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
  618.     RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
  619. }
  620.  
  621. public Register_SafetyFuncBot(id)
  622. {
  623.     RegisterHamFromEntity(Ham_Spawn, id, "fw_Safety_Spawn_Post", 1)
  624.     RegisterHamFromEntity(Ham_Killed, id, "fw_Safety_Killed_Post", 1)
  625. }
  626.  
  627. public Safety_Connected(id)
  628. {
  629.     Set_BitVar(g_IsConnected, id)
  630.     UnSet_BitVar(g_IsAlive, id)
  631.    
  632.     g_PlayerWeapon[id] = 0
  633. }
  634.  
  635. public Safety_Disconnected(id)
  636. {
  637.     UnSet_BitVar(g_IsConnected, id)
  638.     UnSet_BitVar(g_IsAlive, id)
  639.    
  640.     g_PlayerWeapon[id] = 0
  641. }
  642.  
  643. public Safety_CurWeapon(id)
  644. {
  645.     if(!is_alive(id))
  646.         return
  647.        
  648.     static CSW; CSW = read_data(2)
  649.     if(g_PlayerWeapon[id] != CSW) g_PlayerWeapon[id] = CSW
  650. }
  651.  
  652. public fw_Safety_Spawn_Post(id)
  653. {
  654.     if(!is_user_alive(id))
  655.         return
  656.        
  657.     Set_BitVar(g_IsAlive, id)
  658. }
  659.  
  660. public fw_Safety_Killed_Post(id)
  661. {
  662.     UnSet_BitVar(g_IsAlive, id)
  663. }
  664.  
  665. public is_connected(id)
  666. {
  667.     if(!(1 <= id <= 32))
  668.         return 0
  669.     if(!Get_BitVar(g_IsConnected, id))
  670.         return 0
  671.  
  672.     return 1
  673. }
  674.  
  675. public is_alive(id)
  676. {
  677.     if(!is_connected(id))
  678.         return 0
  679.     if(!Get_BitVar(g_IsAlive, id))
  680.         return 0
  681.        
  682.     return 1
  683. }
  684.  
  685. public get_player_weapon(id)
  686. {
  687.     if(!is_alive(id))
  688.         return 0
  689.    
  690.     return g_PlayerWeapon[id]
  691. }
  692.  
  693.  
  694. // ===================== STOCK... =======================
  695. // ======================================================
You don't know? Learn and you will know.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#6

Post by czirimbolo » 1 Month Ago

Raheem wrote:
1 Month Ago
Not a but, but OK here i used replace:

  1. #include <zombie_escape>
  2. #include <ze_vip>
  3. #include <amxconst>
  4. #include <fakemeta>
  5. #include <fakemeta_util>
  6. #include <cstrike>
  7. #include <xs>
  8. #include <engine>
  9. #include <fun>
  10.  
  11. #define PLUGIN "[CSO] Salamander"
  12. #define VERSION "2015"
  13. #define AUTHOR "Dias Pendragon Leon"
  14.  
  15. #define CSW_SAL CSW_M249
  16. #define weapon_sal "weapon_m249"
  17.  
  18. #define DAMAGE 38
  19. #define FIRE_SPEED 640.0
  20. #define RECOIL 0.0
  21.  
  22. #define MODEL_V "models/v_salamander.mdl"
  23. #define MODEL_P "models/p_salamander.mdl"
  24. #define MODEL_W "models/w_salamander.mdl"
  25. #define DEFAULT_W_MODEL "models/w_m249.mdl"
  26.  
  27. new const WeaponSounds[6][] =
  28. {
  29.     "weapons/flamegun-1.wav",
  30.     "weapons/flamegun_draw.wav",
  31.     "weapons/flamegun_clipin1.wav",
  32.     "weapons/flamegun_clipin2.wav",
  33.     "weapons/flamegun_clipout1.wav",
  34.     "weapons/flamegun_clipout2.wav"
  35. }
  36.  
  37. new const WeaponResources[7][] =
  38. {
  39.     "sprites/flame_puff01.spr",
  40.     "sprites/flame_burn01.spr",
  41.     "sprites/weapon_flamethrower.txt",
  42.     "sprites/640hud7_2.spr",
  43.     "sprites/640hud59_2.spr",
  44.     "sprites/640hud60_2.spr",
  45.     "sprites/smokepuff.spr"
  46. }
  47.  
  48. enum
  49. {
  50.     ANIM_IDLE = 0,
  51.     ANIM_SHOOT,
  52.     ANIM_SHOOT_END,
  53.     ANIM_RELOAD,
  54.     ANIM_DRAW
  55. }
  56.  
  57. // Marcros
  58. #define Get_BitVar(%1,%2)       (%1 & (1 << (%2 & 31)))
  59. #define Set_BitVar(%1,%2)       (%1 |= (1 << (%2 & 31)));
  60. #define UnSet_BitVar(%1,%2)     (%1 &= ~(1 << (%2 & 31)));
  61.  
  62. // Vars
  63. new g_Had_Salamander, g_WeaponEnt, g_SmokePuff_SprID, Float:g_PunchAngles[33]
  64. new g_MsgCurWeapon, g_MsgWeaponList
  65.  
  66. // Safety
  67. new g_HamBot
  68. new g_IsConnected, g_IsAlive, g_PlayerWeapon[33]
  69. new g_iItemId
  70.  
  71. public plugin_init()
  72. {
  73.     register_plugin(PLUGIN, VERSION, AUTHOR)
  74.    
  75.     // Your highness!
  76.     Register_SafetyFunc()
  77.    
  78.     // Forward
  79.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  80.     register_forward(FM_SetModel, "fw_SetModel")
  81.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  82.     register_forward(FM_CmdStart, "fw_CmdStart")
  83.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  84.    
  85.     // Engine
  86.     register_think("fireinsaigon", "fw_Fire_Think")
  87.     register_touch("fireinsaigon", "*", "fw_Fire_Touch")
  88.    
  89.     // Hams
  90.     RegisterHam(Ham_Item_Deploy, weapon_sal, "fw_Item_Deploy_Post", 1) 
  91.     RegisterHam(Ham_Item_AddToPlayer, weapon_sal, "fw_Item_AddToPlayer_Post", 1)
  92.    
  93.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  94.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
  95.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_sal, "fw_Weapon_PrimaryAttack")
  96.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_sal, "fw_Weapon_PrimaryAttack_Post", 1)
  97.    
  98.     g_MsgCurWeapon = get_user_msgid("CurWeapon")
  99.     g_MsgWeaponList = get_user_msgid("WeaponList")
  100.    
  101. //  register_clcmd("say /get", "Get_Salamander")
  102.     register_clcmd("weapon_flamethrower", "Hook_Weapon")
  103.    
  104.     g_iItemId = ze_register_item("CSO Salamander", 100, 0)
  105.     ze_set_item_vip(g_iItemId, "VIP_A")
  106. }
  107.  
  108. public plugin_precache()
  109. {
  110.     precache_model(MODEL_V)
  111.     precache_model(MODEL_P)
  112.     precache_model(MODEL_W)
  113.    
  114.     for(new i = 0; i < sizeof(WeaponSounds); i++)
  115.         precache_sound(WeaponSounds[i])
  116.     for(new i = 0; i < sizeof(WeaponResources); i++)
  117.     {
  118.         if(i == 2) precache_generic(WeaponResources[i])
  119.         else if(i == 6) g_SmokePuff_SprID = precache_model(WeaponResources[i])
  120.         else precache_model(WeaponResources[i])
  121.     }
  122. }
  123.  
  124. public fw_PrecacheEvent_Post(type, const name[])
  125. {
  126.     if(equal("events/m249.sc", name))
  127.         g_WeaponEnt = get_orig_retval()
  128. }
  129.  
  130. public client_putinserver(id)
  131. {
  132.     Safety_Connected(id)
  133.     if(!g_HamBot && is_user_bot(id))
  134.     {
  135.         g_HamBot = 1
  136.         set_task(0.1, "Register_HamBot", id)
  137.     }
  138. }
  139.  
  140. public Register_HamBot(id)
  141. {
  142.     Register_SafetyFuncBot(id)
  143.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  144. }
  145.  
  146. public client_disconnected(id)
  147. {
  148.     Safety_Disconnected(id)
  149. }
  150.  
  151. public Hook_Weapon(id)
  152. {
  153.     engclient_cmd(id, weapon_sal)
  154.     return PLUGIN_HANDLED
  155. }
  156.  
  157. public Get_Salamander(id)
  158. {
  159.     Set_BitVar(g_Had_Salamander, id)
  160.     rg_give_item(id, weapon_sal, GT_REPLACE)
  161.    
  162.     message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
  163.     write_byte(1)
  164.     write_byte(CSW_SAL)
  165.     write_byte(100)
  166.     message_end()
  167.    
  168.     cs_set_user_bpammo(id, CSW_SAL, 200)
  169. }
  170.  
  171. public Remove_Salamander(id)
  172. {
  173.     UnSet_BitVar(g_Had_Salamander, id)
  174. }
  175.  
  176. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  177. {
  178.     if(!is_alive(id))
  179.         return FMRES_IGNORED
  180.     if(get_player_weapon(id) != CSW_SAL || !Get_BitVar(g_Had_Salamander, id))
  181.         return FMRES_IGNORED
  182.    
  183.     set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  184.    
  185.     return FMRES_HANDLED
  186. }
  187.  
  188. public fw_SetModel(entity, model[])
  189. {
  190.     if(!pev_valid(entity))
  191.         return FMRES_IGNORED
  192.    
  193.     static szClassName[33]
  194.     pev(entity, pev_classname, szClassName, charsmax(szClassName))
  195.    
  196.     if(!equal(szClassName, "weaponbox"))
  197.         return FMRES_IGNORED
  198.    
  199.     static id
  200.     id = pev(entity, pev_owner)
  201.    
  202.     if(equal(model, DEFAULT_W_MODEL))
  203.     {
  204.         static weapon; weapon = fm_find_ent_by_owner(-1, weapon_sal, entity)
  205.        
  206.         if(!pev_valid(weapon))
  207.             return FMRES_IGNORED
  208.        
  209.         if(Get_BitVar(g_Had_Salamander, id))
  210.         {
  211.             set_pev(weapon, pev_impulse, 442015)
  212.             engfunc(EngFunc_SetModel, entity, MODEL_W)
  213.            
  214.             UnSet_BitVar(g_Had_Salamander, id)
  215.            
  216.             return FMRES_SUPERCEDE
  217.         }
  218.     }
  219.  
  220.     return FMRES_IGNORED
  221. }
  222.  
  223. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  224. {
  225.     if(!is_alive(invoker))
  226.         return FMRES_IGNORED
  227.     if(get_player_weapon(invoker) != CSW_SAL || !Get_BitVar(g_Had_Salamander, invoker))
  228.         return FMRES_IGNORED   
  229.     if(eventid == g_WeaponEnt)
  230.     {
  231.         playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  232.         if(pev(invoker, pev_weaponanim) != ANIM_SHOOT) Set_WeaponAnim(invoker, ANIM_SHOOT)
  233.        
  234.         return FMRES_SUPERCEDE
  235.     }
  236.    
  237.     return FMRES_HANDLED
  238. }
  239.  
  240. public fw_CmdStart(id, uc_handle, seed)
  241. {
  242.     if(!is_alive(id))
  243.         return FMRES_IGNORED
  244.     if(get_player_weapon(id) != CSW_SAL || !Get_BitVar(g_Had_Salamander, id))
  245.         return FMRES_IGNORED
  246.        
  247.     static PressedButton
  248.     PressedButton = get_uc(uc_handle, UC_Buttons)
  249.    
  250.     if(!(PressedButton & IN_ATTACK))
  251.     {
  252.         if((pev(id, pev_oldbuttons) & IN_ATTACK) && pev(id, pev_weaponanim) == ANIM_SHOOT)
  253.         {
  254.             static weapon; weapon = fm_get_user_weapon_entity(id, CSW_SAL)
  255.             if(pev_valid(weapon)) set_pdata_float(weapon, 48, 2.0, 4)
  256.            
  257.             Set_WeaponAnim(id, ANIM_SHOOT_END)
  258.             Make_FireSmoke(id)
  259.         }
  260.     }
  261.        
  262.     return FMRES_HANDLED
  263. }
  264.  
  265. public Make_FireSmoke(id)
  266. {
  267.     static Float:Origin[3]
  268.     get_position(id, 40.0, 5.0, -15.0, Origin)
  269.    
  270.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  271.     write_byte(TE_EXPLOSION)
  272.     engfunc(EngFunc_WriteCoord, Origin[0])
  273.     engfunc(EngFunc_WriteCoord, Origin[1])
  274.     engfunc(EngFunc_WriteCoord, Origin[2])
  275.     write_short(g_SmokePuff_SprID)
  276.     write_byte(5)
  277.     write_byte(30)
  278.     write_byte(14)
  279.     message_end()
  280. }
  281.  
  282. public fw_Item_Deploy_Post(Ent)
  283. {
  284.     if(pev_valid(Ent) != 2)
  285.         return
  286.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
  287.     if(get_pdata_cbase(Id, 373) != Ent)
  288.         return
  289.     if(!Get_BitVar(g_Had_Salamander, Id))
  290.         return
  291.    
  292.     set_pev(Id, pev_viewmodel2, MODEL_V)
  293.     set_pev(Id, pev_weaponmodel2, MODEL_P)
  294. }
  295.  
  296. public fw_Item_AddToPlayer_Post(Ent, id)
  297. {
  298.     if(!pev_valid(Ent))
  299.         return HAM_IGNORED
  300.        
  301.     if(pev(Ent, pev_impulse) == 442015)
  302.     {
  303.         Set_BitVar(g_Had_Salamander, id)
  304.         set_pev(Ent, pev_impulse, 0)
  305.     }
  306.    
  307.     if(Get_BitVar(g_Had_Salamander, id))
  308.     {
  309.         message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, _, id)
  310.         write_string("weapon_flamethrower")
  311.         write_byte(3)
  312.         write_byte(200)
  313.         write_byte(-1)
  314.         write_byte(-1)
  315.         write_byte(0)
  316.         write_byte(4)
  317.         write_byte(CSW_SAL)
  318.         write_byte(0)
  319.         message_end()  
  320.     }
  321.    
  322.     return HAM_HANDLED 
  323. }
  324.  
  325. public fw_TraceAttack(Ent, Attacker, Float:Damage, Float:Dir[3], ptr, DamageType)
  326. {
  327.     if(!is_alive(Attacker))
  328.         return HAM_IGNORED
  329.     if(get_player_weapon(Attacker) != CSW_SAL || !Get_BitVar(g_Had_Salamander, Attacker))
  330.         return HAM_IGNORED
  331.    
  332.     return HAM_SUPERCEDE
  333. }
  334.  
  335. public CreateFire(id, Float:Speed)
  336. {
  337.     new iEnt = create_entity("env_sprite")
  338.     if(!pev_valid(iEnt)) return
  339.    
  340.     static Float:vfAngle[3], Float:MyOrigin[3]
  341.     static Float:Origin[3], Float:TargetOrigin[3], Float:Velocity[3]
  342.  
  343.     get_position(id, 40.0, 5.0, -5.0, Origin)
  344.     get_position(id, 1024.0, 0.0, 0.0, TargetOrigin)
  345.    
  346.     pev(id, pev_angles, vfAngle)
  347.     pev(id, pev_origin, MyOrigin)
  348.    
  349.     vfAngle[2] = float(random(18) * 20)
  350.  
  351.     // set info for ent
  352.     set_pev(iEnt, pev_movetype, MOVETYPE_FLY)
  353.     set_pev(iEnt, pev_rendermode, kRenderTransAdd)
  354.     set_pev(iEnt, pev_renderamt, 160.0)
  355.     set_pev(iEnt, pev_fuser1, get_gametime() + 1.0) // time remove
  356.     set_pev(iEnt, pev_scale, 0.25)
  357.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.05)
  358.    
  359.     entity_set_string(iEnt, EV_SZ_classname, "fireinsaigon")
  360.     engfunc(EngFunc_SetModel, iEnt, WeaponResources[0])
  361.     set_pev(iEnt, pev_mins, Float:{-1.0, -1.0, -1.0})
  362.     set_pev(iEnt, pev_maxs, Float:{1.0, 1.0, 1.0})
  363.     set_pev(iEnt, pev_origin, Origin)
  364.     set_pev(iEnt, pev_gravity, 0.01)
  365.     set_pev(iEnt, pev_angles, vfAngle)
  366.     set_pev(iEnt, pev_solid, SOLID_TRIGGER)
  367.     set_pev(iEnt, pev_owner, id)   
  368.     set_pev(iEnt, pev_frame, 0.0)
  369.     set_pev(iEnt, pev_iuser2, get_user_team(id))
  370.  
  371.     get_speed_vector(Origin, TargetOrigin, Speed, Velocity)
  372.     set_pev(iEnt, pev_velocity, Velocity)
  373.    
  374.     emit_sound(iEnt, CHAN_BODY, WeaponSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  375. }
  376.  
  377. public fw_Fire_Think(iEnt)
  378. {
  379.     if(!pev_valid(iEnt))
  380.         return
  381.    
  382.     static Float:fFrame, Float:fScale
  383.     pev(iEnt, pev_frame, fFrame)
  384.     pev(iEnt, pev_scale, fScale)
  385.  
  386.     // effect exp
  387.     if(pev(iEnt, pev_movetype) == MOVETYPE_NONE)
  388.     {
  389.         fFrame += 1.0
  390.         fScale += 0.1
  391.         fScale = floatmin(fScale, 1.75)
  392.  
  393.         if(fFrame > 21.0)
  394.         {
  395.             engfunc(EngFunc_RemoveEntity, iEnt)
  396.             return
  397.         }
  398.        
  399.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.025)
  400.     } else {
  401.         fFrame += 1.25
  402.         fFrame = floatmin(21.0, fFrame)
  403.         fScale += 0.15
  404.         fScale = floatmin(fScale, 1.75)
  405.        
  406.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.05)
  407.     }
  408.  
  409.     set_pev(iEnt, pev_frame, fFrame)
  410.     set_pev(iEnt, pev_scale, fScale)
  411.    
  412.     // time remove
  413.     static Float:fTimeRemove
  414.     pev(iEnt, pev_fuser1, fTimeRemove)
  415.     if (get_gametime() >= fTimeRemove)
  416.     {
  417.         engfunc(EngFunc_RemoveEntity, iEnt)
  418.         return;
  419.     }
  420. }
  421.  
  422. public fw_Fire_Touch(ent, id)
  423. {
  424.     if(!pev_valid(ent))
  425.         return
  426.        
  427.     if(pev_valid(id))
  428.     {
  429.         static Classname[32]
  430.         pev(id, pev_classname, Classname, sizeof(Classname))
  431.        
  432.         if(equal(Classname, "fireinsaigon")) return
  433.         else if(is_alive(id))
  434.         {
  435.             static EntTeam; EntTeam = pev(ent, pev_iuser2)
  436.             if(get_user_team(id) != EntTeam)
  437.             {
  438.                 static Attacker; Attacker = pev(ent, pev_owner)
  439.                 if(is_connected(Attacker))
  440.                 {
  441.                     ExecuteHamB(Ham_TakeDamage, id, 0, Attacker, float(DAMAGE), DMG_BULLET)
  442.                 }
  443.             }
  444.         }
  445.     }
  446.        
  447.     set_pev(ent, pev_movetype, MOVETYPE_NONE)
  448.     set_pev(ent, pev_solid, SOLID_NOT)
  449. }
  450.  
  451. public ze_select_item_pre(id, itemid)
  452. {
  453.     // If it is not the gun the player is willing to buy then just make it available.
  454.     // g_iItemId is the handler you made it before.
  455.     // You can name itemid whatever you like but just not the same handler name.
  456.    
  457.     if (itemid != g_iItemId)
  458.         return ZE_ITEM_AVAILABLE
  459.        
  460.     // In this item we are working on, it will be for humans only so we need to hide it for zombies so they do not get it.
  461.     //If you want it to be for zombies, you need to add the not operator "!" before the native so it's gonna be like this:
  462.     // if (!ze_is_user_zombie(id))
  463.     // If you want an item to be for zombies & humans then just don't add the next code.
  464.    
  465.     if (ze_is_user_zombie(id))
  466.         return ZE_ITEM_DONT_SHOW
  467.        
  468.     // Here we need to return a value so you don't get a warning on compiling.
  469.     return ZE_ITEM_AVAILABLE
  470. }
  471.  
  472. public ze_select_item_post(id, itemid)
  473. {
  474.     // Here we just block buying the gun if it is not the gun the player is willing to buy so we just add return without values.
  475.     if (itemid != g_iItemId)
  476.         return
  477.        
  478.     // Here you can give the item & you can even add a message to notice the player what he bought for example like this:
  479.     ze_colored_print(id, "You have successfully bought the item.")
  480.    
  481.     // Do you remember in public plugin_init(), we found something like this in it:
  482.     // register_clcmd("say /get", "Get_MyWeapon")
  483.     // That line is to allow you to get the gun for free when you type that command.
  484.     // Well, we don't care about it, we care about:
  485.     // Get_MyWeapon
  486.     // This is the function we will use to give the weapon to the player
  487.     // It's like this:
  488.     Get_Salamander(id)
  489. }
  490.  
  491. public fw_Weapon_PrimaryAttack(ent)
  492. {
  493.     static id; id = pev(ent, pev_owner)
  494.     pev(id, pev_punchangle, g_PunchAngles[id])
  495.    
  496.     return HAM_IGNORED 
  497. }
  498.  
  499. public fw_Weapon_PrimaryAttack_Post(ent)
  500. {
  501.     static id; id = pev(ent, pev_owner)
  502.  
  503.     if(get_player_weapon(id) == CSW_SAL && Get_BitVar(g_Had_Salamander, id) && cs_get_weapon_ammo(ent) > 0)
  504.     {
  505.         static Float:push[3]
  506.         pev(id, pev_punchangle, push)
  507.         xs_vec_sub(push, g_PunchAngles[id], push)
  508.        
  509.         xs_vec_mul_scalar(push, RECOIL, push)
  510.         xs_vec_add(push, g_PunchAngles[id], push)
  511.         set_pev(id, pev_punchangle, push)
  512.        
  513.         CreateFire(id, FIRE_SPEED)
  514.     } else {
  515.         static Float:push[3]
  516.         pev(id, pev_punchangle, push)
  517.         xs_vec_sub(push, g_PunchAngles[id], push)
  518.        
  519.         xs_vec_mul_scalar(push, 0.0, push)
  520.         xs_vec_add(push, g_PunchAngles[id], push)
  521.         set_pev(id, pev_punchangle, push)
  522.     }
  523.    
  524.     return HAM_IGNORED 
  525. }
  526.  
  527. stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
  528. {
  529.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  530.     if(!pev_valid(entwpn))
  531.         return
  532.        
  533.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  534.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  535.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, 4)
  536. }
  537.  
  538. stock Set_PlayerNextAttack(id, Float:nexttime)
  539. {
  540.     set_pdata_float(id, 83, nexttime, 5)
  541. }
  542.  
  543. stock Set_WeaponAnim(id, anim)
  544. {
  545.     set_pev(id, pev_weaponanim, anim)
  546.    
  547.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  548.     write_byte(anim)
  549.     write_byte(pev(id, pev_body))
  550.     message_end()
  551. }
  552.  
  553. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  554. {
  555.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  556.    
  557.     pev(id, pev_origin, vOrigin)
  558.     pev(id, pev_view_ofs,vUp) //for player
  559.     xs_vec_add(vOrigin,vUp,vOrigin)
  560.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  561.    
  562.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
  563.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
  564.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
  565.    
  566.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  567.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  568.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  569. }
  570.  
  571. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  572. {
  573.     new_velocity[0] = origin2[0] - origin1[0]
  574.     new_velocity[1] = origin2[1] - origin1[1]
  575.     new_velocity[2] = origin2[2] - origin1[2]
  576.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  577.     new_velocity[0] *= num
  578.     new_velocity[1] *= num
  579.     new_velocity[2] *= num
  580.    
  581.     return 1;
  582. }
  583.  
  584. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  585. {
  586.     static Float:vfEnd[3], viEnd[3]
  587.     get_user_origin(id, viEnd, 3)  
  588.     IVecFVec(viEnd, vfEnd)
  589.    
  590.     static Float:fOrigin[3], Float:fAngle[3]
  591.    
  592.     pev(id, pev_origin, fOrigin)
  593.     pev(id, pev_view_ofs, fAngle)
  594.    
  595.     xs_vec_add(fOrigin, fAngle, fOrigin)
  596.    
  597.     static Float:fAttack[3]
  598.    
  599.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  600.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  601.    
  602.     static Float:fRate
  603.    
  604.     fRate = fDis / vector_length(fAttack)
  605.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  606.    
  607.     xs_vec_add(fOrigin, fAttack, output)
  608. }
  609.  
  610. /* ===============================
  611. ------------- SAFETY -------------
  612. =================================*/
  613. public Register_SafetyFunc()
  614. {
  615.     register_event("CurWeapon", "Safety_CurWeapon", "be", "1=1")
  616.    
  617.     RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
  618.     RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
  619. }
  620.  
  621. public Register_SafetyFuncBot(id)
  622. {
  623.     RegisterHamFromEntity(Ham_Spawn, id, "fw_Safety_Spawn_Post", 1)
  624.     RegisterHamFromEntity(Ham_Killed, id, "fw_Safety_Killed_Post", 1)
  625. }
  626.  
  627. public Safety_Connected(id)
  628. {
  629.     Set_BitVar(g_IsConnected, id)
  630.     UnSet_BitVar(g_IsAlive, id)
  631.    
  632.     g_PlayerWeapon[id] = 0
  633. }
  634.  
  635. public Safety_Disconnected(id)
  636. {
  637.     UnSet_BitVar(g_IsConnected, id)
  638.     UnSet_BitVar(g_IsAlive, id)
  639.    
  640.     g_PlayerWeapon[id] = 0
  641. }
  642.  
  643. public Safety_CurWeapon(id)
  644. {
  645.     if(!is_alive(id))
  646.         return
  647.        
  648.     static CSW; CSW = read_data(2)
  649.     if(g_PlayerWeapon[id] != CSW) g_PlayerWeapon[id] = CSW
  650. }
  651.  
  652. public fw_Safety_Spawn_Post(id)
  653. {
  654.     if(!is_user_alive(id))
  655.         return
  656.        
  657.     Set_BitVar(g_IsAlive, id)
  658. }
  659.  
  660. public fw_Safety_Killed_Post(id)
  661. {
  662.     UnSet_BitVar(g_IsAlive, id)
  663. }
  664.  
  665. public is_connected(id)
  666. {
  667.     if(!(1 <= id <= 32))
  668.         return 0
  669.     if(!Get_BitVar(g_IsConnected, id))
  670.         return 0
  671.  
  672.     return 1
  673. }
  674.  
  675. public is_alive(id)
  676. {
  677.     if(!is_connected(id))
  678.         return 0
  679.     if(!Get_BitVar(g_IsAlive, id))
  680.         return 0
  681.        
  682.     return 1
  683. }
  684.  
  685. public get_player_weapon(id)
  686. {
  687.     if(!is_alive(id))
  688.         return 0
  689.    
  690.     return g_PlayerWeapon[id]
  691. }
  692.  
  693.  
  694. // ===================== STOCK... =======================
  695. // ======================================================
Can you explain what did you excatly changed? Because many weapons have this problem
Image

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#7

Post by Raheem » 1 Month Ago

Changed give_item(id, weapon_sal) ---> rg_give_item(id, weapon_sal, GT_REPLACE)
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest