AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   More recoil to weapons.. (https://forums.alliedmods.net/showthread.php?t=51681)

Alka 02-22-2007 09:38

More recoil to weapons..
 
Hi.I want to make an plugin to incrase the recoil of weapons.....how to do this?!:o I find this[for no recoil] =>>

PHP Code:

   if(get_pcvar_num(recoil_on_pcvar))
   {
    
set_pev(id,pev_punchangleFloat:{0.00.00.0})
   } 

On ghw "hacks" plugin! Thanks in advanced!:wink:

Voi 02-22-2007 19:01

Re: More recoil to weapons..
 
k, got something like this
Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#define PLUGIN "Weapon Inacuraccy"
#define VERSION "0.1"
#define AUTHOR "VoivoD"
new wiEnabled
#define RECOIL_LOW  -4.0
#define RECOIL_HIGH 4.0
#define RECOIL2_LOW  -8.0
#define RECOIL2_HIGH 8.0
#define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched
#define FL_ONGROUND (1<<9) // At rest / on the ground
new velocityI[3]
//new gmsgShake
//new taskid[32]
new g_rusza[33]
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_PlayerPreThink,"fw_playerprethink");
    wiEnabled = register_cvar("amx_inaccuracy","1");


public fw_playerprethink(id)
{
    if(!get_pcvar_num(wiEnabled))
        return FMRES_IGNORED;
   
    static dummy, weapon;
    weapon = get_user_weapon(id,dummy,dummy);
   
    if(weapon != CSW_M4A1 && weapon != CSW_AK47 && weapon != CSW_AUG && weapon != CSW_SG550 && weapon != CSW_M249 && weapon != CSW_MP5NAVY)
        return FMRES_IGNORED;
    static flags
    flags = entity_get_int(id, EV_INT_flags)
   
   
   
   
   
   
    //    if (!(flags & FL_ONGROUND)) //if in the air, unscope
    //          {
    //        client_cmd(id,"lastinv;lastinv")
    //          unscope_func(id)
    //          return PLUGIN_CONTINUE
    //  }
    if((pev(id,pev_button) & IN_ATTACK) && !(pev(id,pev_oldbuttons) & IN_ATTACK))
    {

        {
        if(weapon != CSW_M4A1 && weapon != CSW_AK47 && weapon != CSW_AUG && weapon != CSW_SG550 && weapon != CSW_M249)
            //if ducking shake less
        {
            if(flags & FL_DUCKING)
            {
                return FMRES_HANDLED
               
            }
            else
               
            {
                new Float:fVec2[3];
                fVec2[0] = random_float(RECOIL_LOW , RECOIL_HIGH);
                fVec2[1] = random_float(RECOIL_LOW , RECOIL_HIGH);
                fVec2[2] = random_float(RECOIL_LOW , RECOIL_HIGH);
                entity_set_vector(id , EV_VEC_punchangle , fVec2);
               
            }
            if(weapon != CSW_MP5NAVY)
            {
                if(flags & FL_DUCKING)
                {
                    return FMRES_HANDLED
                }
                else
                {
                    new Float:fVec2[3];
                    fVec2[0] = random_float(RECOIL2_LOW , RECOIL2_HIGH);
                    fVec2[1] = random_float(RECOIL2_LOW , RECOIL2_HIGH);
                    fVec2[2] = random_float(RECOIL2_LOW , RECOIL2_HIGH);
                    entity_set_vector(id , EV_VEC_punchangle , fVec2);   
                }
               
            }
        }
    }
        }
        return FMRES_HANDLED
    }
   
    public check_movement2(id)
    {     
        //    static id
       
        //    id = playerid[0]
       
        switch ( is_user_bot ( id ) )
        {
            case 1:
                return PLUGIN_CONTINUE
            }
           
            static Float:vector[3]
            entity_get_vector(id, EV_VEC_velocity, vector)
            FVecIVec(vector, velocityI)
           
           
           
           
            if (velocityI[0] != 0 || velocityI[1] != 0 || velocityI[2] != 0) //check movement, if moving shake
               
        {
            g_rusza[id] = 1
        }
        else
        {
            g_rusza[id] = 0
        }
               
        return FMRES_HANDLED
    }

but its only punching view when player has pressed the button, when it holds it doesnt work... any ideas ?

also set_task wont work couse the lowest value can be something between 0.2-0.4 and so the menagement cannot be done with this

Cheap_Suit 02-22-2007 19:20

Re: More recoil to weapons..
 
Dang, im so slow :(. Here is my version.
Note: Untested

Code:
#include <amxmodx> #include <fakemeta> #define PLUGIN "Extra Recoil" #define VERSION "1.0" #define AUTHOR "Cheap_Suit" new g_lastwpn[33] new g_lastclip[33] new cvar_extrarecoil public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("CurWeapon", "event_curweapon", "be","1=1")     cvar_extrarecoil = register_cvar("amx_recoil_multiplier", "1.5") } public event_curweapon(id) {     new weapon_id   = read_data(2)     new weapon_clip = read_data(3)         // weapons we dont want to give extra recoil to.     switch(weapon_id)     {         case CSW_KNIFE, CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE, CSW_C4: return     }         // check if the user is currently attacking.     if(!(pev(id, pev_button) & IN_ATTACK))         return         // check if the user didnt change weapon or if shots were fired. or has no ammo     if(weapon_id != g_lastwpn[id] || weapon_clip >= g_lastclip[id] || weapon_clip < 1)         return         // where the recoil magic really happens.     static Float:punchangle[3]     pev(id, pev_punchangle, punchangle)         new Float:punchangle_length = vector_length(punchangle)         // add extra recoil if there is a recoil?     if(punchangle_length == 0.0)         return         new Float:extra_recoil = get_pcvar_float(cvar_extrarecoil)         punchangle[0] *= extra_recoil     punchangle[1] *= extra_recoil         // punchangle[2] *= extra_recoil // i dont think you want this.         set_pev(id, pev_punchangle, punchangle)         // save current weapon and clip.     g_lastwpn[id]   = weapon_id     g_lastclip[id]  = weapon_clip }

Cheap_Suit 02-22-2007 19:27

Re: More recoil to weapons..
 
@Voi:

Because you check the users oldbutton.

Remove this !(pev(id, pev_oldbuttons) & IN_ATTACK)

Voi 02-22-2007 20:10

Re: More recoil to weapons..
 
thx will try this later couse ive got to go sleep... damn work...;/

btw, we are working on cs realism 2 :)

Alka 02-23-2007 06:51

Re: More recoil to weapons..
 
Thanks!...but i don't see any differences.... :|

Voi 02-23-2007 12:26

Re: More recoil to weapons..
 
doesnt work :(


All times are GMT -4. The time now is 00:43.

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