Resolved Tutorial For Making any zp extra item to ze extra item

Unpaid Requests, Public Plugins
Post Reply
johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

Tutorial For Making any zp extra item to ze extra item

#1

Post by johnnysins2000 » 2 Years Ago

I would like to request that can some one make an tutorial of how to make any zp extra item into ze extra item ?

so it can be used by normal players also !

I hope u understand me !
Nobody Is That Busy If They Make Time :roll:

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

#2

Post by Raheem » 2 Years Ago

Hello Johnny, Basically there is no static steps that you can follow so you can convert from ZP to ZE. That's because the steps i may give you be different in some cases so it need that you should understand some of the coding basics so you can convert any item you need. You need to look at the items we made and learn from it also you should learn the Forwards/Natives of our mod. Further more you can simply post the thing you need to convert and i'll or anyone of the ZE Dev Team help you converting it.
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#3

Post by johnnysins2000 » 2 Years Ago

so Raheem u are saying is that i cannot convert any zp extra item into ze ? to do that i will have to change natives of zp into ze and then also change some forwards so this is a very long step i guess ? Anyway still Guide me bro i can understand
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#4

Post by johnnysins2000 » 2 Years Ago

maybe i have an idea to help me out i will give u the extra item of zp here and u can convert it into ze extra item ..... After doing that i will look at the code how u turned the Zp extra item into ze extra item .... In this way i would understand
Nobody Is That Busy If They Make Time :roll:

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

#5

Post by Raheem » 2 Years Ago

Ok, Just give me the item and i'll edit it then you can understand what i do.
You don't know? Learn and you will know.

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

#6

Post by Raheem » 2 Years Ago

-Ok i do it. Now compile without errors or Warning. Look at what i edit:

1-Include only zombie_escape and you don't need to inculde these inculdes:
  • #include <amxmodx>
    #include <fakemeta>
    #include <dhudmessage>
    #include <hamsandwich>
    #include <engine>
    #include <fun>
2-Edit in the pre select item and in select item.

Hope you can understand these things and any problem just post.

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

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#7

Post by johnnysins2000 » 2 Years Ago

thank u Raheem last night i tried to make the oicw into ze extra item before u post this and i got two warnings ..... one was loosing intendation

over this code


public ze_select_item_pre(id, itemid)
{

if(itemid != g_iItemID)
return ZE_ITEM_AVAILABLE

if (ze_is_user_zombie(id))
return ZE_ITEM_DONT_SHOW

return ZE_ITEM_AVAILABLE
}


but now i get it what was my mistake in this thing that i was getting loosing intentdation thank you very much ! :)






One More Question u remove these includes #include <amxmodx>
#include <fakemeta>
#include <dhudmessage>
#include <hamsandwich>
#include <engine>
#include <fun>
There is no need for these includes for ze ?
Nobody Is That Busy If They Make Time :roll:

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

#8

Post by Raheem » 2 Years Ago

Loose indentation warning just appear if you don't indent (Mean of this the spaces in the code style) your code in one style. For Example if you make something like this:

  1. #include <zombie_escape>
  2.  
  3. public plugin_init()
  4. {
  5.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
  6. RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  7. }
  8.  
  9. public Set_User_Zombie(id)
  10. {
  11.     if (!is_user_alive(id))
  12.         return
  13. }

Or:

  1. #include <zombie_escape>
  2.  
  3. public plugin_init()
  4. {
  5.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
  6.         RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  7. }
  8.  
  9. public Set_User_Zombie(id)
  10. {
  11.     if (!is_user_alive(id))
  12.         return
  13. }

If you try to compile these simple lines it will give you loose indentation, Because simply you don't follow one style so if you do it like:

  1. #include <zombie_escape>
  2.  
  3. public plugin_init()
  4. {
  5.     register_plugin("[ZE] Items: Fire Nade", ZE_VERSION, AUTHORS)
  6.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  7. }
  8.  
  9. public Set_User_Zombie(id)
  10. {
  11.     if (!is_user_alive(id))
  12.         return
  13. }

This is the correct way and no warning will appear for you. It's advisable to write your code in programs like Notepad++ or Code::Blocks or Visual Studio.

About your second Question, If you need anyone of these inculdes so don't write it just by writing: #include <zombie_escape> is same as if you write:
  • #include <amxmodx>
    #include <fakemeta>
    #include <dhudmessage>
    #include <hamsandwich>
    #include <engine>
    #include <fun>
So don't write anyone of these things and only include our zombie_escape include.
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#9

Post by johnnysins2000 » 2 Years Ago

Thanks for the guidance :)
Nobody Is That Busy If They Make Time :roll:

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

#10

Post by Raheem » 2 Years Ago

Welcome brother :)
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest