AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]AWP & SCOUT fast switch (How to get user fov) (https://forums.alliedmods.net/showthread.php?t=85069)

Costin83 02-05-2009 07:47

[SOLVED]AWP & SCOUT fast switch (How to get user fov)
 
What's wrong with this code :shock:?
Pls. HELP ! ! !

I want to force fast-switching of AWP/SCOUT only when are zoomed

Code:

#include <amxmodx>
#include <engine>
new bool:g_switch
public switch_t(id)
{
 g_switch = false
}
public switch_f(id)
{
 g_switch = true
}
public eCurWeapon(id)
{
 static weapon, clip, ammo
 weapon = get_user_weapon(id, clip, ammo)
 switch (weapon)
 {
  case 3,18:
  {
  if(!g_switch)
  {
    if((get_user_button(id) & IN_ATTACK))
    client_cmd(id, "lastinv;lastinv")
  }
  }
 }
 return PLUGIN_CONTINUE
}
public plugin_init()
{
 register_plugin("fast_zoom", "1.0", "80T")
 register_event("CurWeapon", "eCurWeapon", "be", "1=1")
 register_event("SetFOV", "switch_t", "be", "1<90")
 register_event("SetFOV", "switch_f", "be", "1=90")
 
 return  PLUGIN_CONTINUE
}

And this is the simple version (working :mrgreen:)

Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
public eCurWeapon(id)
{
 static weapon, clip, ammo
 weapon = get_user_weapon(id, clip, ammo)
 switch (weapon)
 {
  case 3,18:
  {
  if((get_user_button(id)&IN_ATTACK))
    client_cmd(id,"lastinv;lastinv")
  }
 }
 return PLUGIN_CONTINUE
}
public plugin_init()
{
 register_plugin("fast_zoom", "1.0", "80T")
 register_event("CurWeapon", "eCurWeapon", "be", "1=1")
 
 return  PLUGIN_CONTINUE
}

Copy/paste some code from here and there and now it works like it should :mrgreen:!

Code:

#define PLUGIN_NAME "Fast Zoom"
#define PLUGIN_VERSION "0.1"
#define PLUGIN_AUTHOR "80T"
#include <amxmodx>
#include <engine>
#include <fakemeta>
#define FOV_DEFAULT 90
#define FOV_ZOOM_X3 15
public plugin_init()
{
 register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
 register_forward(FM_PlayerPostThink, "fwPlayerPostThink")
}
public fwPlayerPostThink(id)
{
 static fov
 if ((fov = pev(id, pev_fov)) >= FOV_DEFAULT || !fov)
  return FMRES_IGNORED
 static weapon, clip, ammo
 weapon = get_user_weapon(id, clip, ammo)
 switch (weapon)
 {
  case 3,18:
  {
  if ((get_user_button(id)&IN_ATTACK))
    set_task(0.1, "task_1", id)
  }
 }
 return FMRES_IGNORED
}
public task_1(id)
{
 client_cmd(id, "slot3")
 set_task(0.1, "task_2", id)
}
public task_2(id)
{
 client_cmd(id, "slot1")
}

Credits: VEN for his plugin "zoom_info" from which I've copied most of the code :mrgreen:
And SuicideDog for his plugin "Sniper Realism" copied some code from him either :mrgreen:


All times are GMT -4. The time now is 01:38.

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