AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with PlayersRemaining.sma (https://forums.alliedmods.net/showthread.php?t=251521)

Monster Truck 11-14-2014 15:31

Problem with PlayersRemaining.sma
 
1 Attachment(s)
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)

Bladell 11-15-2014 06:32

Re: Problem with PlayersRemaining.sma
 
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 ] );
    }



Monster Truck 11-15-2014 06:57

Re: Problem with PlayersRemaining.sma
 
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 11-15-2014 07:28

Re: Problem with PlayersRemaining.sma
 
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 ?

RateX 11-15-2014 09:46

Re: Problem with PlayersRemaining.sma
 
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.

Monster Truck 11-15-2014 10:37

Re: Problem with PlayersRemaining.sma
 
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 !

Bladell 11-17-2014 08:40

Re: Problem with PlayersRemaining.sma
 
Quote:

Originally Posted by RateX (Post 2224480)
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?

GinNNy 11-17-2014 08:57

Re: Problem with PlayersRemaining.sma
 
Quote:

Originally Posted by Bladell (Post 2225313)
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?

RateX 11-17-2014 12:56

Re: Problem with PlayersRemaining.sma
 
Quote:

Originally Posted by Bladell (Post 2225313)
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?:3


All times are GMT -4. The time now is 17:43.

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