AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Code to ham or fake until (https://forums.alliedmods.net/showthread.php?t=87525)

One 03-13-2009 05:57

Code to ham or fake until
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <xs>

#define MAX_SOUNDS    5
new g_BulletSounds[MAX_SOUNDS][] = 

    
"misc/whizz1.wav",    
    
"misc/whizz2.wav",     
    
"misc/whizz3.wav",    
    
"misc/whizz4.wav",    
    
"misc/whizz5.wav"
}

new 
g_LastWeapon[33]
new 
g_LastAmmo[33]

new 
PLUGIN_NAME[]     = "Bullet Whizz"
new PLUGIN_AUTHOR[]     = "Cheap_Suit"
new PLUGIN_VERSION[]     = "1.4"

public plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
    
register_cvar("amx_bulletwhizz_dis""40")
    
register_cvar("amx_bulletwhizz""1")
}

public 
plugin_precache()
{
    for(new 
0MAX_SOUNDS; ++i) {    
        
precache_sound(g_BulletSounds[i])
    }
}

public 
Event_CurWeapon(id
{
    if(!
get_cvar_num("amx_bulletwhizz") || !is_user_connected(id) || !is_user_alive(id)) {
        return 
PLUGIN_CONTINUE
    
}
    
    new 
WeaponID read_data(2), Clip read_data(3)
    switch(
WeaponID) {
        case 
CSW_HEGRENADECSW_FLASHBANGCSW_SMOKEGRENADECSW_C4CSW_KNIFE: return PLUGIN_CONTINUE
    
}
    
    if(
g_LastWeapon[id] == WeaponID && g_LastAmmo[id] > Clip)
    {
        new 
Players[32], iNum
        get_players
(PlayersiNum"a")
        for(new 
0iNum; ++i) if(id != Players[i])
        {
            new 
target Players[i]
            new 
Float:fOrigin[2][3], temp[3], Float:fAim[3]
            
entity_get_vector(idEV_VEC_originfOrigin[0])
            
entity_get_vector(targetEV_VEC_originfOrigin[1])
            
            
get_user_origin(idtemp3)
            
IVecFVec(tempfAim)
            
            new 
iDistance get_distance_to_line(fOrigin[0], fOrigin[1], fAim)
            if(
iDistance get_cvar_num("amx_bulletwhizz_dis") || iDistance 
            
|| !fm_is_ent_visible(idtarget)) {
                continue
            }

            new 
RandomSound[64]
            
format(RandomSound63"%s"g_BulletSounds[random_num(0MAX_SOUNDS-1)]) 
            
client_cmd(target"spk %s"RandomSound)
        }
    }
    
g_LastWeapon[id] = WeaponID
    g_LastAmmo
[id] = Clip
    
    
return PLUGIN_CONTINUE
}

stock get_distance_to_line(Float:pos_start[3], Float:pos_end[3], Float:pos_object[3])  
{  
    new 
Float:vec_start_end[3], Float:vec_start_object[3], Float:vec_end_object[3], Float:vec_end_start[3
    
xs_vec_sub(pos_endpos_startvec_start_end// vector from start to end 
    
xs_vec_sub(pos_objectpos_startvec_start_object// vector from end to object 
    
xs_vec_sub(pos_startpos_endvec_end_start// vector from end to start 
    
xs_vec_sub(pos_endpos_objectvec_end_object// vector object to end 
    
    
new Float:len_start_object getVecLen(vec_start_object
    new 
Float:angle_start floatacos(xs_vec_dot(vec_start_endvec_start_object) / (getVecLen(vec_start_end) * len_start_object), degrees)  
    new 
Float:angle_end floatacos(xs_vec_dot(vec_end_startvec_end_object) / (getVecLen(vec_end_start) * getVecLen(vec_end_object)), degrees)  

    if(
angle_start <= 90.0 && angle_end <= 90.0
        return 
floatround(len_start_object floatsin(angle_startdegrees)) 
    return -
1  
}

stock Float:getVecLen(Float:Vec[3])

    new 
Float:VecNull[3] = {0.00.00.0}
    new 
Float:len get_distance_f(VecVecNull)
    return 
len


stock bool:fm_is_ent_visible(indexentity
{
    new 
Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
    
pev(indexpev_originorigin)
    
pev(indexpev_view_ofsview_ofs)
    
xs_vec_add(originview_ofseyespos)

    new 
Float:entpos[3]
    
pev(entitypev_originentpos)
    
engfunc(EngFunc_TraceLineeyesposentpos0index)

    switch (
pev(entitypev_solid)) {
        case 
SOLID_BBOX..SOLID_BSP: return global_get(glb_trace_ent) == entity
    
}

    new 
Float:fraction
    global_get
(glb_trace_fractionfraction)
    if (
fraction == 1.0)
        return 
true

    
return false
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 


anakin_cstrike 03-13-2009 06:29

Re: Code to ham or fake until
 
1. Instead of
[pawn]if( fm_is_ent_visible( index, index2 ) )[/pawn]
you can use
Code:
if( ExecuteHam( Ham_FVisible, index, index2 ) )
2. Use pev instead of entity_get_vector

One 03-19-2009 03:59

Re: Code to ham or fake until
 
TY, iŽll try. first i have to finish another plugin.


All times are GMT -4. The time now is 08:52.

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