Raised This Month: $ Target: $400
 0% 

[Not Working] Thinking Entity as Timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-18-2016 , 15:04   [Not Working] Thinking Entity as Timer
Reply With Quote #1

Hello

I found this snippet in this forum, however it doesn't work.
Can someone tell me what's wrong or what am I missing?

PHP Code:
[...]
   new 
Ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
   
set_pev(Ent,pev_classname,g_Classname)
   
set_pev(Ent,pev_nextthink,1.0)
   
register_forward(FM_Think,"ForwardThink")
}

public 
ForwardThink(Ent)
{
   if(
get_pcvar_num([enabled]) || !b_DamagedRecently || GetPlayerCount(2) == 0)
      return 
FMRES_IGNORED

   
static Classname[33]
   
pev(Ent,pev_classname,Classname,32)
   if(!
equal(Classname,g_Classname))
      return 
FMRES_IGNORED   
      
   
[integer]--
   
set_pev(Ent,pev_nextthink,1.0)

   return 
FMRES_HANDLED

Thanks in advance
__________________
gabuch2 is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 04-18-2016 , 15:46   Re: [Not Working] Thinking Entity as Timer
Reply With Quote #2

what do u want it to do?
__________________
Contact: Steam
Videos: Youtube

Last edited by SkumTomteN; 04-18-2016 at 15:48.
SkumTomteN is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-18-2016 , 17:10   Re: [Not Working] Thinking Entity as Timer
Reply With Quote #3

PHP Code:
new g_Entity;

g_Entity create_entity"info_target" );
entity_set_stringg_Entity EV_SZ_classname "MyThinkingEntity" );
register_think"MyThinkingEntity" "EntityThink" );

public 
EntityThinkiEntity )
{
    if( 
iEntity == g_Entity 
    {
        
//Do stuff here

        
entity_set_floatg_Entity EV_FL_nextthink , ( get_gametime() + 1.0 ) );
    }

__________________

Last edited by Bugsy; 04-18-2016 at 17:10.
Bugsy is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-18-2016 , 17:13   Re: [Not Working] Thinking Entity as Timer
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
PHP Code:
new g_Entity;

g_Entity create_entity"info_target" );
entity_set_stringg_Entity EV_SZ_classname "MyThinkingEntity" );
register_think"MyThinkingEntity" "EntityThink" );

public 
EntityThinkiEntity )
{
    if( 
iEntity == g_Entity 
    {
        
//Do stuff here

        
entity_set_floatg_Entity EV_FL_nextthink , ( get_gametime() + 1.0 ) );
    }

Does nextthink requires the exact time to execute the next think cycle? Makes sense why my code wasn't working.
__________________
gabuch2 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-19-2016 , 10:33   Re: [Not Working] Thinking Entity as Timer
Reply With Quote #5

Yes.
Both functions do basically the same things AFAIK, just in different ways.
__________________
Black Rose is offline
Reply


Thread Tools
Display Modes

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


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