This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Detect teammate


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SaraAki
Member
Join Date: Nov 2022
Old 04-22-2024 , 16:35   Detect teammate
Reply With Quote #1

PHP Code:
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)
      
    
for(new victim 1victim <= get_maxplayers(); victim++)
    {
        if(!
is_user_alive(victim) || g_effected[victim])
            continue                     
                  
        new 
Float:VictimOrigin[3]
        
pev(victimpev_originVictimOrigin)
                   
        new 
Float:Distance get_distance_f(OriginVictimOrigin)   
                   
        if(
Distance <= RADIUS)
        {
                        
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))
        }
     }
 } 
I want this JumpBombExplode to have an effect only on players from enemy team.It currently affects all players within the radius but how to make it only for enemy?

Last edited by SaraAki; 04-23-2024 at 10:57. Reason: Wrap code with tags [ php] [/ php]
SaraAki is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-22-2024 , 17:21   Re: Detect teammate
Reply With Quote #2

Post the full plugin. We need to see how the attackers player ID can be derived. And please wrap your code with [ php] [/ php] tags
__________________

Last edited by Bugsy; 04-22-2024 at 17:21.
Bugsy is offline
SaraAki
Member
Join Date: Nov 2022
Old 04-23-2024 , 03:55   Re: Detect teammate
Reply With Quote #3

Ok here you go.

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)
      
    
for(new victim 1victim <= get_maxplayers(); victim++)
    {
        if(!
is_user_alive(victim) || g_effected[victim])
            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])               

        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 SaraAki; 04-23-2024 at 03:55.
SaraAki is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 04-23-2024 , 10:05   Re: Detect teammate
Reply With Quote #4

I've got the code but it is not able to be tested until you upload all the custom models.
__________________
DJEarthQuake is offline
SaraAki
Member
Join Date: Nov 2022
Old 04-23-2024 , 10:46   Re: Detect teammate
Reply With Quote #5

Can you please just edit sma,instead of that sprites and models add default names.I dont know how to add that on this forum/site but i will try,but already tried.

Last edited by SaraAki; 04-23-2024 at 10:49.
SaraAki is offline
v120kaaimcfg
New Member
Join Date: Apr 2024
Old 04-23-2024 , 12:06   Re: Detect teammate
Reply With Quote #6

Quote:
Originally Posted by SaraAki View Post
Can you please just edit sma,instead of that sprites and models add default names.I dont know how to add that on this forum/site but i will try,but already tried.
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)

    
new nadeowner pev(Entitypev_owner)
    new 
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])               

        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()

v120kaaimcfg is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 04-23-2024 , 13:32   Re: Detect teammate
Reply With Quote #7

Quote:
Originally Posted by SaraAki View Post
Can you please just edit sma,instead of that sprites and models add default names.I dont know how to add that on this forum/site but i will try,but already tried.
It would help if you could turn up the originals. Models and sprites set to stock ones.

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)

#if !defined MaxClients
static MaxClients
#endif

//#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"
}
*/
static const BOMB_MODEL[][] = 
{
    
"models/v_hegrenade_uGamers.mdl",
    
"models/p_hegrenade_uGamers.mdl",
    
"models/w_hegrenade_uGamers.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")
    
g_spr_rustler precache_model("sprites/effects/snowflake.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")
    
#if !defined MaxClients
    
MaxClients get_maxplayers()
    
#endif
    
}

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
}

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

