AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invis plugin modify. (https://forums.alliedmods.net/showthread.php?t=128078)

SlayeR 05-28-2010 15:31

Invis plugin modify.
 
Hi I got this plugin and I have question. Is possible to remove pragma semicolon and change ( plr ) to (id)? Can someone help?
PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#pragma semicolon 1

#define MAX_ENTITYS 900+15*32 // (900+15*SERVER_SLOTS) is the calculation cs uses but it can be bypassed by the "-num_edicts <x>"-parameter

new bool:g_bPlayerInvisible[33];
new 
bool:g_bWaterInvisible[33];

new 
bool:g_bWaterEntity[MAX_ENTITYS];
new 
bool:g_bWaterFound;

new 
g_iSpectatedId[33];

public 
plugin_init( )
{
    
register_plugin"Invis""2.0""SchlumPF" );
    
    
register_clcmd"say /invis""menuInvisDisplay" );
    
register_menucmdregister_menuid"\rInvisibility - SchlumPF^n^n" ), 1023"menuInvisAction" );
    
    
register_forwardFM_AddToFullPack"fwdAddToFullPack_Post");
    
RegisterHamHam_Spawn"player""hamSpawnPlayer_Post");
    
    
register_event"SpecHealth2""eventSpecHealth2""bd" );
}

public 
plugin_cfg( )
{
    
// precache in a boolean variable whether an entity is func_water or not.
    // this will save a lot performance since AddToFullPack is called very often.
    // i could set the ents iuser variable to avoid using such a huge variable
    // and problems with the "-num_edicts" parameter but this is a lot faster
    // than retrieving pev_iuser in AddToFullPack. another way would have been
    // using a binary system to store the data in less than a huge array but in
    // fact a huge array takes a few kb ram which is for me less than a constant
    // usage of the cpu since i would need to use a few operators to read the data
    // out of the bianry system. all in all a binary storing system is at least a good
    // alternative which some iuser variable of the private ent values (pev) would not be.
    
    
new ent = -1;
    while( ( 
ent find_ent_by_classent"func_water" ) ) != )
    {
        
// pev( ent, pev_skin ) ==  CONTENTS_WATER is also true on func_water entities
        
        
if( !g_bWaterFound )
        {
            
g_bWaterFound true;
        }

        
g_bWaterEntity[ent] = true;
    }
    
    
// thanks to connor for finding the following two detections
    
ent = -1;
    while( ( 
ent find_ent_by_classent"func_illusionary" ) ) != )
    {
        if( 
peventpev_skin ) ==  CONTENTS_WATER )
        {
            if( !
g_bWaterFound )
            {
                
g_bWaterFound true;
            }
    
            
g_bWaterEntity[ent] = true;
        }
    }
    
    
ent = -1;
    while( ( 
ent find_ent_by_classent"func_conveyor" ) ) != )
    {
        if( 
peventpev_spawnflags ) == )
        {
            if( !
g_bWaterFound )
            {
                
g_bWaterFound true;
            }
    
            
g_bWaterEntity[ent] = true;
        }
    }
}

public 
fwdAddToFullPack_Postes_handleeenthosthostflagsplayerpset )
{
    if( 
player && g_bPlayerInvisible[host] && host != ent && ent != g_iSpectatedId[host] )
    {
        static const 
Float:corner[8][3] = 
        {
            { -
4096.0, -4096.0, -4096.0 },
            { -
4096.0, -4096.04096.0 },
            { -
4096.04096.0, -4096.0 },
            { -
4096.04096.04096.0 },
            { 
4096.0, -4096.0, -4096.0 },
            { 
4096.0, -4096.04096.0 },
            { 
4096.04096.0, -4096.0 },
            { 
4096.04096.04096.0 }
        };
        
        
// rounded; distance from the map's center to the corners; sqrt( 4096^2 + 4096^2 + 4096^2 )
        
static const Float:map_distance 7094.480108;
        
        static 
Float:origin[3];
        
get_eses_handleES_Originorigin );
        
        static 
i;
        while( 
get_distance_forigincorner[i] ) > map_distance )
        { 
            if( ++
>= sizeofcorner ) )
            {
                
// better to nullify the varibale now then doing it each time before the loop
                
0;
            }
        }
        
        
