Thread: Detect teammate
View Single Post
v120kaaimcfg
Member
Join Date: Apr 2024
Old 04-23-2024 , 15:27   Re: Detect teammate
Reply With Quote #10

Quote:
Originally Posted by SaraAki View Post
---v120kaaimcfg in your version nothing has changed.

---DJEarthQuake in your version nothing happens,the effect does not affect anyone.
Fixed:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <fun>
#include <cstrike>

new MsgScreenShake 
new exploSpr
new g_effected[33]
new 
boolg_roundend

#define grenadeeffect "items/blastgrenade_hit.wav"

#define message_begin_fl(%1,%2,%3,%4) engfunc(EngFunc_MessageBegin, %1, %2, %3, %4)
#define write_coord_fl(%1) engfunc(EngFunc_WriteCoord, %1)

//#define RADIUS 189.0
const FloatRADIUS 189.0  
#define JUMP_EXP 199.0
#define WEAPON_DEFAULT "weapon_flashbang"

new const SPRITE_EXPLO[] = "sprites/shockwave.spr";

new const 
FLASH_SOUND[] = "items/blastbomb_explode.wav"

new const BOMB_MODEL[][] = 
{
    
"models/v_cs_fun_blast.mdl",
    
"models/p_cs_fun_blast.mdl",
    
"models/w_cs_fun_blast.mdl"
}

new 
g_spr_rustlerbool:using_rustler[33], msgScreenFadeamx_kill_fade_amount

public plugin_precache() 
{
        static 
i

    
for(0sizeof BOMB_MODELi++)
        
precache_model(BOMB_MODEL[i])

        
precache_sound(FLASH_SOUND)

        
exploSpr precache_model(SPRITE_EXPLO)
        
precache_sound(grenadeeffect)

        
g_spr_rustler precache_model("sprites/effects/rotating_star.spr")
}

public 
plugin_init()
{
    
register_plugin("Jump Grenade""1.0""NoPanicXxX")
    
    
register_forward(FM_EmitSound,"fw_emitsound")
    
    
MsgScreenShake get_user_msgid("ScreenShake")

        
RegisterHam(Ham_Item_DeployWEAPON_DEFAULT"DeployPost"1)
        
register_forward(FM_SetModel"fw_SetModel")
        
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)

        
register_event ("HLTV""event_new_round""a""1=0""2=0")
        
register_logevent("round_end"2"1=Round_End")

        
RegisterHam(Ham_Killed"player""OnKilled"1)

        
register_message(get_user_msgid("ScreenFade"), "Message_ScreenFade")
        
        
// Screenfade 
        
msgScreenFade get_user_msgid("ScreenFade")
        
amx_kill_fade_amount register_cvar("amx_kill_fade_amount""240")
}

public 
Message_ScreenFade(not_usednot_used2not_used3)
{
    if( 
get_msg_arg_int(4) != 255 || get_msg_arg_int(5) != 255 || get_msg_arg_int(6) != 255 )
        return 
PLUGIN_CONTINUE
    
    
static iAlpha
    iAlpha 
get_msg_arg_int(7)
    if(
iAlpha != 200 && iAlpha != 255)
        return 
PLUGIN_CONTINUE

    
return PLUGIN_HANDLED


public 
OnKilled(idatkgibs)
{
        if(
using_rustler[id] && is_user_connected(id))
        {
                
using_rustler[id] = false
        
}
}

public 
client_putinserver(id)
{
        
using_rustler[id] = false
}

public 
client_disconnect(id)
{
        
using_rustler[id] = false
}

public 
event_new_round()
{   
   
g_roundend false

   
static id;
   for(
id id <= get_maxplayers() ; id++)
   {
        
using_rustler[id] = false
   
}
}

public 
round_end()
{
    
g_roundend true

    
static id;
    for(
id id <= get_maxplayers() ; id++)
    {
        
using_rustler[id] = false
    
}
}

public 
fw_PlayerSpawn_Post(id)
{    
     if(
g_effected[id] && is_user_connected(id)) 
     {
     
g_effected[id] = 0
     
}
}

public 
Shake(id)
{
    if(!
is_user_alive(id))
        return

    if(
g_roundend)
        return

    
g_effected[id] = 0

    using_rustler
[id] = false

    
new Dura UTIL_FixedUnsigned16(4.0<< 12)
    new 
Freq UTIL_FixedUnsigned16(0.7 << 8)
    new 
Ampl UTIL_FixedUnsigned16(20.0<< 12)
    
    
message_begin(MSG_ONE_UNRELIABLE MsgScreenShake , {0,0,0} ,id)
    
write_shortAmpl // --| Shake amount.
    
write_shortDura // --| Shake lasts this long.
    
write_shortFreq // --| Shake noise frequency.
    
message_end ()       
}

rustler_sprite(id)
{
    if(!
is_user_alive(id)) return;
    
    static 
origin[3]
    
get_user_origin(idorigin)
    
    
message_begin(MSG_PVSSVC_TEMPENTITYorigin)
    
write_byte(TE_SPRITE)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2]+52)
    
