Raised This Month: $12 Target: $400
 3% 

How can I do that...?


Post New Thread Reply   
 
Thread Tools Display Modes
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-27-2019 , 18:01   Re: How can I do that...?
Reply With Quote #11

The plugin works as it should do but the code that makes the camera look where the user is aiming at (by the player view), makes the camera move weird like an aimbot basically. In relation of sounds and animations, I blocked the animations and recreated every single sound (I might forgot something, but I stopped working on it since online, due the low FPS or lag for some players, it's useless).

PHP Code:
#include <amxmodx> 
#include <cstrike>
#include <fakemeta> 
#include <engine>
#include <hamsandwich> 
#include <xs> 

#define VERSION             "0.0.2" 

#define MAX_PLAYERS                32 
#define USE_TOGGLE             3 

const CONST_SHOTGUNS =            (<< CSW_M3)|(<< CSW_XM1014)
const 
INVALID_WEAPONS =         (<< 2)|(<< CSW_KNIFE)|(<< CSW_C4)|(<< CSW_HEGRENADE)|(<< CSW_FLASHBANG)|(<< CSW_SMOKEGRENADE)

const 
XTRA_OFS_WEAPON =            4
const XTRAS_OFS_PLAYER =        5
const m_pPlayer =            41
const m_fInReload =             54
const m_fInSpecialReload =         55
const m_flTimeWeaponIdle =         48
const m_pActiveItem =            373

new const g_szGunsEvents[][] = 
{
        
"events/awp.sc",
        
"events/g3sg1.sc",
        
"events/ak47.sc",
        
"events/scout.sc",
        
"events/m249.sc",
        
"events/m4a1.sc",
        
"events/sg552.sc",
        
"events/aug.sc",
        
"events/sg550.sc",
        
"events/m3.sc",
        
"events/xm1014.sc",
        
"events/usp.sc",
        
"events/mac10.sc",
        
"events/ump45.sc",
        
"events/fiveseven.sc",
        
"events/p90.sc",
        
"events/deagle.sc",
        
"events/p228.sc",
        
"events/glock18.sc",
        
"events/mp5n.sc",
        
"events/tmp.sc",
        
"events/elite_left.sc",
        
"events/elite_right.sc",
        
"events/galil.sc",
        
"events/famas.sc"
}

new const 
g_szDeploySounds[][] =
{
    
"",
    
"weapons/p228_slidepull.wav",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"weapons/mac10_boltpull.wav",
    
"weapons/aug_forearm.wav",
    
"",
    
"weapons/elite_deploy.wav",
    
"weapons/fiveseven_slidepull.wav",
    
"",
    
"",
    
"weapons/galil_boltpull.wav",
    
"weapons/famas_forearm.wav",
    
"weapons/usp_slideback.wav",
    
"weapons/slideback1.wav"
    
"",
    
"weapons/mp5_slideback.wav",
    
"weapons/m249_chain.wav",
    
"weapons/m3_pump.wav",
    
"weapons/m4a1_deploy.wav",
    
"",
    
"",
    
"",
    
"",
    
"weapons/sg552_boltpull.wav",
    
"weapons/ak47_boltpull.wav",
    
"",
    
"weapons/p90_boltpull.wav"
}

new const 
g_szSoundReload[] =         "weapons/generic_reload.wav"

new CAMERA_FORWARD
new CAMERA_RIGHT 
new CAMERA_UP
new CAMERA_FRACTION

new g_iGunsEventsBitsumg_forwardPrecacheEvent

new g_iPlayerCamera[MAX_PLAYERS 1
new 
g_szWeaponSoundFmt[36][64], g_szWeaponDifferent[4][64]

public 
plugin_init() 

    
register_plugin("Camera View AUTOMATIC"VERSION"ConnorMcLeod"
    
    
CAMERA_FORWARD register_cvar("camera_forward""-100.0")
    
CAMERA_RIGHT register_cvar("camera_right""0.0")
    
CAMERA_UP register_cvar("camera_up""25.0")
    
CAMERA_FRACTION register_cvar("camera_fraction""-35.0")
    
    new 
szWeaponName[20]
    for(new 
CSW_P228;<= CSW_P90;i++)
    {
        if((
<< i) & INVALID_WEAPONS)
            continue
        
        
get_weaponname(iszWeaponNamecharsmax(szWeaponName))
        
RegisterHam(Ham_Item_DeployszWeaponName"FwdHamWeaponDeploy"1)
        
        if((
== CSW_M3) || (== CSW_XM1014))
            continue
            
        
RegisterHam(Ham_Weapon_ReloadszWeaponName"FwdHamWeaponReload"1)
    }
    
    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Post"1
    
RegisterHam(Ham_Think"trigger_camera""Camera_Think"
    
RegisterHam(Ham_Weapon_Reload"weapon_m3",     "FwdHamShotgunReload"1)
    
RegisterHam(Ham_Weapon_Reload"weapon_xm1014""FwdHamShotgunReload"1)
    
    
register_forward(FM_SetView"SetView"
    
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1)
    
register_forward(FM_PlaybackEvent"fwPlaybackEvent")
    
unregister_forward(FM_PrecacheEventg_forwardPrecacheEvent1)
    
    
register_clcmd("aaa""aa")
}

public 
aa(id)
{
    for(new 
1;32;i++)
    {
        if(
is_user_alive(i) && is_user_bot(i))
        {
            
set_pev(ipev_flagspev(ipev_flags) | FL_FROZEN)
        }
    }
}

public 
plugin_precache()
{
    for(new 
i;sizeof g_szDeploySounds;i++)
    {
        if(!
g_szDeploySounds[i][0])
            continue
            
        
precache_sound(g_szDeploySounds[i])
    }
    
    new 
szWeaponName[20], szSound[64]
    for(new 
CSW_P228;<= CSW_P90;i++)
    {
        if(
INVALID_WEAPONS & (<< i))
            continue
        
        new 
bool:bPrecache true
        
switch(i)
        {
            case 
CSW_SCOUT:        formatex(szSoundcharsmax(szSound), "weapons/scout_fire-1.wav")
            case 
CSW_ELITE:        formatex(szSoundcharsmax(szSound), "weapons/elite_fire.wav")
            case 
CSW_AWP:        formatex(szSoundcharsmax(szSound), "weapons/awp1.wav")
            case 
CSW_USP:        
            {
                
formatex(szSoundcharsmax(szSound), "weapons/usp_unsil-1.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponSoundFmt[i], charsmax(g_szWeaponSoundFmt[]), szSound)
                
                
formatex(szSoundcharsmax(szSound), "weapons/usp2.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponDifferent[0], charsmax(g_szWeaponDifferent[]), szSound)
                
                
bPrecache false
            
}
            case 
CSW_M4A1:
            {
                
formatex(szSoundcharsmax(szSound), "weapons/m4a1_unsil-1.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponSoundFmt[i], charsmax(g_szWeaponSoundFmt[]), szSound)
                
                
formatex(szSoundcharsmax(szSound), "weapons/m4a1-1.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponDifferent[1], charsmax(g_szWeaponDifferent[]), szSound)
                
                
bPrecache false
            
}
            case 
CSW_GLOCK18:
            {
                
formatex(szSoundcharsmax(szSound), "weapons/glock18-2.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponSoundFmt[i], charsmax(g_szWeaponSoundFmt[]), szSound)
                
                
formatex(szSoundcharsmax(szSound), "weapons/glock18-1.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponDifferent[2], charsmax(g_szWeaponDifferent[]), szSound)
                
                
bPrecache false
            
}
            case 
CSW_FAMAS:
            {
                
formatex(szSoundcharsmax(szSound), "weapons/famas-2.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponSoundFmt[i], charsmax(g_szWeaponSoundFmt[]), szSound)
                
                
formatex(szSoundcharsmax(szSound), "weapons/famas-burst.wav")
                
precache_sound(szSound)
                
copy(g_szWeaponDifferent[3], charsmax(g_szWeaponDifferent[]), szSound)
                
                
bPrecache false
            
}
            default:
            {
                
get_weaponname(iszWeaponNamecharsmax(szWeaponName))
                if(
== CSW_MP5NAVY)
                {
                    
replace(szWeaponNamecharsmax(szWeaponName), "navy""")
                }
                
formatex(szSoundcharsmax(szSound), "weapons/%s-1.wav"szWeaponName[7])
            }
        }
        
        if(
bPrecache)
        {
            
precache_sound(szSound)
            
copy(g_szWeaponSoundFmt[i], charsmax(g_szWeaponSoundFmt[]), szSound)
            
            
formatex(szSoundcharsmax(szSound), "sound/weapons/%s-2.wav"szWeaponName[7])
            if(
file_exists(szSound))
            {
                
precache_sound(szSound[5])
            }
        }
    }
    
    
g_forwardPrecacheEvent register_forward(FM_PrecacheEvent"fwPrecacheEvent"1)
    
precache_sound(g_szSoundReload)
}

public 
fwPrecacheEvent(iType, const szName[]) 
{
    for(new 
i;sizeof g_szGunsEvents;++i
    {
        if(
equal(g_szGunsEvents[i], szName)) 
        {
                        
g_iGunsEventsBitsum |= (<< get_orig_retval())
                        return 
FMRES_HANDLED
        
}
        }
        return 
FMRES_IGNORED
}

public 
fwPlaybackEvent(flagsiInvokeriEventId
{
    if(!(
g_iGunsEventsBitsum & (<< iEventId)) || !is_user_connected(iInvoker))
                return 
FMRES_IGNORED
        
    
new iWeaponID get_user_weapon(iInvoker)
    if(!
iWeaponID)
        return 
FMRES_HANDLED
    
    
    
new iWeaponEnt get_pdata_cbase(iInvokerm_pActiveItemXTRAS_OFS_PLAYER), szSound[64]
    if(
cs_get_weapon_silen(iWeaponEnt))
    {
        if(
iWeaponID == CSW_USP)
        {
            
copy(szSoundcharsmax(szSound), g_szWeaponDifferent[0])
        }
        else if(
iWeaponID == CSW_M4A1)
        {
            
copy(szSoundcharsmax(szSound), g_szWeaponDifferent[1])
        }
    }
    else if(
cs_get_weapon_burst(iWeaponEnt))
    {
        if(
iWeaponID == CSW_GLOCK18)
        {
            
copy(szSoundcharsmax(szSound), g_szWeaponDifferent[2])
        }
        else if(
iWeaponID == CSW_FAMAS)
        {
            
copy(szSoundcharsmax(szSound), g_szWeaponDifferent[3])
        }
    }
    else 
copy(szSoundcharsmax(szSound), g_szWeaponSoundFmt[iWeaponID])

    
emit_sound(iInvokerCHAN_WEAPONszSoundVOL_NORMATTN_NORM0PITCH_NORM)
    
    new 
iTargetiBody
    get_user_aiming
(iInvokeriTargetiBody)
    if(
is_user_alive(iTarget))
        return 
FMRES_IGNORED
        
    
new Float:fEntityEndPosition[3]
    
getAimEndPosition(iInvokerfEntityEndPosition)
    
drawSpark(fEntityEndPosition)
    return 
FMRES_IGNORED
}

public 
fw_UpdateClientData_Post(idsendweaponscd_handle)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED    
        
    set_cd
(cd_handleCD_flNextAttackget_gametime() + 0.001
    return 
FMRES_HANDLED
}

public 
FwdHamWeaponDeploy(const iWeapon)
{
    static 
id;id get_pdata_cbase(iWeaponm_pPlayerXTRA_OFS_WEAPON)
    if(!
is_user_connected(id))
        return 
HAM_IGNORED
        
    client_cmd
(id"spk ^"%s^""g_szDeploySounds[cs_get_weapon_id(iWeapon)])
    return 
HAM_IGNORED
}

public 
FwdHamWeaponReload(const iWeapon)
{
    if(
get_pdata_int(iWeaponm_fInReloadXTRA_OFS_WEAPON))
    {
        
emit_sound(get_pdata_cbase(iWeaponm_pPlayerXTRA_OFS_WEAPON), CHAN_ITEMg_szSoundReloadVOL_NORMATTN_NORM0PITCH_NORM)
    }
}

public 
FwdHamShotgunReload(const iWeapon)
{
    if(
get_pdata_int(iWeaponm_fInSpecialReloadXTRA_OFS_WEAPON) != 1)
        return 
HAM_IGNORED

    
new Float:flTimeWeaponIdle get_pdata_float(iWeaponm_flTimeWeaponIdleXTRA_OFS_WEAPON)
    if(
flTimeWeaponIdle != 0.55)
        return 
HAM_IGNORED
        
    emit_sound
(get_pdata_cbase(iWeaponm_pPlayerXTRA_OFS_WEAPON), CHAN_WEAPONg_szSoundReloadVOL_NORMATTN_NORM0PITCH_NORM)
    return 
HAM_IGNORED
}

public 
CBasePlayer_Spawn_Post(id

    if(!
is_user_alive(id)) 
    { 
        return 
    } 
    
    new 
iEnt g_iPlayerCamera[id
    if(!
pev_valid(iEnt)) 
    { 
        static 
iszTriggerCamera 
        
if(!iszTriggerCamera
        { 
            
iszTriggerCamera engfunc(EngFunc_AllocString"trigger_camera"
        } 
        
iEnt engfunc(EngFunc_CreateNamedEntityiszTriggerCamera
        
set_kvd(0KV_ClassName"trigger_camera"
        
set_kvd(0KV_fHandled0
        
set_kvd(0KV_KeyName"wait"
        
set_kvd(0KV_Value"999999"
        
dllfunc(DLLFunc_KeyValueiEnt0
        
        
set_pev(iEntpev_ownerid)
        
set_pev(iEntpev_spawnflagsSF_CAMERA_PLAYER_TARGET|SF_CAMERA_PLAYER_POSITION
        
set_pev(iEntpev_flagspev(iEntpev_flags) | FL_ALWAYSTHINK
        
        
dllfunc(DLLFunc_SpawniEnt
        
        
g_iPlayerCamera[id] = iEnt 
        
        
new Float:flMaxSpeediFlags pev(idpev_flags
        
pev(idpev_maxspeedflMaxSpeed
        
        
ExecuteHam(Ham_UseiEntididUSE_TOGGLE1.0
        
        
set_pev(idpev_flagsiFlags
        
engfunc(EngFunc_SetClientMaxspeedidflMaxSpeed
        
set_pev(idpev_maxspeedflMaxSpeed
    } 


public 
SetView(idiEnt

    if(
is_user_alive(id)) 
    { 
        new 
iCamera g_iPlayerCamera[id
        if(
iCamera && iEnt != iCamera
        { 
            new 
szClassName[16
            
pev(iEntpev_classnameszClassNamecharsmax(szClassName)) 
            if(!
equal(szClassName"trigger_camera")) // should let real cams enabled 
            

                
engfunc(EngFunc_SetViewidiCamera// shouldn't be always needed 
                
return FMRES_SUPERCEDE 
            

        } 
    } 
    return 
FMRES_IGNORED 


public 
client_disconnected(id

    new 
iEnt g_iPlayerCamera[id
    if(
pev_valid(iEnt)) 
    { 
        
engfunc(EngFunc_RemoveEntityiEnt
    } 
    
g_iPlayerCamera[id] = 


public 
client_putinserver(id

    
g_iPlayerCamera[id] = 


public 
Camera_Think(iEnt

    static 
id 
    
if(!(id pev(iEntpev_owner))) 
    { 
        return 
    } 
    
    static 
Float:fVecPlayerOrigin[3], Float:fVecCameraOrigin[3], Float:fVecAngles[3],  
    
Float:fVecForward[3], Float:fVecRight[3], Float:fVecUp[3]
    
    
pev(idpev_originfVecPlayerOrigin
    
pev(idpev_view_ofsfVecAngles
    
fVecPlayerOrigin[2] += fVecAngles[2
    
pev(idpev_v_anglefVecAngles
    
    
angle_vector(fVecAnglesANGLEVECTOR_FORWARDfVecForward
    
angle_vector(fVecAnglesANGLEVECTOR_RIGHTfVecRight
    
angle_vector(fVecAnglesANGLEVECTOR_UPfVecUp
    
    
fVecCameraOrigin[0] = fVecPlayerOrigin[0] + fVecForward[0] * get_pcvar_float(CAMERA_FORWARD) + fVecRight[0] * get_pcvar_float(CAMERA_RIGHT) + fVecUp[0] * get_pcvar_float(CAMERA_UP
    
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + fVecForward[1] * get_pcvar_float(CAMERA_FORWARD) + fVecRight[1] * get_pcvar_float(CAMERA_RIGHT) + fVecUp[1] * get_pcvar_float(CAMERA_UP
    
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + fVecForward[2] * get_pcvar_float(CAMERA_FORWARD) + fVecRight[2] * get_pcvar_float(CAMERA_RIGHT) + fVecUp[2] * get_pcvar_float(CAMERA_UP
    
    
engfunc(EngFunc_TraceLinefVecPlayerOriginfVecCameraOriginIGNORE_MONSTERSid0
    
    static 
Float:flFraction 
    get_tr2
(0TR_flFractionflFraction
    if(
flFraction != 1.0// adjust camera place if close to a wall 
    

        
flFraction *= get_pcvar_float(CAMERA_FRACTION)
        
        
fVecCameraOrigin[0] = fVecPlayerOrigin[0] + (fVecForward[0] * flFraction
        
fVecCameraOrigin[1] = fVecPlayerOrigin[1] + (fVecForward[1] * flFraction
        
fVecCameraOrigin[2] = fVecPlayerOrigin[2] + (fVecForward[2] * flFraction
    } 
    
    
set_pev(iEntpev_originfVecCameraOrigin)
    
set_pev(iEntpev_anglesfVecAngles)
    
set_pev(idpev_anglesfVecAngles)
    
    new 
Float:fEntityEndPosition[3]
    
getAimEndPosition(idfEntityEndPosition)
    
entity_set_aim(iEntfEntityEndPosition)
}  

getAimEndPosition(idFloat:fOrigin[3]) 
{
    new 
Float:fStart[3], Float:fViewOfs[3]
    
pev(idpev_originfStart)
    
pev(idpev_view_ofsfViewOfs)
    
xs_vec_add(fStartfViewOfsfStart)

    new 
Float:fDest[3]
    
pev(idpev_v_anglefDest)
    
engfunc(EngFunc_MakeVectorsfDest)
    
global_get(glb_v_forwardfDest)
    
xs_vec_mul_scalar(fDest4096.0fDest)
    
xs_vec_add(fStartfDestfDest)

    
engfunc(EngFunc_TraceLinefStartfDestDONT_IGNORE_MONSTERSid0)
    
get_tr2(0TR_vecEndPosfOrigin)
}

entity_set_aim(idFloat:fEndOrigin[3])
{
    static 
Float:fOrigin[3]
    
pev(idpev_originfOrigin)
    
    static 
Float:fVec[3]
    
pev(idpev_view_ofsfVec)
    
xs_vec_add(fOriginfVecfOrigin)
    
    static 
Float:fLook[3], Float:fLen
    xs_vec_sub
(fEndOriginfOriginfOrigin
    
fLen xs_vec_len(fOrigin)
    
    
fOrigin[0] /= fLen
    fOrigin
[1] /= fLen
    fOrigin
[2] /= fLen
    
    vector_to_angle
(fOriginfLook)
    
fLook[0] *= -1
    set_pev
(idpev_anglesfLook)
    
set_pev(idpev_fixangle1)
}

drawSpark(Float:origin[3])
{
    
message_begin(MSG_ALLSVC_TEMPENTITY)
    
write_byte(TE_SPARKS)
    
engfunc(EngFunc_WriteCoordorigin[0])
    
engfunc(EngFunc_WriteCoordorigin[1])
    
engfunc(EngFunc_WriteCoordorigin[2])
    
message_end()
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_WORLDDECAL)
    
engfunc(EngFunc_WriteCoordorigin[0])
    
engfunc(EngFunc_WriteCoordorigin[1])
    
engfunc(EngFunc_WriteCoordorigin[2])
    
write_byte(random_num(4145))
    
message_end()  

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 04-27-2019 at 18:35.
EFFx is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-28-2019 , 04:58   Re: How can I do that...?
Reply With Quote #12

Oh my god, it's perfect =)
Definitely helped a lot!
thEsp is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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