Raised This Month: $ Target: $400
 0% 

FM_Think


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
@.SizNeR
Member
Join Date: Jun 2013
Old 08-21-2013 , 14:40   FM_Think
Reply With Quote #1

PHP Code:
#include < amxmodx >
#include < fakemeta >

new const g_szEntityClass[] = "MyEntity";

new 
g_iEntity;


public 
plugin_init()
{
    
register_plugin"Using FM_Think""v1.0""@.SizNeR" );
    
    
register_forwardFM_Think"FwThink" );
    
    
    
CmdCreateEntity();
}

public 
FwThinkiEntity )
{
    if ( !
pev_validiEntity ) )
        return 
1;
        
    static 
szEntityClass32 ];
    
    
peviEntitypev_classnameszEntityClasscharsmaxszEntityClass ) );
    
    if ( !
equaliszEntityClassg_szEntityClass ) )
    {
        
CmdSetThinkg_iEntity1.0 );
        
        return 
1;
    }
    
    new 
iPlayers32 ], iCtCountiTerrorCount;
    
    
get_playersiPlayersiCtCount"ceh""CT" );
    
    
get_playersiPlayersiTerrorCount"ceh""TERRORIST" );
    
    if ( ( 
iCtCount <= && iTerrorCount >= ) || ( iCtCount <= && iTerrorCount >= 10 ) || ( iCtCount <= && iTerrorCount >= 15 ) || ( iCtCount <= && iTerrorCount >= 20 ) )
    {
        
MyPublic();
        
        return 
1;
    }
    
    
CmdSetThinkg_iEntity1.0 );
    
    return 
1;
}

public 
MyPublic()
{
    
log_amx"On My Public." );
}

stock CmdCreateEntity()
{
    
g_iEntity engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );
    
    
set_pevg_iEntitypev_classnameg_szEntityClass );
    
    
CmdSetThinkg_iEntity1.0 );
}

stock CmdSetThinkiEntityFloat:flTime )
{
    
set_peviEntitypev_nextthinkget_gametime() + flTime );

Help please?

Last edited by @.SizNeR; 08-21-2013 at 14:41.
@.SizNeR is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-21-2013 , 14:55   Re: FM_Think
Reply With Quote #2

This is not going to help if you don't explain what is your problem.
__________________
Arkshine is offline
@.SizNeR
Member
Join Date: Jun 2013
Old 08-21-2013 , 14:56   Re: FM_Think
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
This is not going to help if you don't explain what is your problem.
The server is not printing the message in MyPublic().
@.SizNeR is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-21-2013 , 18:33   Re: FM_Think
Reply With Quote #4

Every time think is called for any other entity it will update the think time of your entity. This is obviously why it's never called. The next think is always getting pushed forward by other entitys.

Also since you only have one entity just do
Code:
if ( iEntity != g_iEntity )     return;

And here's what you should've done.
Code:
public FwThink( iEntity ) {     server_print("FwThink was called.");     if ( !pev_valid( iEntity ) )     return 1;     server_print("Entity is valid.");     static szEntityClass[ 32 ];         pev( iEntity, pev_classname, szEntityClass, charsmax( szEntityClass ) );         if ( !equali( szEntityClass, g_szEntityClass ) )     {         server_print("Wrong entity, updating nextthink.");         CmdSetThink( g_iEntity, 1.0 );                 return 1;     }         new iPlayers[ 32 ], iCtCount, iTerrorCount;         get_players( iPlayers, iCtCount, "ceh", "CT" );         get_players( iPlayers, iTerrorCount, "ceh", "TERRORIST" );         server_print("iCtCount: %d, iTerrorCount: %d", iCtCount, iTerrorCount);             if ( ( iCtCount <= 0 && iTerrorCount >= 1 ) || ( iCtCount <= 1 && iTerrorCount >= 10 ) || ( iCtCount <= 2 && iTerrorCount >= 15 ) || ( iCtCount <= 3 && iTerrorCount >= 20 ) )     {         MyPublic();                 return 1;     }         CmdSetThink( g_iEntity, 1.0 );         return 1; }
__________________

Last edited by Black Rose; 08-21-2013 at 18:38.
Black Rose is offline
@.SizNeR
Member
Join Date: Jun 2013
Old 08-21-2013 , 18:48   Re: FM_Think
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
Every time think is called for any other entity it will update the think time of your entity. This is obviously why it's never called. The next think is always getting pushed forward by other entitys.

Also since you only have one entity just do
Code:
if ( iEntity != g_iEntity )     return;

