Raised This Month: $ Target: $400
 0% 

Problem with PlayersRemaining.sma


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bladell
Senior Member
Join Date: Jun 2012
Old 11-17-2014 , 08:40   Re: Problem with PlayersRemaining.sma
Reply With Quote #7

Quote:
Originally Posted by RateX View Post
try:
PHP Code:
#include <amxmodx>
#include <engine>

#define DELAY        0.5
#define HUD_STAY    DELAY + 0.1
#define TASK_HUD    239472384723
#define TASK_GETNUM    238479923748

enum _:CVARS {
    
RED,
    
GREEN,
    
BLUE,
    
LOCATION
};

enum _:TEAMS {
    
TE,
    
CT
};

new 
g_pCvarsCVARS ];

new const 
Float:g_flCoords[ ][ ] = {
    { 
0.02, -1.0 },
    { 
0.100.40 },
    { 
0.280.00 },
    { 
0.570.00 },
    { 
0.570.45 },
    { 
0.570.78 },
    { 
0.270.78 },
    { 
0.010.78 },
    { 
0.310.36 }
}

public 
plugin_init( ) {
    
register_plugin"Players Remaining""1.0""xPaw" );
    
    
g_pCvarsRED      ] = register_cvar"amx_pr_red",        "0" );
    
g_pCvarsGREEN    ] = register_cvar"amx_pr_green",      "127" );
    
g_pCvarsBLUE     ] = register_cvar"amx_pr_blue",       "255" );
    
g_pCvarsLOCATION ] = register_cvar"amx_pr_location",   "5" );

    
register_event"HLTV""Event_HLTV_New_Round""a""1=0""2=0" );
    
register_logevent("logevent_round_end"2"1=Round_End");
}

public 
Event_HLTV_New_Round( ) 
{
    
set_task(150.0"ShowHUD"TASK_HUD)
}

public 
ShowHUD()
{
    new 
iEntity create_entity"info_target" );
    
    if( 
is_valid_entiEntity ) ) {
        
entity_set_stringiEntityEV_SZ_classname"PlayersRemainThinker" );
        
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + DELAY );
        
        
register_think"PlayersRemainThinker""FwdThink" );
    } else
        
set_taskDELAY"GetNum"TASK_GETNUM__"b" );
}

public 
FwdThink(iEntity
{
    
GetNum( );
    
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + DELAY );
}

public 
logevent_round_end()
{
    new 
ent = -1
    
while((ent find_ent_by_class(ent"PlayersRemainThinker")))
    {
        
remove_entity(ent)
    }
    if(
task_exists(TASK_GETNUM)) remove_task(TASK_GETNUM);
    if(
task_exists(TASK_HUD)) remove_task(TASK_HUD);
}

public 
GetNum( ) {
    new 
iPlayers32 ], iNumTEAMS ];
    
get_playersiPlayersiNumTE ], "ae""TERRORIST" );
    
get_playersiPlayersiNumCT ], "ae""CT" );
    
    if( 
iNumTE ] > || iNumCT ] > ) {
        new 
iCvarsCVARS ];
        
        
iCvarsRED      ] = get_pcvar_numg_pCvarsRED      ] );
        
iCvarsGREEN    ] = get_pcvar_numg_pCvarsGREEN    ] );
        
iCvarsBLUE     ] = get_pcvar_numg_pCvarsBLUE     ] );
        
iCvarsLOCATION ] = get_pcvar_numg_pCvarsLOCATION ] );
        
        if( 
iCvarsLOCATION ] > sizeofg_flCoords ) - ) {
            
set_pcvar_numg_pCvarsLOCATION ], );
            
            
iCvarsLOCATION ] = 1;
        }
        
        
set_hudmessageiCvarsRED ], iCvarsGREEN ], iCvarsBLUE ], 
        
g_flCoordsiCvarsLOCATION ] ][ ], g_flCoordsiCvarsLOCATION ] ][ ], 0HUD_STAYHUD_STAY0.00.0);
        
        
show_hudmessage0"Players Remaining^nTE: %i^nCT: %i"iNumTE ], iNumCT ] );
    }

BTW, the nature of the problem is that you guys have no idea how to use set_task. Atleast look at the description on wiki/api page and example in exiting plugins.
The problem is that you talk too much. You made a task to be non repetitive and that's it... very smart guy, whe should pay you or what?
Bladell is offline
 



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:43.


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