AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   make ent visible and solid only for owner (https://forums.alliedmods.net/showthread.php?t=237719)

red_bull2oo6 03-28-2014 15:36

make ent visible and solid only for owner
 
Hi, we meet again.
I'm wondering if you could help me with some code examples.

I have the following test code.
PHP Code:

/* Plugin generated by AMXX-Studio */

    #include < amxmodx >
    #include < fakemeta >
    #include < engine >
    
    #pragma semicolon 1
    
    
new const
        
PLUGIN_NAME[ ]         = "New Plugin",
        
PLUGIN_VERSION[ ]     = "1.0";
    
    new const 
g_szModel[ ]         = "models/player/sas/sas.mdl";
    new const 
g_szClassName[ ]    = "CustomNPC";
    
    
    new 
g_iNPC33 ];
        
public 
plugin_precache( )    precache_modelg_szModel );
                
public 
plugin_init( )
{
    
    
register_pluginPLUGIN_NAMEPLUGIN_VERSION"Askhanar" );
    
register_clcmd"say /npc""ClCmdSayNPC" );
    
    
register_forwardFM_AddToFullPack"fw_AddToFullPackPre"false );
    
register_thinkg_szClassName"think_NPC" );
    
    
// Add your code here...
}

public 
client_putinserverid )    g_iNPCid ] = -99;
public 
client_disconnectid )
    if( 
g_iNPCid ] > )
        
remove_entityg_iNPCid ] );
        
public 
ClCmdSayNPCid )
{
    
g_iNPCid ] = CreateNPCid );
}

public 
fw_AddToFullPackes_handleeenthosthostflagsplayerpset )
{
    
//code to make my ent visible and solid only for me.
}

public 
think_NPCiEnt )
{
    
    
//Draw a box around it.
    
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 1.7 );
    
    static 
Floatmins[3], Floatmaxs[3];
    
pev(iEntpev_absminmins);
    
pev(iEntpev_absmaxmaxs);

    
//Draw a box which is the size of the bounding NPC
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BOX);
    
engfunc(EngFunc_WriteCoordmins[0]);
    
engfunc(EngFunc_WriteCoordmins[1]);
    
engfunc(EngFunc_WriteCoordmins[2]);
    
engfunc(EngFunc_WriteCoordmaxs[0]);
    
engfunc(EngFunc_WriteCoordmaxs[1]);
    
engfunc(EngFunc_WriteCoordmaxs[2]);
    
write_short(100);
    
write_byte(random_num(25255));
    
write_byte(random_num(25255));
    
write_byte(random_num(25255));
    
message_end();
            
}


CreateNPC(idFloat:fOrigin]= { 0.00.00.0 }, Float:fAngle]= { 0.00.00.0 } )
{
    
    new 
iEnt  create_entity("info_target");
    
    
entity_set_stringiEntEV_SZ_classnameg_szClassName );
    
entity_get_vectoridEV_VEC_originfOrigin );
    
entity_set_originiEntfOrigin );
    
    
fOrigin] += 80;
    
entity_set_originidfOrigin );

    
entity_get_vectoridEV_VEC_anglesfAngle );
    
fAngle] = 0.0;
    
entity_set_vectoriEntEV_VEC_anglesfAngle );
    
    
    
entity_set_model(iEntg_szModel );
    
entity_set_int(iEntEV_INT_movetypeMOVETYPE_NONE );
    
    
entity_set_int(iEntEV_INT_solidSOLID_BBOX );
    
entity_set_int(iEntEV_INT_iuser1id );
    
    
//Create a bounding box for oru NPC
    
new Floatmins[3] = {-16.0, -16.0, -36.0 };
    new 
Floatmaxs[3] = { 16.016.036.0 };

    
entity_set_size(iEntminsmaxs);
    
entity_set_byteiEntEV_BYTE_controller1125 );
    
drop_to_floor(iEnt );
    
    
//set_rendering( iEnt, kRenderFxDistort, 0, 0, 0, kRenderTransAdd, 255 );
    
    //Make it instantly think
    
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 0.01 );
    
    return 
iEnt;
    


All i want is to make that 'test npc' visible and solid only for the owner stored in iuser1 ( in this case me )

red_bull2oo6 05-13-2014 16:14

Re: make ent visible and solid only for owner
 
bump ?!

Backstabnoob 05-13-2014 16:25

Re: make ent visible and solid only for owner
 
Try searching. I'll give you a little tip, you want to use ES_Solid and ES_RenderAmt.

There are literally hundreds of topics about AddToFullpack.

red_bull2oo6 05-13-2014 18:05

Re: make ent visible and solid only for owner
 
i did, and i tried some 'methods' by myself but i didn't figured it out.

here is one of them i found.
it makes it invisible but it's still solid.

PHP Code:

/* Plugin generated by AMXX-Studio */

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

#pragma semicolon 1

new const
PLUGIN_NAME[ ]         = "New Plugin",
PLUGIN_VERSION[ ]     = "1.0";

new const 
g_szModel[ ]         = "models/player/sas/sas.mdl";
new const 
g_szClassName[ ]    = "CustomNPC";


new 
g_iNPC33 ];

public 
plugin_precache( )    precache_modelg_szModel );

public 
plugin_init( )
{
    
    
register_pluginPLUGIN_NAMEPLUGIN_VERSION"Askhanar" );
    