And here's what you should've done.
Code:
public FwThink( iEntity ) {     server_print("FwThink was called.");     if ( !pev_valid( iEntity ) )     return 1;     server_print("Entity is valid.");     static szEntityClass[ 32 ];         pev( iEntity, pev_classname, szEntityClass, charsmax( szEntityClass ) );         if ( !equali( szEntityClass, g_szEntityClass ) )     {         server_print("Wrong entity, updating nextthink.");         CmdSetThink( g_iEntity, 1.0 );                 return 1;     }         new iPlayers[ 32 ], iCtCount, iTerrorCount;         get_players( iPlayers, iCtCount, "ceh", "CT" );         get_players( iPlayers, iTerrorCount, "ceh", "TERRORIST" );         server_print("iCtCount: %d, iTerrorCount: %d", iCtCount, iTerrorCount);             if ( ( iCtCount <= 0 && iTerrorCount >= 1 ) || ( iCtCount <= 1 && iTerrorCount >= 10 ) || ( iCtCount <= 2 && iTerrorCount >= 15 ) || ( iCtCount <= 3 && iTerrorCount >= 20 ) )     {         MyPublic();                 return 1;     }         CmdSetThink( g_iEntity, 1.0 );         return 1; }
I did it, its don't print any thing.
@.SizNeR is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-21-2013 , 18:58   Re: FM_Think
Reply With Quote #6

Wrong answer.
Code:
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
Here's what it should look like.
Code:
public FwThink( iEntity ) {     if ( iEntity != g_iEntity || ! pev_valid(iEntity) )         return;         new iPlayers[ 32 ], iCtCount, iTerrorCount;         get_players( iPlayers, iCtCount, "ceh", "CT" );     get_players( iPlayers, iTerrorCount, "ceh", "TERRORIST" );         if ( ( ! iCtCount && iTerrorCount 1 ) || ( iCtCount <= 1 && iTerrorCount >= 10 ) || ( iCtCount <= 2 && iTerrorCount >= 15 ) || ( iCtCount <= 3 && iTerrorCount >= 20 ) )     {         MyPublic();                 return;     }         CmdSetThink( g_iEntity, 1.0 ); }
__________________

Last edited by Black Rose; 08-21-2013 at 19:06.
Black Rose is offline
@.SizNeR
Member
Join Date: Jun 2013
Old 08-21-2013 , 19:02   Re: FM_Think
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
Wrong answer.
Code:
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
FwThink was called.
Entity is valid.
Wrong entity, updating nextthink.
Its not printing on my server.

Edit:
Its work, but MyPublic() is not called.

Last edited by @.SizNeR; 08-21-2013 at 19:10.
@.SizNeR is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-21-2013 , 19:14   Re: FM_Think
Reply With Quote #8

... what are you doing? It's working fine.
Code:
L 08/22/2013 - 01:12:11: "Black Rose<53><STEAM_0:1:-snip-><>" joined team "TERRORIST"
L 08/22/2013 - 01:12:12: [test7.amxx] On My Public.
__________________

Last edited by Black Rose; 08-21-2013 at 19:33.
Black Rose is offline
@.SizNeR
Member
Join Date: Jun 2013
Old 08-21-2013 , 19:32   Re: FM_Think
Reply With Quote #9

Quote:
Originally Posted by Black Rose View Post
... what are you doing? It's working fine.
Code:
L 08/22/2013 - 01:12:11: "Black Rose<53><STEAM_0:1:-snip-><>" joined team "TERRORIST"
L 08/22/2013 - 01:12:12: [test7.amxx] On My Public.
I change a little the code and its always printing me the same message.

Code:
Code:
public FwFirstThink( iEntity ) {       static szClassname[ 32 ];         pev( iEntity, pev_classname, szClassname, charsmax( szClassname ) );         server_print( "On think." );         if( !equali( szClassname, g_szFirstClass ) )     {         set_think( g_iFirstEnt, 1.0 );                 server_print( "Updating next time. [1]" );                 return 1;     }         if( g_bActive )     {         set_think( iEntity, 1.0 );                 server_print( "Updating next time. [2]" );                 return 1;     }         new players[ 32 ], pnum;         new tCount, ctCount;         get_players( players, pnum, "c" );         for( new i = 0; i < pnum; i++ )     {         if( !is_user_connected( players[ i ] ) )             continue;                 switch( cs_get_user_team( players[ i ] ) )         {             case CS_TEAM_T:                 tCount++;                         case CS_TEAM_CT:                 ctCount++;         }     }         if ( ( tCount <= 1 && ctCount >= 0 ) || ( tCount / ctCount > 5 ) && !g_bActive )     {         server_print( "Starting First" );                 g_bActive = true;             g_iCountdown = 5;             set_task( 1.0, "CmdFirstCountdown", g_iCountdownTask, _, _, "b" );     }     set_think( iEntity, 1.0 );         server_print( "Updating next time. [3]" );         return 1; }

Message:
PHP Code:
On think.
Updating next time. [1
Thanks for help.

Last edited by @.SizNeR; 08-21-2013 at 19:32.
@.SizNeR is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-21-2013 , 19:37   Re: FM_Think
Reply With Quote #10

So you broke it exactly the same way again? I already told you in #4 this is wrong. Don't update think time if you get the wrong entity. Just exit the function.

On top of that, after it finishes one run it will return on "if( g_bActive )" and break again.
__________________
Black Rose 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 15:54.


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