set_eses_handleES_Origincorner[i] );
        
set_eses_handleES_Effectsget_eses_handleES_Effects ) | EF_NODRAW );
    }
    else if( 
g_bWaterInvisible[host] && g_bWaterEntity[ent])
    {
        
set_eses_handleES_Effectsget_eses_handleES_Effects ) | EF_NODRAW );
    }
}

public 
hamSpawnPlayer_Postplr )
{
    
g_iSpectatedId[plr] = 0;
}

// thanks to xPaw who told me about this event
public eventSpecHealth2plr )
{
    
g_iSpectatedId[plr] = read_data);
}

public 
menuInvisDisplayplr )
{
    static 
menu[256];

    new 
len formatexmenu255"\rInvisibility - SchlumPF^n^n" );
    
    
len += formatexmenu[len], 255 len"\r1. \wPlayers: %s^n"g_bPlayerInvisible[plr] ? "invisible" "visible" );
    
    if( 
g_bWaterFound )
    {
        
len += formatexmenu[len], 255 len"\r2. \wWater: %s^n"g_bWaterInvisible[plr] ? "invisible" "visible" );
    }
     
//else
    //{
    //    len += formatex( menu[len], 255 - len, "\r2. \wWater: There is no water on this map!^n" );
    //}

    
len += formatexmenu[len], 255 len"^n\r0. \wExit" );
    
    
show_menuplr, ( 1<<1<<1<<), menu, -);
        
    return 
PLUGIN_HANDLED;
}

public 
menuInvisActionplrkey )
{
    switch( 
key )
    {
        case 
0:
        {
            
g_bPlayerInvisible[plr] = !g_bPlayerInvisible[plr];
            
menuInvisDisplayplr );
        }
        case 
1:
        {
            if( 
g_bWaterFound )
            {
                
g_bWaterInvisible[plr] = !g_bWaterInvisible[plr];
            }
            
            
menuInvisDisplayplr );
        }
        case 
9show_menuplr0"" );
    }
}

public 
client_connectplr )
{
    
g_bPlayerInvisible[plr] = false;
    
g_bWaterInvisible[plr] = false;
    
g_iSpectatedId[plr] = 0;



unnyquee 05-28-2010 15:41

Re: Invis plugin modify.
 
PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#define MAX_ENTITYS 900+15*32 // (900+15*SERVER_SLOTS) is the calculation cs uses but it can be bypassed by the "-num_edicts <x>"-parameter

new bool:g_bPlayerInvisible[33];
new 
bool:g_bWaterInvisible[33];

new 
bool:g_bWaterEntity[MAX_ENTITYS];
new 
bool:g_bWaterFound;

new 
g_iSpectatedId[33];

public 
plugin_init( )
{
    
register_plugin"Invis""2.0""SchlumPF" );
    
    
register_clcmd"say /invis""menuInvisDisplay" );
    
register_menucmdregister_menuid"\rInvisibility - SchlumPF^n^n" ), 1023"menuInvisAction" );
    
    
register_forwardFM_AddToFullPack"fwdAddToFullPack_Post");
    
RegisterHamHam_Spawn"player""hamSpawnPlayer_Post");
    
    
register_event"SpecHealth2""eventSpecHealth2""bd" );
}

public 
plugin_cfg( )
{
    
// precache in a boolean variable whether an entity is func_water or not.
    // this will save a lot performance since AddToFullPack is called very often.
    // i could set the ents iuser variable to avoid using such a huge variable
    // and problems with the "-num_edicts" parameter but this is a lot faster
    // than retrieving pev_iuser in AddToFullPack. another way would have been
    // using a binary system to store the data in less than a huge array but in
    // fact a huge array takes a few kb ram which is for me less than a constant
    // usage of the cpu since i would need to use a few operators to read the data
    // out of the bianry system. all in all a binary storing system is at least a good
    // alternative which some iuser variable of the private ent values (pev) would not be.
    
    
new ent = -1;
    while( ( 
ent find_ent_by_classent"func_water" ) ) != )
    {
        
// pev( ent, pev_skin ) ==  CONTENTS_WATER is also true on func_water entities
        
        
if( !g_bWaterFound )
        {
            
g_bWaterFound true;
        }

        
g_bWaterEntity[ent] = true;
    }
    
    