write_short(g_spr_rustler)
    
write_byte(2)
    
write_byte(240)
    
message_end()
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id))
        return
        
    static 
Float:Rustler_TimeFloat:Rustler_hud_delay[33]
    
    
Rustler_Time get_gametime()
    
    if(
Rustler_Time 0.5 Rustler_hud_delay[id])
    {
        if(
using_rustler[id]) rustler_sprite(id)
        
        
Rustler_hud_delay[id] = Rustler_Time
    
}
}

public 
fw_emitsound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch)
{
    
// not a flashbang exploding
    
if(!equali(sample,"weapons/flashbang-1.wav") && !equali(sample,"weapons/flashbang-2.wav"))
        return 
FMRES_IGNORED

    create_blast
(entity)      
    
JumpBombExplode(entity)
    
emit_sound(entityCHAN_STATICFLASH_SOUNDVOL_NORMATTN_NORM0PITCH_NORM )
                
    
    return 
FMRES_IGNORED
}

public 
JumpBombExplode(Entity)
{       

    if(
Entity 0)
        return

    if(
g_roundend)
        return

    static 
Float:Origin[3]
    
pev(Entitypev_originOrigin)
                  
           
    
//emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

    
static nadeownernadeownerteam
    nadeowner 
pev(Entitypev_iuser1)
    
nadeownerteam get_user_team(nadeowner)

    for(new 
victim 1victim <= get_maxplayers(); victim++)
    {
        if(!
is_user_alive(victim) || g_effected[victim] || get_user_team(victim) == nadeownerteam)
            continue                     
                  
        new 
Float:VictimOrigin[3]
        
pev(victimpev_originVictimOrigin)

        new 
Float:Distance get_distance_f(OriginVictimOrigin)   
                   
        if(
Distance <= RADIUS)
        {
            
//static Float:NewSpeed

            //NewSpeed = JUMP_EXP * (1.0 - (Distance / RADIUS))

                        //NewSpeed = JUMP_EXP * 5
                           
            //static Float:Velocity[3]
            //get_speed_vector(Origin, VictimOrigin, NewSpeed, Velocity)
                           
            //set_pev(victim, pev_velocity, Velocity)

                        
set_pev(victimpev_punchangleFloat:{125.0125.0125.0})
                        
set_task(3.0"Shake"victim)
                        
g_effected[victim] = 1
                        client_cmd
(victim"spk %s"grenadeeffect)
                        
using_rustler[victim] = true
                        fadegreen
(victimget_pcvar_num(amx_kill_fade_amount))
        }
     }


UTIL_FixedUnsigned16 ( const Float:Value, const Scale ) {
    return 
clampfloatroundValue Scale ), 00xFFFF );
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speedFloat:new_velocity[3])
{
    
new_velocity[0] = origin2[0] - origin1[0]
    
new_velocity[1] = origin2[1] - origin1[1]
    
new_velocity[2] = origin2[2] - origin1[2]
    new 
Float:num floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    
new_velocity[0] *= num
    new_velocity
[1] *= num
    new_velocity
[2] *= num

    
return 1
}

public 
DeployPost(entity)
{
    static 
id
    id 
get_pdata_cbase(entity414)

    if(!
is_user_alive(id))
        return 
PLUGIN_CONTINUE

    set_pev
(idpev_viewmodel2BOMB_MODEL[0])
    
set_pev(idpev_weaponmodel2BOMB_MODEL[1])
        
//client_print(id, print_center, "Blast Grenade")

    
return PLUGIN_CONTINUE
}

