AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Set es problem (https://forums.alliedmods.net/showthread.php?t=173584)

HoLLyWooD 12-07-2011 12:26

Set es problem
 
i want create plugin with addtofullpack
If show cvar enabled player can show entities

BUt dont work
set_es(es, ES_Effects, get_es(es, ES_Effects) & ~EF_NODRAW);

code:
Code:

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0.0"
#define AUTHOR "HoLLyWooD"

#define smodel                "models/winebottle.mdl"
#define ent_class        "present_spawn_point"

new bool:show = false;

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR);
       
        register_forward(FM_AddToFullPack, "addToFullPackPre", 0);
       
        register_clcmd("say new_ent", "create_ent");
        register_clcmd("say show_ent", "cmd_show");
}

public plugin_precache()
        precache_model(smodel);

public cmd_show(id){
        show = (show) ? false : true;
        client_print(id, print_chat, (show) ? "You can show entities" : "You can`t show entities");
}

public create_ent(id){
        new Float:origin[3], ent, classname[32], bool:is_ent = false;
        entity_get_vector(id, EV_VEC_origin, origin);
       
        while( (ent = find_ent_in_sphere(ent, origin, 100.0)) != 0 ){
                entity_get_string(ent,EV_SZ_classname,classname,charsmax(classname));
               
                if(equali(classname,ent_class)){
                        is_ent = true;
                        break;
                }
        }
       
        if(is_ent){
                client_print(id, print_center, "Some entity is in 100 radius");
                return;
        }
       
        ent = create_entity("info_target");
        entity_set_string(ent,EV_SZ_classname, ent_class);
        entity_set_model(ent,smodel);
        entity_get_vector(id, EV_VEC_origin, origin);
        entity_set_origin(ent,origin);
        entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER);
        set_rendering(ent, kRenderFxGlowShell, 0,255, 0, kRenderNormal, 16 );
        entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
        drop_to_floor(ent);
       
        client_print(id, print_chat, "Invisible entity created!");
}

public addToFullPackPre(es, e, ent, host, hostflags, player, pSet){
        if(!show || !is_valid_ent(ent))
                return FMRES_IGNORED;
       
        new classname[32];
        entity_get_string(ent, EV_SZ_classname, classname, 31);
               
        if(equali(classname, ent_class))
                set_es(es, ES_Effects, get_es(es, ES_Effects) & ~EF_NODRAW);
               
        return FMRES_IGNORED;
}


ConnorMcLeod 12-07-2011 12:40

Re: Set es problem
 
Either you register the forward as post and you set es effect like you tried, either you let it as pre and you only have to supercede it.

HoLLyWooD 12-07-2011 14:04

Re: Set es problem
 
Code:

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0.0"
#define AUTHOR "HoLLyWooD"

#define smodel                "models/winebottle.mdl"
#define ent_class        "present_spawn_point"

new bool:show = false;

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR);
       
        register_forward(FM_AddToFullPack, "addToFullPackPre", 0);
       
        register_clcmd("say new_ent", "create_ent");
        register_clcmd("say show_ent", "cmd_show");
}

public plugin_precache()
        precache_model(smodel);

public cmd_show(id){
        show = (show) ? false : true;
        client_print(id, print_chat, (show) ? "You can show entities" : "You can`t show entities");
}

public create_ent(id){
        new Float:origin[3], ent, classname[32], bool:is_ent = false;
        entity_get_vector(id, EV_VEC_origin, origin);
       
        while( (ent = find_ent_in_sphere(ent, origin, 100.0)) != 0 ){
                entity_get_string(ent,EV_SZ_classname,classname,charsmax(classname));
               
                if(equali(classname,ent_class)){
                        is_ent = true;
                        break;
                }
        }
       
        if(is_ent){
                client_print(id, print_center, "Some entity is in 100 radius");
                return;
        }
       
        ent = create_entity("info_target");
        entity_set_string(ent,EV_SZ_classname, ent_class);
        entity_set_model(ent,smodel);
        entity_get_vector(id, EV_VEC_origin, origin);
        entity_set_origin(ent,origin);
        entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER);
        set_rendering(ent, kRenderFxGlowShell, 0,255, 0, kRenderNormal, 16 );
        entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
        drop_to_floor(ent);
       
        client_print(id, print_chat, "Invisible entity created!");
}

public addToFullPackPre(es, e, ent, host, hostflags, player, pSet){
        if(!show || !is_valid_ent(ent))
                return FMRES_IGNORED;
       
        new classname[32];
        entity_get_string(ent, EV_SZ_classname, classname, 31);
               
        if(equali(classname, ent_class)){
                set_es(es, ES_Effects, get_es(es, ES_Effects) & ~EF_NODRAW);
                return FMRES_SUPERCEDE;
        }
               
        return FMRES_IGNORED;
}

dont work

HoLLyWooD 12-08-2011 03:44

Re: Set es problem
 
i try create invisible entity with modelindex - but isn`t work

PHP Code:

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0.0"
#define AUTHOR "HoLLyWooD"

#define smodel         "models/winebottle.mdl"
#define ent_class     "present_spawn_point"

new bool:show false;
new 
modelindex;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_forward(FM_AddToFullPack"addToFullPackPre"0);
    
    
register_clcmd("say new""create_ent");
    
register_clcmd("say show""cmd_show");
}

public 
plugin_precache()
    
modelindex engfunc(EngFunc_PrecacheModelsmodel);
    
//precache_model(smodel);

public cmd_show(id){
    
show = (show) ? false true;
    
client_print(idprint_chat, (show) ? "You can show entities" "You can`t show entities");
}

public 
create_ent(id){
    new 
Float:origin[3], entclassname[32], bool:is_ent false;
    
entity_get_vector(idEV_VEC_originorigin);
    
    while( (
ent find_ent_in_sphere(entorigin100.0)) != ){
        
entity_get_string(ent,EV_SZ_classname,classname,charsmax(classname));
        
        if(
equali(classname,ent_class)){
            
is_ent true;
            break;
        }
    }
    
    if(
is_ent){
        
client_print(idprint_center"Some entity is in 100 radius");
        return;
    }
    
    
ent create_entity("info_target");
    
entity_set_string(ent,EV_SZ_classnameent_class);
    
//entity_set_int(ent, EV_INT_modelindex, modelindex);
    //entity_set_model(ent,smodel);
    
entity_get_vector(idEV_VEC_originorigin);
    
entity_set_origin(ent,origin);
    
entity_set_int(entEV_INT_solidSOLID_TRIGGER);
    
set_rendering(entkRenderFxGlowShell0,2550kRenderNormal16 );
    
//entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
    
drop_to_floor(ent);
    
    
client_print(idprint_chat"Invisible entity created!");
}

public 
addToFullPackPre(eseenthosthostflagsplayerpSet){
    if(!
show || !is_valid_ent(ent))
        return 
FMRES_IGNORED;
    
    new 
classname[32];
    
entity_get_string(entEV_SZ_classnameclassname31);
        
    if(
equali(classnameent_class)){
        
set_es(esES_ModelIndexmodelindex);
        
//set_es(es, ES_Effects, 0);
        
return FMRES_SUPERCEDE;
    }
        
    return 
FMRES_IGNORED;




All times are GMT -4. The time now is 20:52.

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