AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   m4a1's Silence (https://forums.alliedmods.net/showthread.php?t=240181)

k1203352 05-10-2014 11:04

m4a1's Silence
 
I want to bind"t" on m4a1's silence.

But i don't want bind"t" with zoom...

How should I do sma?

NikKOo31 05-10-2014 11:54

Re: m4a1's Silence
 
Not sure of sending +attack2, but if you want to test, here you go:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
//#include <cstrike>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
register_impulse(201"impulse_201"//spray default on t
}

public 
impulse_201(id
{
    new 
weapon get_user_weapon(id__)
    if(
weapon == CSW_M4A1)
    {
        
engclient_cmd(id"+attack2"//not tested D:
    
}

    return 
PLUGIN_CONTINUE


You must have spray bind on T if you want this to work :bee:

aron9forever 05-10-2014 19:09

Re: m4a1's Silence
 
he wants to put a silencer on an m4a1 without using +attack2(hence the no zoom part)
I have no idea how it's done but I think it can be done, or at least I think so, I've played on DM servers where m4a1 from menu already has a silencer on it depending on how you died holding the gun

Backstabnoob 05-10-2014 19:25

Re: m4a1's Silence
 
Try cs_set_weapon_silen( )

hleV 05-10-2014 20:34

Re: m4a1's Silence
 
Nikko's example would be pretty much correct as long as your "T" is bound to "impulse 201". Though you may need to chance engclient_cmd() to client_cmd(). It may also require adding "wait; -attack2". Needs testing.

NikKOo31 05-10-2014 22:03

Re: m4a1's Silence
 
Quote:

Originally Posted by aron9forever (Post 2136172)
he wants to put a silencer on an m4a1 without using +attack2(hence the no zoom part)
I have no idea how it's done but I think it can be done, or at least I think so, I've played on DM servers where m4a1 from menu already has a silencer on it depending on how you died holding the gun

I don't think he say that.

Quote:

Originally Posted by hleV (Post 2136187)
Nikko's example would be pretty much correct as long as your "T" is bound to "impulse 201". Though you may need to chance engclient_cmd() to client_cmd(). It may also require adding "wait; -attack2". Needs testing.

I thought that after posting. I'm not sure if would need delay between +attack2 and -attack2? I will try to test it later

k1203352 05-11-2014 01:00

Re: m4a1's Silence
 
Thanks each help.

I want bind " t " on m4a1's silence like this...

PHP Code:

/* UTF-8 func by www.DT-Club.net */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN_NAME "New Plug-In"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Love灬Weiwei"

#define WEAPON_CSW CSW_M4A1
#define WEAPON_ENT "weapon_m4a1"
#define WEAPON_RELOAD_TIME 4.0
#define WEAPON_DRAW_TIME 2.0
#define WEAPON_ADDSIL_TIME 1.8
#define WEAPON_SHOOT_TIME 2.2

#define TASK_SHOOT 1234

enum {
 
anim_idle,
 
anim_reload,
 
anim_draw,
 
anim_shoot1,
 
anim_shoot2,
 
anim_shoot3,
 
anim_add,
 
anim_idle_unsil,
}

new 
g_reloading[33],g_addsil[33],g_shooting[33],g_hasDoneCurWeap[33]

const 
m_pPlayer 41   
const m_flNextPrimaryAttack 46

public plugin_init()
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
 
register_forward(FM_CmdStart"forward_cmdstart")
 
register_forward(FM_UpdateClientData"UpdateClientData_Post"1)
 
 
register_event("CurWeapon","Current_Weapon","be","1=1")
 
 
RegisterHam(Ham_Weapon_PrimaryAttackWEAPON_ENT"fw_WeapPriAttack"1)
 
RegisterHam(Ham_Weapon_ReloadWEAPON_ENT"fw_WeaponReload",1);
 
RegisterHam(Ham_Item_DeployWEAPON_ENT"fw_WeaponDeployPost"1);
 
g_grenade_access register_cvar("amx_grenade_access""p");
 
//
}

public 
native_playanim(player,anim)
{
 
set_pev(playerpev_weaponanimanim)
 
message_begin(MSG_ONESVC_WEAPONANIM, {000}, player)
 
write_byte(anim)
 
write_byte(pev(playerpev_body))
 
message_end()
}


public 
forward_cmdstart(iduc_handleseed)
{
 if(!
is_user_alive(id) || get_user_weapon(id) != WEAPON_CSW)
  return 
PLUGIN_HANDLED
  
 
if((get_uc(uc_handleUC_Buttons) & IN_ATTACK2) && !(pev(idpev_oldbuttons) & IN_ATTACK2) )
 {
  if(!
g_reloading[id] && !g_addsil[id])
  {
   if(
cs_get_user_zoom(id) == CS_SET_AUGSG552_ZOOM)
   {
    
cs_set_user_zoom(id,CS_RESET_ZOOM,1)
   }
   else
   {
    
cs_set_user_zoom(id,CS_SET_AUGSG552_ZOOM,1)
   }
   
   
emit_sound(idCHAN_ITEM"weapons/zoom.wav"0.202.400100)
  }

 }
 

 if( 
get_uc(uc_handleUC_Impulse) ==  201 && !g_reloading[id] && !g_addsil[id] && !g_shooting[id])
 {

  
cs_set_user_zoom(idCS_RESET_ZOOM0)
  
  
remove_task(id)
  
g_addsil[id] = true
  set_task
(WEAPON_ADDSIL_TIME,"Finish_addSil",id)
  
  new 
ent fm_find_ent_by_owner(-1WEAPON_ENT,id)
  
  if(
cs_get_weapon_silen(ent))
  {
   
cs_set_weapon_silen(ent,0,1)
  }
   
  else
  {
   
cs_set_weapon_silen(ent,1,1
  }
    
 }

 new 
cmd
 
 
if(g_addsil[id])
 {
  if((
cmd get_uc(uc_handleUC_Buttons)) & IN_ATTACK )
  {
   
cmd &= ~IN_ATTACK
   set_uc
(uc_handleUC_Buttonscmd)
  }  
  
  if((
cmd get_uc(uc_handleUC_Buttons)) & IN_RELOAD )
  {
   
cmd &= ~IN_RELOAD
   set_uc
(uc_handleUC_Buttonscmd)
  }  
 }
 
 if((
cmd get_uc(uc_handleUC_Buttons)) & IN_ATTACK2 )
 {
  
cmd &= ~IN_ATTACK2
  set_uc
(uc_handleUC_Buttonscmd)
 }
    
 
 return 
PLUGIN_HANDLED
}

public 
Finish_WeapReload(id)
{

 
g_reloading[id] = false
 
}

public 
Finish_addSil(id)
{
 
g_addsil[id] = false
 
 
if(is_user_alive(id) && get_user_weapon(id) == WEAPON_CSW)
 {
  new 
ent fm_find_ent_by_owner(-1WEAPON_ENT,id)
  
  if(
cs_get_weapon_silen(ent))
   
native_playanim(id,anim_idle)
  else
   
native_playanim(id,anim_idle_unsil)
 }
}

public 
Finish_shoot(taskid)
{
 new 
id taskid-TASK_SHOOT
 
 g_shooting
[id] = false
}

public 
Current_Weapon(id)
{
 if(!
g_hasDoneCurWeap[id] && get_user_weapon(id) != WEAPON_CSW)
 {
  
remove_task(id)
  
remove_task(id+TASK_SHOOT)
  
g_reloading[id] = false
  g_addsil
[id] = false
  g_shooting
[id] = false
  g_hasDoneCurWeap
[id] = true
 
}

}

public 
UpdateClientData_Postidsendweaponscd_handle )
{
 if(!
is_user_alive(id) || !g_addsil[id] || get_user_weapon(id) != WEAPON_CSW)
  return 
PLUGIN_HANDLED
 
 set_cd
(cd_handleCD_ID1);
 
 return 
PLUGIN_CONTINUE
}


public 
fw_WeaponReload(weapon)
{
 static 
id;
 
id get_pdata_cbase(weaponm_pPlayer4);
 
 
cs_set_user_zoom(idCS_RESET_ZOOM0
 
 
remove_task(id)
 
g_reloading[id] = true
 set_task
(WEAPON_RELOAD_TIME,"Finish_WeapReload",id)
}

public 
fw_WeaponDeployPost(weapon)
{
 static 
id;
 
id get_pdata_cbase(weaponm_pPlayer4);
 
 
remove_task(id)
 
g_reloading[id] = true
 set_task
(WEAPON_DRAW_TIME,"Finish_WeapReload",id)
 
 
g_hasDoneCurWeap[id] = false
 
 client_print
(id,print_chat,"欢迎使用开镜精华,右键开镜,T键使用特殊功能。")
}

public 
fw_WeapPriAttack(weapon)
{
 static 
id;
 
id get_pdata_cbase(weaponm_pPlayer4);
 
 if(
cs_get_user_zoom(id) == CS_SET_AUGSG552_ZOOM)
 {
  static 
Float:weap_delay
  weap_delay 
get_pdata_float(weapon464) * 1.5
  
  set_pdata_float
(weaponm_flNextPrimaryAttackweap_delay4)
 }
 
 
remove_task(id+TASK_SHOOT)
 
g_shooting[id] = true
 set_task
(WEAPON_SHOOT_TIME,"Finish_shoot",id+TASK_SHOOT)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\\\ rtf1\\\\ ansi\\\\ deff0{\\\\ fonttbl{\\\\ f0\\\\ fnil\\\\ fcharset134 Tahoma;}}\\n\\\\ viewkind4\\\\ uc1\\\\ pard\\\\ lang2052\\\\ f0\\\\ fs16 \\n\\\\ par }
*/ 

But it's has sight zoom.

I don't want this.

xairgeo 10-03-2018 01:53

Re: m4a1's Silence
 
bump

CrazY. 10-03-2018 07:47

Re: m4a1's Silence
 
Quote:

Originally Posted by xairgeo (Post 2617803)
bump

What the f*, no one will answer you since this thread was been created in 2014.

SHIELD755 10-03-2018 11:09

Re: m4a1's Silence
 
Quote:

Originally Posted by xairgeo (Post 2617803)
bump


from where did you get this :) :)


All times are GMT -4. The time now is 09:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.