Raised This Month: $ Target: $400
 0% 

How properly count/use cycles of ent think


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 10-24-2014 , 13:33   How properly count/use cycles of ent think
Reply With Quote #1

This is my maybe third try to use entity think
it works
I just want to know how to count each think and do something in it in correct way

PHP Code:

new wtf

public ctfthink(ent)
{
  if(!
is_valid_ent(ent)) return      
  
set_pev(ent,pev_nextthinkhalflife_time() + 5.0)
   
wtf++    
   if(
wtf 5
   {
     
// do something on 5th think
    
}

is there another way to do so?
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 10-24-2014 at 13:33.
avril-lavigne is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-24-2014 , 14:02   Re: How properly count/use cycles of ent think
Reply With Quote #2

This may be stupid, to do something different on each think. This sound like an XY problem, you should explain what are you trying to do. You can increase the wtf variable and create a switch, but this is still a bad way. Again, explain what are you actually trying to do.
__________________
HamletEagle is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 10-24-2014 , 14:41   Re: How properly count/use cycles of ent think
Reply With Quote #3

PHP Code:
var = 0

think
()
{
  switch (++var)
  {
    case 
1:
    {

    }

    case 
2:
    {

    }

    default:
    {
       
// this will execute when var is > 2
       // ensure var will never exceed 2147483647
    
}
  }

Ref
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
avril-lavigne
Banned
Join Date: Apr 2009
Old 10-24-2014 , 19:23   Re: How properly count/use cycles of ent think
Reply With Quote #4

I want to check ent state if its == 3 return it to base

PHP Code:


    set_pev
(ent,pev_nextthinkget_gametime() + 25.0 //  will this count 25 sec only on NEXT think not now?   
    
set_pev(ent,pev_originbase
so it moves ent immediately. I need 30sec delay ... thats why I tried wtf 5sec* 5 cycles
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-24-2014 , 22:10   Re: How properly count/use cycles of ent think
Reply With Quote #5

Without more detail this looks like it would be way better suited for a task. Also why do you want to have 5 steps of 5 seconds instead of just one of 25? Please tell us what you actually want to achieve.
__________________
In Flames we trust!
Nextra is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-25-2014 , 08:51   Re: How properly count/use cycles of ent think
Reply With Quote #6

Well, if you really need to count cycles, I would prefer static local variable to do so.
But, however, I agree with Nextra - you should provide more information of what you are trying to achieve.
klippy is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 10-25-2014 , 14:33   Re: How properly count/use cycles of ent think
Reply With Quote #7

PHP Code:
public ctfthink(ent)
{
         if(!
is_valid_ent(ent)) return      
         
set_pev(ent,pev_nextthinkhalflife_time() + 5.0//check ent status each 5 sec

         
if(getstatus(ent) == 3// dropped state. 
         
{
              
dd++    
              if(
dd 5)   // got 30 sec delay. 6*5 times
              
{
                              
                               
set_pev(ent,pev_originoct)  // go to base
                           
status(ent,1)  // on base
                           
dd 0      
              
}             
        }
         else 
dd // ent status 3 was interrupted by a player , clear counter

If put nextthink 30 sec right after needed state (3). It wont count delay NOW . Also if it sleeps 30 sec - what if someone picked up ent in that period and entity state was changed? so I cant wait 30sec at once. So I need to check ent state each few seconds to make sure it was dropped and stay in the same state 30sec before going to base.
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 10-25-2014 at 14:36.
avril-lavigne is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 10-26-2014 , 04:47   Re: How properly count/use cycles of ent think
Reply With Quote #8

I can't get a word from what you say. What do you mean "after needed state (3)", "delay NOW"? What these references are?
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 10-26-2014 , 06:13   Re: How properly count/use cycles of ent think
Reply With Quote #9

Just tell what you want to do, because I cant understand what you want.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
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 17:38.


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