register_clcmd"say /npc""ClCmdSayNPC" );
    
    
register_forwardFM_AddToFullPack"fw_AddToFullPackPre"false );
    
register_thinkg_szClassName"think_NPC" );
    
    
// Add your code here...
}

public 
client_putinserverid )    g_iNPCid ] = -99;
public 
client_disconnectid )
    if( 
g_iNPCid ] > )
        
remove_entityg_iNPCid ] );

public 
ClCmdSayNPCid )
{
    
g_iNPCid ] = CreateNPCid );
}

public 
fw_AddToFullPackes_handleeenthosthostflagsplayerpset )
{
    
    if( !
player )
    {
        static 
szClassName32 ];
        
entity_get_stringentEV_SZ_classnameszClassNamesizeofszClassName ) -);
        
        if( 
equalszClassNameg_szClassName )
            && 
entity_get_intentEV_INT_iuser1 ) != host )
        {
            
            
set_eses_handleES_Origin, { 999999999.0999999999.0999999999.0 } );
            
set_eses_handleES_RenderModekRenderTransAlpha );
            
set_eses_handleES_RenderAmt);
            
            
set_eses_handleES_SolidSOLID_NOT );
        }
    }
    
}

public 
think_NPCiEnt )
{
    
    
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 1.7 );
    
    static 
Floatmins[3], Floatmaxs[3];
    
pev(iEntpev_absminmins);
    
pev(iEntpev_absmaxmaxs);
    
    
//Draw a box which is the size of the bounding NPC
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BOX);
    
engfunc(EngFunc_WriteCoordmins[0]);
    
engfunc(EngFunc_WriteCoordmins[1]);
    
engfunc(EngFunc_WriteCoordmins[2]);
    
engfunc(EngFunc_WriteCoordmaxs[0]);
    
engfunc(EngFunc_WriteCoordmaxs[1]);
    
engfunc(EngFunc_WriteCoordmaxs[2]);
    
write_short(100);
    
write_byte(random_num(25255));
    
write_byte(random_num(25255));
    
write_byte(random_num(25255));
    
message_end();
    
}


CreateNPC(idFloat:fOrigin]= { 0.00.00.0 }, Float:fAngle]= { 0.00.00.0 } )
{

    new 
iEnt  create_entity("info_target");
    
    
entity_set_stringiEntEV_SZ_classnameg_szClassName );
    
entity_get_vectoridEV_VEC_originfOrigin );
    
entity_set_originiEntfOrigin );
    
    
fOrigin] += 80;
    
entity_set_originidfOrigin );
    
    
entity_get_vectoridEV_VEC_anglesfAngle );
    
fAngle] = 0.0;
    
entity_set_vectoriEntEV_VEC_anglesfAngle );
    
    
    
entity_set_model(iEntg_szModel );
    
entity_set_int(iEntEV_INT_movetypeMOVETYPE_NONE );
    
    
entity_set_int(iEntEV_INT_solidSOLID_BBOX );
    
entity_set_int(iEntEV_INT_iuser1id );
    
    
//Create a bounding box for oru NPC
    
static Floatmins[3] = {-16.0, -16.0, -36.0 };
    static 
Floatmaxs[3] = { 16.016.036.0 };
    
    
entity_set_size(iEntminsmaxs);
    
entity_set_byteiEntEV_BYTE_controller1125 );
    
drop_to_floor(iEnt );
    
    
//set_rendering( iEnt, kRenderFxDistort, 0, 0, 0, kRenderTransAdd, 255 );
    
    //Make it instantly think
    
entity_set_floatiEntEV_FL_nextthinkget_gametime() + 0.01 );
    
    return 
iEnt;




red_bull2oo6 09-02-2015 12:02

Re: make ent visible and solid only for owner
 
bump ? anyone please just a scratch of code ?

SpeeDeeR 09-02-2015 14:08

Re: make ent visible and solid only for owner
 
pev_groupinfo

https://forums.alliedmods.net/showthread.php?t=205453
https://forums.alliedmods.net/showpo...3&postcount=14
https://forums.alliedmods.net/showthread.php?t=200238

red_bull2oo6 09-02-2015 14:20

Re: make ent visible and solid only for owner
 
i allready saw those links in other thread..about addtofullpack fwd in this section but i need for a specific player nor for a specific team.

why's my method not working ? what's wrong. i suck @addtofullpack

SpeeDeeR 09-02-2015 20:50

Re: make ent visible and solid only for owner
 
You can't manipulate the solid state with this forward. What you really need is pev_groupinfo. The ent will be rendered just for it's owner.

PHP Code:

#define Mask(%0)    ( 1<<(%0 & 31) )

CreateNPC(...) {
    
//....
    //render it just for player with index id
    
set_peviEntpev_groupinfoMask(id));
    
    
//to make it visible for all players use 0 as third argument
    //to make it visible for additional player with index ID add him to the bitmask like
    //set_pev(iEnt, pev_groupinfo, pev(iEnt, pev_groupinfo ) | Mask( ID ) );
    //to remove him from the group use
    //set_pev(iEnt, pev_groupinfo, pev(iEnt, pev_groupinfo ) & ~Mask( ID ) )




All times are GMT -4. The time now is 06:03.

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