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

[Help] Don't camp near the bomb


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mirk
Senior Member
Join Date: Nov 2012
Old 11-26-2015 , 03:54   [Help] Don't camp near the bomb
Reply With Quote #1

Hello guys,
Could you help me fix this plugin, please?

Writes that this error:
L 11/26/2015 - 09:48:41: [AMXX] [0] dont_bomb_camp.sma::PlayerPreThink (line 36)
L 11/26/2015 - 09:48:41: [ENGINE] Invalid entity 83
L 11/26/2015 - 09:48:41: [AMXX] Displaying debug trace (plugin "dont_bomb_camp.amxx")

- In the line 36 is code
HTML Code:
entity_get_vector(weapbox, EV_VEC_origin, fOrigin);
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <fakemeta_util>
#include <engine>

#define PLUGIN "Dont Bomb Camp"
#define VERSION "1.1"
#define AUTHOR "naven"

#define FADE_IN            (1<<0)
#define FADE_OUT        (1<<1)
#define FADE_HOLD        (1<<2)
#define FADE_LENGTH_PERM    (1<<0)

new g_msgFade;
new 
CvarDistance;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
g_msgFade get_user_msgid("ScreenFade");
    
    
register_forward(FM_PlayerPreThink"PlayerPreThink");
    
    
CvarDistance register_cvar("gb_distance""300.0")
}

public 
PlayerPreThink(id)
{
    new 
Float:fOrigin[3], FloatfPlayerOrigin[3];
    new 
weapboxbomb fm_find_ent_by_class(-1"weapon_c4");
    if(
bomb && (weapbox pev(bombpev_owner)) > get_maxplayers())
    {
        
entity_get_vector(weapboxEV_VEC_originfOrigin);
        
entity_get_vector(idEV_VEC_originfPlayerOrigin);
        
        if(
get_distance_f(fOriginfPlayerOrigin) < get_pcvar_float(CvarDistance))
        {
            new 
FloatpunishPercentage 1.0;
            new 
duration = (punishPercentage == 1.0) ? FADE_LENGTH_PERM 1<<12;
            new 
holdTime = (punishPercentage == 1.0) ? FADE_LENGTH_PERM 1<<8;
            new 
fadeType = (punishPercentage == 1.0) ? FADE_HOLD FADE_IN;
            new 
blindness 127 floatround(128.0 punishPercentage);
            
            
message_begin(MSG_ONEg_msgFade, {0,0,0}, id);
            
write_short(duration);
            
write_short(holdTime);
            
write_short(fadeType);
            
write_byte(0);
            
write_byte(0);
            
write_byte(0);
            
write_byte(blindness);
            
message_end();
            
            
set_hudmessage(25500, -1.00.2000.10.5__, -1);
            
show_hudmessage(id"Nekempi u bomby!");
        } else {
            
punish_blind_stop(id);
        }
    }
}

public 
punish_blind_stop(id)
{
    
message_begin(MSG_ONEg_msgFade, {0,0,0}, id);
    
write_short(0);
    
write_short(1<<8);
    
write_short(FADE_OUT);
    
write_byte(0);
    
write_byte(0);
    
write_byte(0);
    
write_byte(255);
    
message_end();

Mirk is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 11-26-2015 , 09:28   Re: [Help] Don't camp near the bomb
Reply With Quote #2

check if is a valid entity? pev_valid
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-26-2015 , 12:19   Re: [Help] Don't camp near the bomb
Reply With Quote #3

I made the following changes:
  • Removed PreThink and using a task instead with an interval of 1 second. PreThink was a terrible idea for something like this.
  • Added a pev_valid() check to see if that fixes the error.
  • Made the task only create if the current map has a 'de' prefix (de_dust, de_dust2, etc).
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <engine>

#define MAX_PLAYERS 32

new const Float:CheckInterval 1.0;
new const 
HUDMessage[] = "Nekempi u bomby!";

new 
g_msgFade CvarDistance;

public 
plugin_init()
{
    
register_plugin"Dont Bomb Camp" "1.1b" "naven/bugsy" );
    
    new 
szMap];
    
get_mapnameszMap charsmaxszMap ) );
    
    if ( 
szMap] == 'd' && szMap] == 'e' )
    {
        
g_msgFade get_user_msgid("ScreenFade");
        
CvarDistance register_cvar("gb_distance""300.0");
        
set_taskCheckInterval "BombCheckTask" , .flags="b" );
    }
}

public 
BombCheckTask()
{
    new 
Float:fOrigin] , weapboxbomb id playersList[32] , playersCount;
    
    
bomb fm_find_ent_by_class( -"weapon_c4" );
    
    if ( 
bomb && !( <= ( weapbox pevbomb pev_owner ) ) <= MAX_PLAYERS ) && pev_validweapbox ) )
    {
        
pevweapbox pev_origin fOrigin );

        
playersCount find_sphere_class"player" get_pcvar_floatCvarDistance ) , playersList sizeofplayersList ) , fOrigin );
            
        for ( new 
playersCount i++ )
        {
            
id playersList];
            
            
message_begin(MSG_ONEg_msgFade, {0,0,0}, id);
            
