Raised This Month: $ Target: $400
 0% 

[Help] Don't camp near the bomb


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 06:18.


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