public 
event_new_round()
{   
   
g_roundend false

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

public 
round_end()
{
    
g_roundend true

    
static id;
    for(
id id <= MaxClients 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)
    
    static 
iOwneriOwner pev(Entitypev_owner)
    static 
iOwnerTeamiOwnerTeam get_user_team(iOwner)
                  
           
    
//emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
      
    
for(new victim 1victim <= MaxClientsvictim++)
    {
        if(!
is_user_alive(victim) || g_effected[victim])
            continue

        static 
iOwnerTeamateiOwnerTeamate =(get_user_team(victim))
        if(
iOwnerTeamate == iOwnerTeam)
            return

        
server_print "Affected %N"victim
                  
        
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])               

        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()

Attached Files
File Type: zip grenade_models.zip (193.3 KB, 11 views)
__________________

Last edited by DJEarthQuake; 04-23-2024 at 13:45. Reason: Thought they were stock!
DJEarthQuake is offline
SaraAki
Member
Join Date: Nov 2022
Old 04-23-2024 , 14:12   Re: Detect teammate
Reply With Quote #8

---v120kaaimcfg in your version nothing has changed.

---DJEarthQuake in your version nothing happens,the effect does not affect anyone.
SaraAki is offline
Tote
Senior Member
Join Date: Jul 2023
Old 04-23-2024 , 15:14   Re: Detect teammate
Reply With Quote #9

Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <fun>
#include <cstrike>

new MsgScreenShake 
new exploSpr
new g_effected[33]
new bool: g_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 Float: RADIUS = 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_rustler, bool:using_rustler[33], msgScreenFade, amx_kill_fade_amount

public plugin_precache() 
{
static i

for(i = 0; i < sizeof BOMB_MODEL; i++)
	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_Deploy, WEAPON_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_used, not_used2, not_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(id, atk, gibs)
{
	if(using_rustler[id] && is_user_connected(id))
	{
		using_rustler[id] = false
	}
}

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

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

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

public round_end()
{
	g_roundend = true
	
	static id;
	for(id = 1 ; 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, 1 << 12)
	new Freq = UTIL_FixedUnsigned16(0.7 , 1 << 8)
	new Ampl = UTIL_FixedUnsigned16(20.0, 1 << 12)
	
	message_begin(MSG_ONE_UNRELIABLE , MsgScreenShake , {0,0,0} ,id)
	write_short( Ampl ) // --| Shake amount.
	write_short( Dura ) // --| Shake lasts this long.
	write_short( Freq ) // --| Shake noise frequency.
	message_end ()       
}

rustler_sprite(id)
{
if(!is_user_alive(id)) return;

static origin[3]
get_user_origin(id, origin)

message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
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_Time, Float: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(entity, CHAN_STATIC, FLASH_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
	
	
	return FMRES_IGNORED
}

public JumpBombExplode(Entity)
{       
	
	if(Entity < 0)
		return PLUGIN_HANDLED;
	
	if(g_roundend)
		return PLUGIN_HANDLED;
	
	static Float:Origin[3]
	pev(Entity, pev_origin, Origin)
	
	//emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	static iOwner; iOwner = pev(Entity, pev_owner)
	static iOwnerTeam; iOwnerTeam = get_user_team(iOwner)
	
	for(new victim = 1; victim <= get_maxplayers(); victim++)
	{
		if(!is_user_alive(victim) || g_effected[victim])
			continue;
			
		static victimteam; victimteam = get_user_team(victim)
		
		if(iOwnerTeam == victimteam) {
			return FMRES_SUPERCEDE;
		}
		
		
		new Float:VictimOrigin[3]
		pev(victim, pev_origin, VictimOrigin)
		
		new Float:Distance = get_distance_f(Origin, VictimOrigin)   
		
		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(victim, pev_punchangle, Float:{125.0, 125.0, 125.0})
			set_task(3.0, "Shake", victim)
			g_effected[victim] = 1
			client_cmd(victim, "spk %s", grenadeeffect)
			using_rustler[victim] = true
			fadegreen(victim, get_pcvar_num(amx_kill_fade_amount))
		}
	}
	return FMRES_IGNORED
} 

UTIL_FixedUnsigned16 ( const Float:Value, const Scale ) {
	return clamp( floatround( Value * Scale ), 0, 0xFFFF );
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float: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(entity, 41, 4)
	
	if(!is_user_alive(id))
		return PLUGIN_CONTINUE
	
	set_pev(id, pev_viewmodel2, BOMB_MODEL[0])
	set_pev(id, pev_weaponmodel2, BOMB_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(Entity, pev_dmgtime) == 0.0)
		return FMRES_IGNORED
	
	new iOwner = pev(Entity, pev_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(Entity, pev_body, 23)        
		
		engfunc(EngFunc_SetModel, Entity, BOMB_MODEL[2])               
		
		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(id, amount)
{    
//FADE OUT FROM GREEN
if (amount > 255)
	amount = 255
	
	message_begin(MSG_ONE_UNRELIABLE, msgScreenFade, {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()
}
Tote is offline
v120kaaimcfg
New 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
Reply



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 11:28.


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