Converted FG-LAUNCHER ( Cool Extra Item )

Zombies/Humans Extra-Items
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 441
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

Re: FG-LAUNCHER ( Cool Extra Item )

#11

Post by czirimbolo » 5 Months Ago

In the first sma. file there is a register_clcmd("say /get", "Get_FGLauncher").

Jack fixed this and there is no more command /get.

Anyway, Jack I can buy that weapon now in menu, but after that nothing happens. Gun is not working ;)
Image

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 532
Joined: 1 Year Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 42 times
Age: 19
Contact:

#12

Post by Jack GamePlay » 5 Months Ago

czirimbolo wrote:
5 Months Ago
In the first sma. file there is a register_clcmd("say /get", "Get_FGLauncher").

Jack fixed this and there is no more command /get.

Anyway, Jack I can buy that weapon now in menu, but after that nothing happens. Gun is not working ;)
I have updated the code
Check: https://escapers-zone.net/viewtopic.php?p=6997#p6997
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 441
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#13

Post by czirimbolo » 5 Months Ago

Yes I saw this, and after that, nothing happens after buying the gun
Image

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 532
Joined: 1 Year Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 42 times
Age: 19
Contact:

#14

Post by Jack GamePlay » 5 Months Ago

czirimbolo wrote:
5 Months Ago
Yes I saw this, and after that, nothing happens after buying the gun
Try:
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <zombie_escape>
  4. #include <engine>
  5.  
  6. #define PLUGIN "FG-Launcher"
  7. #define VERSION "1.0"
  8. #define AUTHOR "SexY DeviL CJ"
  9.  
  10. #define bpammo 40
  11. #define clipammo 10
  12. #define damage 80
  13. #define fgl "weapon_mp5navy"
  14. #define CSW_FGLAUNCHER CSW_MP5NAVY
  15. #define v_model "models/v_fglauncher.mdl"
  16. #define p_model "models/p_fglauncher.mdl"
  17. #define w_model "models/w_fglauncher.mdl"
  18. #define s_model "models/s_fglauncher.mdl"
  19. #define spark_sprite1 "sprites/spark2.spr"
  20. #define spark_sprite2 "sprites/spark3.spr"
  21. #define shoot_sound "weapons/fglauncher-1.wav"
  22.  
  23. /*  natives */
  24. native give_item(index, const item[]);
  25. native cs_get_user_bpammo(index, weapon);
  26. native cs_set_user_bpammo(index, weapon, amount);
  27. native cs_get_weapon_ammo(index);
  28. native cs_set_weapon_ammo(index, newammo);
  29. /*  --- */
  30.  
  31. new id
  32. new bool:gHasFg[33], sTrail, sExplo, gmsgWeaponList, g_iItemID;
  33.  
  34. public plugin_init() {
  35.     register_plugin(PLUGIN, VERSION, AUTHOR);
  36.     RegisterHam(Ham_Weapon_PrimaryAttack, fgl, "fgl_Pattack");
  37.     RegisterHam(Ham_Item_AddToPlayer, fgl, "fgl_atp");
  38.     register_forward(FM_SetModel, "fgl_setmodel");
  39.     register_forward(FM_UpdateClientData, "client_data_post", 1);
  40.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  41.     RegisterHam(Ham_Item_PostFrame, fgl, "fgl_PostFrame");
  42.     RegisterHam(Ham_Weapon_Reload, fgl, "fgl_Reload");
  43.     RegisterHam(Ham_Weapon_Reload, fgl, "fgl_Reload_Post", 1);
  44.    
  45.     register_clcmd("weapon_fglauncher_cso", "Hook_Select");
  46.    
  47.     register_touch("fgl_grenade", "*", "fgl_touch");
  48.    
  49.     gmsgWeaponList = get_user_msgid("WeaponList");
  50.    
  51.     g_iItemID = ze_register_item("FG-LAUNCHER", 140, 0);
  52. }
  53.  
  54. public plugin_precache(){
  55.     precache_model(v_model);
  56.     precache_model(p_model);
  57.     precache_model(w_model);
  58.     precache_model(s_model);
  59.     precache_generic( "sprites/weapon_fglauncher_cso.txt" );
  60.     precache_generic( "sprites/cso/640hud86.spr" );
  61.     precache_generic( "sprites/cso/640hud7x.spr" );
  62.     precache_generic( "sprites/cso/scope_vip_grenade.spr" );
  63.     sTrail = precache_model(spark_sprite2);
  64.     sExplo = precache_model(spark_sprite1);
  65.     precache_sound(shoot_sound);
  66. }
  67.  
  68. public ze_select_item_pre(player, itemid)
  69. {
  70.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  71.     if (itemid != g_iItemID)
  72.         return ZE_ITEM_AVAILABLE
  73.    
  74.     // Available for Humans only, So don't show it for zombies
  75.     if (ze_is_user_zombie(player))
  76.         return ZE_ITEM_DONT_SHOW
  77.    
  78.     return ZE_ITEM_AVAILABLE
  79. }
  80.  
  81. public ze_select_item_post(player, itemid)
  82. {
  83.     if (itemid != g_iItemID)
  84.         return
  85.    
  86.     fgl_Give(player)
  87. }
  88.  
  89. public ze_user_infected(player)
  90. {
  91.     if (!is_user_alive(player))
  92.         return
  93.  
  94.     if (gHasFg[player])
  95.         gHasFg[player] = false
  96. }
  97.  
  98. public Hook_Select(id)
  99. {
  100.     engclient_cmd(id, fgl);
  101.     return PLUGIN_HANDLED;
  102. }
  103.  
  104. public CurrentWeapon(id){
  105.     static lastweapon[33];
  106.     if(gHasFg[id] && get_user_weapon(id) == CSW_FGLAUNCHER){
  107.         if(lastweapon[id] != CSW_FGLAUNCHER) set_pev(id, pev_weaponanim, 3);
  108.         set_pev(id, pev_viewmodel2, v_model);
  109.         set_pev(id, pev_weaponmodel2, p_model);
  110.     }
  111.     lastweapon[id] = get_user_weapon(id);
  112. }
  113.  
  114. public fgl_Pattack(weapon){
  115.     new owner = pev(weapon, pev_owner);
  116.    
  117.     if(gHasFg[owner] && cs_get_weapon_ammo(weapon)>0){
  118.         fakeshoot(owner, weapon);
  119.  
  120.         return HAM_SUPERCEDE;
  121.     }
  122.     return HAM_IGNORED;
  123. }
  124.  
  125. public fgl_atp(fg, id) {
  126.     if(!is_valid_ent(fg) || !is_user_connected(id)) return HAM_IGNORED;
  127.        
  128.     if(entity_get_int(fg, EV_INT_impulse) == 1431)
  129.     {
  130.         gHasFg[id] = true;
  131.         entity_set_int(fg, EV_INT_impulse, 0);
  132.         Sprite(id);
  133.         return HAM_HANDLED;
  134.     }
  135.     else Sprite(id,0);
  136.    
  137.     return HAM_IGNORED;
  138. }
  139.  
  140. public fgl_setmodel(entity, model[])
  141. {
  142.     if(!is_valid_ent(entity))
  143.         return FMRES_IGNORED;
  144.    
  145.     new cn[33];
  146.     pev(entity, pev_classname, cn, 32);
  147.    
  148.     if(equal(cn, "weaponbox")) {
  149.    
  150.         new owner = pev(entity, pev_owner);
  151.    
  152.         if(equal(model, "models/w_mp5.mdl"))
  153.         {
  154.             static iStoredFGID;
  155.             iStoredFGID = find_ent_by_owner(-1, "weapon_mp5navy", entity);
  156.            
  157.             if(gHasFg[owner] && is_valid_ent(iStoredFGID))
  158.             {
  159.                 entity_set_int(iStoredFGID, EV_INT_impulse, 1431);
  160.                 gHasFg[owner] = false;
  161.                
  162.                 entity_set_model(entity, w_model);
  163.                 return FMRES_SUPERCEDE;
  164.             }
  165.         }
  166.     }
  167.    
  168.     return FMRES_IGNORED;
  169. }
  170.  
  171. public fakeshoot(id, weapon){
  172.     new Float:f[3];
  173.     cs_set_weapon_ammo(weapon, cs_get_weapon_ammo(weapon)-1);
  174.     set_pev(id, pev_punchangle, Float:{ -10.0, 0.0, 0.0 });
  175.     UTIL_PlayWeaponAnimation(id, 1);
  176.     emit_sound(id, CHAN_WEAPON, shoot_sound, 1.0, ATTN_NORM, 0, PITCH_NORM);
  177.     set_pdata_float(id, 83, 1.5);
  178.     pev(id, pev_origin, f);
  179.     f[2]+=3.0;
  180.     set_pev(id, pev_origin, f);
  181.     set_task(0.1, "check_stuck", id+121);
  182.    
  183.     create_grenade(id);
  184. }
  185.  
  186. public create_grenade(id){
  187.     new grenade = create_entity("info_target"), Float:fOrigin[3], Float:fVelocity[3], Float:fAngles[3];
  188.    
  189.     engfunc(EngFunc_GetAttachment, id, 1, fOrigin, fAngles);
  190.    
  191.     velocity_by_aim(id, 1000, fVelocity);
  192.     fVelocity[2]+=100.0;
  193.    
  194.     pev(id, pev_v_angle, fAngles);
  195.    
  196.     set_pev(grenade, pev_classname, "fgl_grenade");
  197.     set_pev(grenade, pev_origin, fOrigin);
  198.     set_pev(grenade, pev_velocity, fVelocity);
  199.     set_pev(grenade, pev_angles, fAngles);
  200.     set_pev(grenade, pev_movetype, MOVETYPE_TOSS);
  201.     set_pev(grenade, pev_solid, SOLID_BBOX);
  202.     set_pev(grenade, pev_owner, id);
  203.    
  204.     entity_set_model(grenade, s_model);
  205.    
  206.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  207.     write_byte(TE_BEAMFOLLOW);
  208.     write_short(grenade);
  209.     write_short(sTrail);
  210.     write_byte(10);
  211.     write_byte(3);
  212.     write_byte(255);
  213.     write_byte(255);
  214.     write_byte(255);
  215.     write_byte(250);
  216.     message_end();
  217.    
  218. }
  219.  
  220. public fgl_touch(ent){
  221.     new Float:originF[3];
  222.     pev(ent, pev_origin, originF);
  223.    
  224.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0);
  225.     write_byte(TE_WORLDDECAL);
  226.     engfunc(EngFunc_WriteCoord, originF[0]);
  227.     engfunc(EngFunc_WriteCoord, originF[1]);
  228.     engfunc(EngFunc_WriteCoord, originF[2]);
  229.     write_byte(engfunc(EngFunc_DecalIndex,"{scorch3"));
  230.     message_end();
  231.    
  232.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  233.     write_byte(TE_EXPLOSION);
  234.     engfunc(EngFunc_WriteCoord, originF[0]);
  235.     engfunc(EngFunc_WriteCoord, originF[1]);
  236.     engfunc(EngFunc_WriteCoord, originF[2]+60.0);
  237.     write_short(sTrail);
  238.     write_byte(10);
  239.     write_byte(15);
  240.     write_byte(0);
  241.     message_end();
  242.    
  243.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  244.     write_byte(TE_SPRITE);
  245.     engfunc(EngFunc_WriteCoord, originF[0]+random_float(-5.0, 5.0));
  246.     engfunc(EngFunc_WriteCoord, originF[1]+random_float(-5.0, 5.0));
  247.     engfunc(EngFunc_WriteCoord, originF[2]+200.0);
  248.     write_short(sExplo);
  249.     write_byte(15);
  250.     write_byte(200);
  251.     message_end();
  252.            
  253.     new owner = pev(ent, pev_owner);
  254.     new a = FM_NULLENT;
  255.  
  256.     while((a = find_ent_in_sphere(a,originF,300.0)) != 0) {
  257.        
  258.         if(a!=owner && a!=ent && pev(a,pev_takedamage)!=DAMAGE_NO && is_user_connected(a) && ze_is_user_zombie(a)) {
  259.             ExecuteHamB( Ham_TakeDamage, a ,owner,owner, (damage*60/entity_range(ent,a)), DMG_BULLET);
  260.         }
  261.     }
  262.     remove_entity(ent);
  263. }
  264.  
  265. public check_stuck(id){
  266.     id-=121;
  267.     new Float:f[3];
  268.     if(is_player_stuck(id)){
  269.         pev(id, pev_origin, f);
  270.         f[2]-=3.0;
  271.         set_pev(id, pev_origin, f);
  272.     }
  273. }
  274.  
  275. public client_data_post(id, SendWeapons, CD_Handle)
  276. {
  277.     if(is_user_alive(id) && get_user_weapon(id) == CSW_FGLAUNCHER && gHasFg[id])
  278.         set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.00001);
  279. }
  280.  
  281. public fgl_PostFrame(weapon_entity) {
  282.     new id = pev(weapon_entity, pev_owner);
  283.     if (!is_user_connected(id) || !gHasFg[id])
  284.         return HAM_IGNORED;
  285.  
  286.     new Float:flNextAttack = get_pdata_float(id, 83, 4);
  287.  
  288.     new iClip = get_pdata_int(weapon_entity, 51, 4);
  289.  
  290.     new fInReload = get_pdata_int(weapon_entity, 54, 4) ;
  291.  
  292.     if( fInReload && flNextAttack <= 0.0 )
  293.     {
  294.         new j = min(clipammo - iClip, cs_get_user_bpammo(id, CSW_FGLAUNCHER));
  295.    
  296.         set_pdata_int(weapon_entity, 51, iClip + j, 4);
  297.         cs_set_user_bpammo(id, CSW_FGLAUNCHER, cs_get_user_bpammo(id, CSW_FGLAUNCHER)-j);
  298.        
  299.         set_pdata_int(weapon_entity, 54, 0, 4);
  300.         fInReload = 0;
  301.     }
  302.  
  303.     return HAM_IGNORED;
  304. }
  305.  
  306. public fgl_Reload(weapon_entity) {
  307.     new id = pev(weapon_entity, pev_owner);
  308.     if (!is_user_connected(id) || !gHasFg[id])
  309.         return HAM_IGNORED;
  310.  
  311.     new iBpAmmo = cs_get_user_bpammo(id, CSW_FGLAUNCHER);
  312.     new iClip = get_pdata_int(weapon_entity, 51, 4);
  313.  
  314.     if (iBpAmmo <= 0 || iClip >= 10)
  315.         return HAM_SUPERCEDE;
  316.  
  317.  
  318.     return HAM_IGNORED;
  319. }
  320.  
  321. public fgl_Reload_Post(weapon_entity) {
  322.     new id = pev(weapon_entity, pev_owner);
  323.    
  324.     if (!is_user_connected(id))
  325.         return HAM_IGNORED;
  326.  
  327.     if (!gHasFg[id])
  328.         return HAM_IGNORED;
  329.  
  330.     set_pdata_float(weapon_entity, 48, 6.0, 4);
  331.  
  332.     set_pdata_float(id, 83, 6.0, 5);
  333.  
  334.     set_pdata_int(weapon_entity, 54, 1, 4);
  335.  
  336.     UTIL_PlayWeaponAnimation(id, 2);
  337.  
  338.     return HAM_IGNORED;
  339. }
  340.  
  341. public fgl_Give(id){
  342.    
  343.     gHasFg[id] = true;
  344.     new weapon = give_item(id, fgl);
  345.     cs_set_user_bpammo(id, CSW_FGLAUNCHER, 40);
  346.     cs_set_weapon_ammo(weapon, 10);
  347.     ExecuteHamB(Ham_Item_Deploy, weapon);
  348.     Sprite(id);
  349.    
  350. }
  351.  
  352. stock Sprite(id, type=1)
  353. {
  354.    
  355.     message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id);
  356.     write_string(type?"weapon_fglauncher_cso":fgl);
  357.     write_byte(10);
  358.     write_byte(40);
  359.     write_byte(-1);
  360.     write_byte(-1);
  361.     write_byte(0);
  362.     write_byte(7);
  363.     write_byte(19);
  364.     write_byte(0);
  365.     message_end();
  366.    
  367. }
  368.  
  369. stock is_player_stuck(id)
  370. {
  371.     static Float:originF[3];
  372.     pev(id, pev_origin, originF);
  373.    
  374.     engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0);
  375.    
  376.     if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  377.         return true;
  378.    
  379.     return false;
  380. }
  381.  
  382. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  383. {
  384.     set_pev(Player, pev_weaponanim, Sequence);
  385.        
  386.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player);
  387.     write_byte(Sequence);
  388.     write_byte(2);
  389.     message_end();
  390. }
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 441
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#15

Post by czirimbolo » 5 Months Ago

Solved. Thanks Jack!
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests