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

Solved hide entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tote
Senior Member
Join Date: Jul 2023
Old 08-06-2023 , 13:56   hide entity
Reply With Quote #1

Hello.
Im trying to find a way to hide an entity which is being used in another plugin. For example an entity class name(d) "ent_hat" is being used in a plugin, if i want to get the classname of this entity in another plugin how can i do it?

Here's what im trying to do to get entity class name from another plugin:
static classname[32]
pev(ent, pev_classname, classname, 31)
if(is_valid(ent))
{
if(equal(classname, "ent_hat"))
{
do something//
}
}

Last edited by Tote; 08-07-2023 at 12:31.
Tote is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-06-2023 , 16:04   Re: hide entity
Reply With Quote #2

Where are you putting that code? Also, I think you'll probably want to use something like find_ent_by_class().
__________________
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 08-06-2023 , 19:56   Re: hide entity
Reply With Quote #3

PHP Code:
#define INVISBLE 128
#define VISIBLE 0

stock HideHats()
{
    static 
ent;
    
ent = -1

    
while((ent find_ent_by_class(ent,"ent_hat") != 0)
   {
        if(
is_valid_ent(ent)) // am not sure if the function find ent by class check if is valid ent earlier but in any case...
           
entity_set_intentEV_INT_effectsINVISIBLE ); 

          
// entity_set_int( ent, EV_INT_effects, VISIBLE ); 
   
}


Last edited by MrPickles; 08-06-2023 at 19:58.
MrPickles is offline
Tote
Senior Member
Join Date: Jul 2023
Old 08-07-2023 , 03:04   Re: hide entity
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
Where are you putting that code? Also, I think you'll probably want to use something like find_ent_by_class().
Thanks for reply, Im putting it in FmAddToFullPack
Tote is offline
Tote
Senior Member
Join Date: Jul 2023
Old 08-07-2023 , 03:04   Re: hide entity
Reply With Quote #5

Thanks, I'll try it out !
Tote is offline
Tote
Senior Member
Join Date: Jul 2023
Old 08-07-2023 , 03:29   Re: hide entity
Reply With Quote #6

i tried using this: it works, but it lags the server uses too much CPU suddenly and spams Errors in Console:
ERRORS:
L 08/07/2023 - 00:11:47: [FAKEMETA] Invalid entity
L 08/07/2023 - 00:11:47: [AMXX] Displaying debug trace (plugin "Untitled.amxx", version "1.0")
L 08/07/2023 - 00:11:47: [AMXX] Run time error 10: native error (native "pev")
L 08/07/2023 - 00:11:47: [AMXX] [0] Untitled.sma::ForwardAddToFullPack (line 3453)
L 08/07/2023 - 00:11:47: [FAKEMETA] Invalid entity
Thats the error which spams in my console and i have tried your way too @Mr.Pickles

if(!is_valid_ent(ent))
return 1;
if(equal(classname, "ent_hat") == ent || ent == equal(classname, "ent_hat"))
{
set_es( es_handle, ES_RenderMode, kRenderTransAlpha );
set_es( es_handle, ES_RenderAmt, 0 );
}
Tote is offline
Tote
Senior Member
Join Date: Jul 2023
Old 08-07-2023 , 03:42   Re: hide entity
Reply With Quote #7

SOLVED!
Used:
new entu = engfunc( EngFunc_FindEntityByString, -1, "classname", "ent_hat" );
Thanks for your help guys!
Tote is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 08-07-2023 , 21:08   Re: hide entity
Reply With Quote #8

Quote:
Originally Posted by Tote View Post
SOLVED!
Used:
new entu = engfunc( EngFunc_FindEntityByString, -1, "classname", "ent_hat" );
Thanks for your help guys!
The code that I gave you must have worked perfectly, you don't need to use add to full pack for that, with that,you are searching each frame for the entity with that classname, with which I gave you only activate/deactivate invisibility once.

You could also try sending the error it gave you, you sent the error of your code only.
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-07-2023 , 23:25   Re: hide entity
Reply With Quote #9

Quote:
Originally Posted by Tote View Post
SOLVED!
Used:
new entu = engfunc( EngFunc_FindEntityByString, -1, "classname", "ent_hat" );
Thanks for your help guys!
That's essentially the same thing. Also, as Mr. Pickles said, calling the function multiple times per second is most likely not necessary at all. Just set the visibility when you need to change it.

Also, if the entity is a long-lived entity (e.g. created once during the map), you only need to search for it once and simply save the entity ID and re-use it when you need to do something with it.
__________________
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 08-08-2023 , 00:40   Re: hide entity
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
That's essentially the same thing. Also, as Mr. Pickles said, calling the function multiple times per second is most likely not necessary at all. Just set the visibility when you need to change it.

Also, if the entity is a long-lived entity (e.g. created once during the map), you only need to search for it once and simply save the entity ID and re-use it when you need to do something with it.
What happens is that he has it in separate plugins, he would have to create a library saving the index of the hat, in order to obtain it in the other plugin, make a loop with the maximum number of connected players and verify if the hat is a valid entity, I think that the find ent by class is more appropriate in this case.
MrPickles 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 04:52.


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