// thanks to connor for finding the following two detections
    
ent = -1;
    while( ( 
ent find_ent_by_classent"func_illusionary" ) ) != )
    {
        if( 
peventpev_skin ) ==  CONTENTS_WATER )
        {
            if( !
g_bWaterFound )
            {
                
g_bWaterFound true;
            }
    
            
g_bWaterEntity[ent] = true;
        }
    }
    
    
ent = -1;
    while( ( 
ent find_ent_by_classent"func_conveyor" ) ) != )
    {
        if( 
peventpev_spawnflags ) == )
        {
            if( !
g_bWaterFound )
            {
                
g_bWaterFound true;
            }
    
            
g_bWaterEntity[ent] = true;
        }
    }
}

public 
fwdAddToFullPack_Postes_handleeenthosthostflagsplayerpset )
{
    if( 
player && g_bPlayerInvisible[host] && host != ent && ent != g_iSpectatedId[host] )
    {
        static const 
Float:corner[8][3] = 
        {
            { -
4096.0, -4096.0, -4096.0 },
            { -
4096.0, -4096.04096.0 },
            { -
4096.04096.0, -4096.0 },
            { -
4096.04096.04096.0 },
            { 
4096.0, -4096.0, -4096.0 },
            { 
4096.0, -4096.04096.0 },
            { 
4096.04096.0, -4096.0 },
            { 
4096.04096.04096.0 }
        };
        
        
// rounded; distance from the map's center to the corners; sqrt( 4096^2 + 4096^2 + 4096^2 )
        
static const Float:map_distance 7094.480108;
        
        static 
Float:origin[3];
        
get_eses_handleES_Originorigin );
        
        static 
i;
        while( 
get_distance_forigincorner[i] ) > map_distance )
        { 
            if( ++
>= sizeofcorner ) )
            {
                
// better to nullify the varibale now then doing it each time before the loop
                
0;
            }
        }
        
        
set_eses_handleES_Origincorner[i] );
        
set_eses_handleES_Effectsget_eses_handleES_Effects ) | EF_NODRAW );
    }
    else if( 
g_bWaterInvisible[host] && g_bWaterEntity[ent])
    {
        
set_eses_handleES_Effectsget_eses_handleES_Effects ) | EF_NODRAW );
    }
}

public 
hamSpawnPlayer_Postid )
{
    
g_iSpectatedId[id] = 0;
}

// thanks to xPaw who told me about this event
public eventSpecHealth2id )
{
    
g_iSpectatedId[id] = read_data);
}

public 
menuInvisDisplayid )
{
    static 
menu[256];

    new 
len formatexmenu255"\rInvisibility - SchlumPF^n^n" );
    
    
len += formatexmenu[len], 255 len"\r1. \wPlayers: %s^n"g_bPlayerInvisible[id] ? "invisible" "visible" );
    
    if( 
g_bWaterFound )
    {
        
len += formatexmenu[len], 255 len"\r2. \wWater: %s^n"g_bWaterInvisible[id] ? "invisible" "visible" );
    }
     
//else
    //{
    //    len += formatex( menu[len], 255 - len, "\r2. \wWater: There is no water on this map!^n" );
    //}

    
len += formatexmenu[len], 255 len"^n\r0. \wExit" );
    
    
show_menuid, ( 1<<1<<1<<), menu, -);
        
    return 
PLUGIN_HANDLED;
}

public 
menuInvisActionidkey )
{
    switch( 
key )
    {
        case 
0:
        {
            
g_bPlayerInvisible[id] = !g_bPlayerInvisible[id];
            
menuInvisDisplayid );
        }
        case 
1:
        {
            if( 
g_bWaterFound )
            {
                
g_bWaterInvisible[id] = !g_bWaterInvisible[id];
            }
            
            
menuInvisDisplayid );
        }
        case 
9show_menuid0"" );
    }
}

public 
client_connectid )
{
    
g_bPlayerInvisible[id] = false;
    
g_bWaterInvisible[id] = false;
    
g_iSpectatedId[id] = 0;




All times are GMT -4. The time now is 05:25.

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