public 
fw_SetModel(Entity, const Model[])
{
    if(
Entity 0)
        return 
FMRES_IGNORED

    
if(pev(Entitypev_dmgtime) == 0.0)
        return 
FMRES_IGNORED

    
new iOwner pev(Entitypev_owner)
 
    if(!
is_user_connected(iOwner)) return FMRES_IGNORED

        
/*static model[32];
    pev(ent, pev_model, model, 31)*/
           
    
if(equal(Model"models/w_flashbang.mdl"))
    {
        
set_pev(Entitypev_body23)        

        
engfunc(EngFunc_SetModelEntityBOMB_MODEL[2])
        
set_pev(Entitypev_iuser1pev(Entitypev_owner))
        return 
FMRES_SUPERCEDE    
    
}
    return 
FMRES_IGNORED
}

// make the explosion effects
create_blast(entity)

    new 
Float:origin[3]
    
pev(entity,pev_origin,origin)

    
// smallest ring
    
message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
    
write_byte(TE_BEAMCYLINDER);
    
write_coord_fl(origin[0]); // x
    
write_coord_fl(origin[1]); // y
    
write_coord_fl(origin[2]); // z
    
write_coord_fl(origin[0]); // x axis
    
write_coord_fl(origin[1]); // y axis
    
write_coord_fl(origin[2] + 385.0); // z axis
    
write_short(exploSpr); // sprite
    
write_byte(0); // start frame
    
write_byte(0); // framerate
    
write_byte(4); // life
    
write_byte(60); // width
    
write_byte(0); // noise
    
write_byte(31); // red
    
write_byte(255); // green
    
write_byte(127); // blue
    
write_byte(100); // brightness
    
write_byte(0); // speed
    
message_end();

    
// medium ring
    
message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
    
write_byte(TE_BEAMCYLINDER);
    
write_coord_fl(origin[0]); // x
    
write_coord_fl(origin[1]); // y
    
write_coord_fl(origin[2]); // z
    
write_coord_fl(origin[0]); // x axis
    
write_coord_fl(origin[1]); // y axis
    
write_coord_fl(origin[2] + 470.0); // z axis
    
write_short(exploSpr); // sprite
    
write_byte(0); // start frame
    
write_byte(0); // framerate
    
write_byte(4); // life
    
write_byte(60); // width
    
write_byte(0); // noise
    
write_byte(31); // red
    
write_byte(255); // green
    
write_byte(127); // blue
    
write_byte(100); // brightness
    
write_byte(0); // speed
    
message_end();

    
// largest ring
    
message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0);
    
write_byte(TE_BEAMCYLINDER);
    
write_coord_fl(origin[0]); // x
    
write_coord_fl(origin[1]); // y
    
write_coord_fl(origin[2]); // z
    
write_coord_fl(origin[0]); // x axis
    
write_coord_fl(origin[1]); // y axis
    
write_coord_fl(origin[2] + 555.0); // z axis
    
write_short(exploSpr); // sprite
    
write_byte(0); // start frame
    
write_byte(0); // framerate
    
write_byte(4); // life
    
write_byte(60); // width
    
write_byte(0); // noise
    
write_byte(31); // red
    
write_byte(255); // green
    
write_byte(127); // blue
    
write_byte(100); // brightness
    
write_byte(0); // speed
    
message_end();

    
/*// light effect
    message_begin_fl(MSG_PAS,SVC_TEMPENTITY,origin,0);
    write_byte(TE_DLIGHT);
    write_coord_fl(origin[0]); // x
    write_coord_fl(origin[1]); // y
    write_coord_fl(origin[2]); // z
    write_byte(50); // radius
    write_byte(31); // red
    write_byte(255); // green
    write_byte(127); // blue
    write_byte(8); // life
    write_byte(60); // decay rate
    message_end();*/      
}

stock fadegreen(idamount)
{    
    
//FADE OUT FROM GREEN
    
if (amount 255)
        
amount 255
    
    message_begin
(MSG_ONE_UNRELIABLEmsgScreenFade, {0,0,0}, id)
    
write_short(amount 100)    //Durration
    
write_short(0)        //Hold
    
write_short(0)        //Type
    
write_byte(0)    //R
    
write_byte(150)    //G
    
write_byte(0)    //B
    
write_byte(amount)    //B
    
message_end()


Last edited by v120kaaimcfg; 04-23-2024 at 15:28.
v120kaaimcfg is offline