Raised This Month: $32 Target: $400
 8% 

Problem with PlayersRemaining.sma


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Monster Truck
Member
Join Date: Jan 2012
Location: France
Old 11-14-2014 , 15:31   Problem with PlayersRemaining.sma
Reply With Quote #1

Hi, today, as says the title, i have a problem when i try to edit this plugin.

This plugin is called PlayersRemaining.sma made by xPaw, here's the original link : Heeeere

This plugin displays an HUD message for the remaining CTs and Ts.

My purpose is to make this plugin displaying the HUD messages after exactly 150 sec, and when the round is finished, to remove the HUD messages, and then, when the round is starting, waiting 150 sec for displaying messages and so on ...

I tried with set_task and remove_task but this code seems to hard for me :/

I'll thank any help.

(My own work is attached)
Attached Files
File Type: sma Get Plugin or Get Source (PlayersRemaining.sma - 464 views - 2.0 KB)

Last edited by Monster Truck; 11-14-2014 at 15:32.
Monster Truck is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 11-15-2014 , 06:32   Re: Problem with PlayersRemaining.sma
Reply With Quote #2

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

#define DELAY_A 150
#define DELAY_W 0.5
#define HUD_STAY DELAY_W + 0.1

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

enum _:TEAMS {
    
TE,
    
CT
};

new 
g_pCvarsCVARS ];

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" );
    
    
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( ) 
{
    new 
iEntity create_entity"info_target" );
    
    if( 
is_valid_entiEntity ) ) 
    {
        
entity_set_stringiEntityEV_SZ_classname"PlayersRemainThinker" );
        
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + DELAY_A );
        
        
register_think"PlayersRemainThinker""FwdThink" );
    } 
    else
    {
        
set_task1.5 "ShowMessage"___"b"1243798 );
    }
}

public 
FwdThinkiEntity 
{
    
set_task1.5"ShowMessage"___"b"2542462 );
    
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + DELAY_W );
}

public 
Logevent_Round_End( )
{
    
remove_task1243798 ); 
    
remove_task2542462 ); 
}

public 
ShowMessage( ) 
{
    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     ] );

        
set_hudmessageiCvarsRED ], iCvarsGREEN ], iCvarsBLUE ], 0.790.510HUD_STAYHUD_STAY0.00.0);
        
        
show_hudmessage0"Zombie Connectés : %i^nSurvivants Restants : %i"iNumTE ], iNumCT ] );
    }

Bladell is offline
Monster Truck
Member
Join Date: Jan 2012
Location: France
Old 11-15-2014 , 06:57   Re: Problem with PlayersRemaining.sma
Reply With Quote #3

Wow smart, was thinking about doing approximately the same thing, but sounds well.

Thank you, if i do not reply it means that it's solved.
Monster Truck is offline
Monster Truck
Member
Join Date: Jan 2012
Location: France
Old 11-15-2014 , 07:28   Re: Problem with PlayersRemaining.sma
Reply With Quote #4

Having some issues with your code, when using it, the HUD is displaying after 150 sec, but a few seconds later, it begins "twinkling" (there are not any conflict with another HUD message) before fully disappearing. And the HUD is not displaying anymore, even in the next round.

Any ideas on the nature of the problem ?
Monster Truck is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-15-2014 , 09:46   Re: Problem with PlayersRemaining.sma
Reply With Quote #5

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.
RateX is offline
Monster Truck
Member
Join Date: Jan 2012
Location: France
Old 11-15-2014 , 10:37   Re: Problem with PlayersRemaining.sma
Reply With Quote #6

It's working really fine, thank you.

BTW, i read the amx wiki for set_task and remove_task, i tried somethin like "Bladell" does but i had no clue on how to use it correctly, because i used it only once or twice for very tiny plugins.

Well, anyway, thank you again for the help, see you !

Last edited by Monster Truck; 11-15-2014 at 10:37.
Monster Truck is offline
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
GinNNy
Senior Member
Join Date: Mar 2014
Old 11-17-2014 , 08:57   Re: Problem with PlayersRemaining.sma
Reply With Quote #8

Quote:
Originally Posted by Bladell View Post
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?
And what is your problem here?
GinNNy is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-17-2014 , 12:56   Re: Problem with PlayersRemaining.sma
Reply With Quote #9

Quote:
Originally Posted by Bladell View Post
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?
Which part are you implying?

About paying me, why not?
RateX 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 03:14.


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