AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to check when round time has expired? (https://forums.alliedmods.net/showthread.php?t=232796)

11922911 01-05-2014 00:07

how to check when round time has expired?
 
Is there an accurate way to detect when round time has expired when there is no objective in map?

Black Rose 01-05-2014 04:40

Re: how to check when round time has expired?
 
I'm not very updated. Someone will point out if there's a better way.
https://wiki.alliedmods.net/Half-Lif...ents#RoundTime

I haven't tested it as my server is not running currently.
Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 3", "", "");         register_event("RoundTime", "eventRoundTime", "a", "1=0"); } public eventRoundTime() {     server_print("Round time is 0:00"); }

ConnorMcLeod 01-05-2014 05:09

Re: how to check when round time has expired?
 
Won't work, this message is only sent with initial value (freezetime, or roundtime, or intermediar value when players is spawned at middle of round/freezetime), the count down is made on client.

To prevent an XY problem, tell what you want to do with this detection.

11922911 01-05-2014 05:23

Re: how to check when round time has expired?
 
I want to forces end round when round time has expired.

ConnorMcLeod 01-05-2014 06:29

Re: how to check when round time has expired?
 
If you use linux, try this :

PHP Code:

#include < amxmodx >
#include < engine >
#include < orpheu >
#include < round_terminator >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

new OrpheuFunction:g_ofnHasRoundTimeExpired;
new 
OrpheuHook:g_ohHasRoundTimeExpired;

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    if(    !
find_ent_by_class(-1"func_bomb_target")
    &&    !
find_ent_by_class(-1"info_bomb_target")
    &&    !
find_ent_by_class(-1"func_hostage_rescue")
    &&    !
find_ent_by_class(-1"func_escapezone")
    &&    !
find_ent_by_class(-1"func_vip_safetyzone")
    &&    !
find_ent_by_class(-1"hostage_entity")    )
    {
        
g_ofnHasRoundTimeExpired OrpheuGetFunction("HasRoundTimeExpired""CHalfLifeMultiplay");
        
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0");
        
Event_HLTV_New_Round();
    }
}

public 
Event_HLTV_New_Round()
{
    
g_ohHasRoundTimeExpired OrpheuRegisterHook
    
(
        
g_ofnHasRoundTimeExpired,
        
"OnHasRoundTimeExpired_P",
        
OrpheuHookPost
    
);
}

public 
OnHasRoundTimeExpired_P()
{
    if( 
OrpheuGetReturn() )
    {
        
OrpheuUnregisterHook(g_ohHasRoundTimeExpired);
        
TerminateRoundRoundEndType_Timer );
    }


Requires following plugin : http://forums.alliedmods.net/showthread.php?p=1122356
And function signature :
On windows the function is not called, that's why plugin can't work.
Code:

{
    "name" : "HasRoundTimeExpired",
    "class" : "CHalfLifeMultiplay",
    "library" : "mod",
        "return" :
    {
        "type" : "bool"
    },
    "identifiers" :
    [
        {
            "os" : "windows",
            "mod" : "cstrike",
            "value" : [0xDB,"*","*",0xA1,"*","*","*","*",0xD8,"*",0xD8,"*","*",0xD8,"*","*","*","*","*",0xDF,"*",0xF6,"*","*",0x7A,"*",0x8B,"*","*",0x85]
        },
        {
            "os" : "linux",
            "mod" : "cstrike",
            "value" : "_ZN18CHalfLifeMultiplay19HasRoundTimeExpiredEv"
        }
    ]
}


11922911 01-05-2014 21:44

Re: how to check when round time has expired?
 
I don't usually use Linux.
Anyway, maybe it would be useful for sometimes.
Thanks.

ConnorMcLeod 01-06-2014 00:48

Re: how to check when round time has expired?
 
Try with a task then.

PHP Code:

#include < amxmodx >
#include < engine >
#include < round_terminator >

#pragma semicolon 1

#define PLUGIN "No Objectives Round End"
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

const TASK_ROUNDEND 1931543;

new 
mp_roundtimeFloat:g_flRoundTime;

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    if(    !
find_ent_by_class(-1"func_bomb_target")
    &&    !
find_ent_by_class(-1"info_bomb_target")
    &&    !
find_ent_by_class(-1"func_hostage_rescue")
    &&    !
find_ent_by_class(-1"func_escapezone")
    &&    !
find_ent_by_class(-1"func_vip_safetyzone")
    &&    !
find_ent_by_class(-1"hostage_entity")    )
    {
        
mp_roundtime get_cvar_pointer("mp_roundtime");
        
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0");
        
register_logevent("LogEvent_Round_Start"2"1=Round_Start");
        
Event_HLTV_New_Round();
    }
}

public 
Event_HLTV_New_Round()
{
    
remove_task(TASK_ROUNDEND);
    
g_flRoundTime floatclamp(get_pcvar_float(mp_roundtime)*60.060.0540.0);
}

public 
LogEvent_Round_Start()
{
    
set_task(g_flRoundTime"Task_RoundEnd"TASK_ROUNDEND);
}

public 
Task_RoundEnd()
{
    
TerminateRoundRoundEndType_Timer );


If doesn't work, try RoundEndType_Timer instead.

11922911 01-06-2014 22:10

Re: how to check when round time has expired?
 
Not a bad idea :)
Thanks.

ConnorMcLeod 01-07-2014 00:59

Re: how to check when round time has expired?
 
Quote:

Originally Posted by ConnorMcLeod (Post 2081798)

If doesn't work, try RoundEndType_Timer instead.

I meant RoundEndType_Draw.


All times are GMT -4. The time now is 10:05.

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