write_short(1<<12);
            
write_shortFixedUnsigned16CheckInterval << 12 ) );
            
write_short(0);
            
write_byte(0);
            
write_byte(0);
            
write_byte(0);
            
write_byte(255);
            
message_end();
            
            
set_hudmessage(25500, -1.00.2000.1CheckInterval__, -1)
            
show_hudmessage(idHUDMessage );
        }
    }
}

FixedUnsigned16(Float:flValueiScale)
{
    new 
iOutput;

    
iOutput floatround(flValue iScale);

    if ( 
iOutput )
        
iOutput 0;

    if ( 
iOutput 0xFFFF )
        
iOutput 0xFFFF;

    return 
iOutput;

__________________

Last edited by Bugsy; 11-26-2015 at 12:44.
Bugsy is offline
Mirk
Senior Member
Join Date: Nov 2012
Old 11-26-2015 , 17:36   Re: [Help] Don't camp near the bomb
Reply With Quote #4

Quote:
Originally Posted by tuty View Post
check if is a valid entity? pev_valid
No, I don't added valid entity, thank you for advise.

Quote:
Originally Posted by Bugsy View Post
I made the following changes:
  • Removed PreThink and using a task instead with an interval of 1 second. PreThink was a terrible idea for something like this.
  • Added a pev_valid() check to see if that fixes the error.
  • Made the task only create if the current map has a 'de' prefix (de_dust, de_dust2, etc).
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <engine>

#define MAX_PLAYERS 32

new const Float:CheckInterval 1.0;
new const 
HUDMessage[] = "Nekempi u bomby!";

new 
g_msgFade CvarDistance;

public 
plugin_init()
{
    
register_plugin"Dont Bomb Camp" "1.1b" "naven/bugsy" );
    
    new 
szMap];
    
get_mapnameszMap charsmaxszMap ) );
    
    if ( 
szMap] == 'd' && szMap] == 'e' )
    {
        
g_msgFade get_user_msgid("ScreenFade");
        
CvarDistance register_cvar("gb_distance""300.0");
        
set_taskCheckInterval "BombCheckTask" , .flags="b" );
    }
}

public 
BombCheckTask()
{
    new 
Float:fOrigin] , weapboxbomb id playersList[32] , playersCount;
    
    
bomb fm_find_ent_by_class( -"weapon_c4" );
    
    if ( 
bomb && !( <= ( weapbox pevbomb pev_owner ) ) <= MAX_PLAYERS ) && pev_validweapbox ) )
    {
        
pevweapbox pev_origin fOrigin );

        
playersCount find_sphere_class"player" get_pcvar_floatCvarDistance ) , playersList sizeofplayersList ) , fOrigin );
            
        for ( new 
playersCount i++ )
        {
            
id playersList];
            
            
message_begin(MSG_ONEg_msgFade, {0,0,0}, id);
            
write_short(1<<12);
            
write_shortFixedUnsigned16CheckInterval << 12 ) );
            
write_short(0);
            
write_byte(0);
            
write_byte(0);
            
write_byte(0);
            
write_byte(255);
            
message_end();
            
            
set_hudmessage(25500, -1.00.2000.1CheckInterval__, -1)
            
show_hudmessage(idHUDMessage );
        }
    }
}

FixedUnsigned16(Float:flValueiScale)
{
    new 
iOutput;

    
iOutput floatround(flValue iScale);

    if ( 
iOutput )
        
iOutput 0;

    if ( 
iOutput 0xFFFF )
        
iOutput 0xFFFF;

    return 
iOutput;

I love you Bugsy It is great code, thank you for helpfulness
Mirk is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 11-27-2015 , 06:57   Re: [Help] Don't camp near the bomb
Reply With Quote #5

Quote:
Originally Posted by Mirk View Post
No, I don't added valid entity, thank you for advise.
what? Bugsy, explain kindly to this lad, what i have just said and what you have done.
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-27-2015 , 11:47   Re: [Help] Don't camp near the bomb
Reply With Quote #6

Quote:
Originally Posted by tuty View Post
check if is a valid entity? pev_valid
Quote:
Originally Posted by Bugsy View Post
I made the following changes:
  • Removed PreThink and using a task instead with an interval of 1 second. PreThink was a terrible idea for something like this.
  • Added a pev_valid() check to see if that fixes the error. <- tuty said to do this, which I did for you.
  • Made the task only create if the current map has a 'de' prefix (de_dust, de_dust2, etc).
Quote:
Originally Posted by Mirk View Post
No, I don't added valid entity, thank you for advise.
Quote:
Originally Posted by tuty View Post
what? Bugsy, explain kindly to this lad, what i have just said and what you have done.
__________________
Bugsy 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 10:37.


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