AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   roundstart event (https://forums.alliedmods.net/showthread.php?t=192330)

GhostMan 08-09-2012 03:56

roundstart event
 
how do i call round start event when all players are just spawned but before freeze time?

And when round start event is called like that?

PHP Code:

register_logevent("Event_Roundstart"2"1=Round_Start"); 

And where i can find all parameters meanings?

dark_style 08-09-2012 05:57

Re: roundstart event
 
Take a look at this tutorial - http://forums.alliedmods.net/showthread.php?t=42159 .

Liverwiz 08-09-2012 11:40

Re: roundstart event
 
This is also a good wiki to have laying around.
http://wiki.amxmodx.org/Half-Life_1_...s#Introduction

Most of these events run through register_logevent

Exolent[jNr] 08-09-2012 11:42

Re: roundstart event
 
Quote:

Originally Posted by Liverwiz (Post 1767722)
This is also a good wiki to have laying around.
http://wiki.amxmodx.org/Half-Life_1_...s#Introduction

Most of these events run through register_logevent

None of the events on that page are used with register_logevent().

Liverwiz 08-09-2012 11:56

Re: roundstart event
 
Quote:

Originally Posted by Exolent[jNr] (Post 1767724)
None of the events on that page are used with register_logevent().

:oops: look at me confusing my shit again.....
I stand corrected.
But its still good to have around, however irrelevant to this thread.

akcaliberg 08-09-2012 23:16

Re: roundstart event
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new bool:new_round[33];
new 
round;
new 
iMaxPlayers;
public 
plugin_init() {
    
RegisterHam(Ham_Spawn"player""HamPlayerSpawnPost",1)
    
register_logevent("LogeventRoundEnd",2,"1=Round_End"//Check: will the new round start ?
    
register_logevent("LogeventRoundStart",2,"1=Round_Start"//Check: is it first round ?
    
round=0;
    
iMaxPlayers get_maxplayers();
}
public 
LogeventRoundEnd() {
        for(new 
i=1;i<=iMaxPlayers;i++) {
                
new_round[i] = true;
        }
}
public 
LogeventRoundStart() { 
    
round++
}
public 
HamPlayerSpawnPost(id) {
    if(
new_round[id] || !round) {
        
//Codes
        
new_round[id] = false;
    }
    


I'm new in scripting, but I guess this work (?)

Liverwiz 08-09-2012 23:19

Re: roundstart event
 
in order for the HamSpawn to be post you need a 4th argument to be 1.
Code:

    RegisterHam(Ham_Spawn, "player", "HamPlayerSpawnPost")
:arrow:
PHP Code:

    RegisterHam(Ham_Spawn"player""HamPlayerSpawnPost"1

otherwise its pre

and only the first person in the spawn iteration will have the HamSpawn code run on them. After that new_round will be false, and thus all if-checks will be be false.

ConnorMcLeod 08-10-2012 02:09

Re: roundstart event
 
You can use this, offering 2 forwards :

PHP Code:

forward NewRoundHLTVround_num )
forward MapCleanedUp() 

The 1st one is the usual HLTV event with round num as argument
The 2nd one is the last thing called in CHalfLifeMultiPlay::RoundRestart, so it happen after all players have been spawned.

Don't rip the code to use in multiple plugin, because you gonna have unexpected results unregistering FM_PlaybackEvent on the same frame other FM_PlaybackEvent forwards are sent.
If you want to use in only 1 plugin you can rip the code, else use this plugin and its forwards.

PHP Code:

/*    Formatright © 2011, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN "New Round Forwards"

const INVALID_FORWARD = -1

new const g_szNewRoundHLTVCallBack[] = "NewRoundHLTV"
new const g_szMapCleanedUpCallBack[] = "MapCleanedUp"

new g_iNewRoundHLTV INVALID_FORWARD
new g_iMapCleanedUp INVALID_FORWARD

new g_iFhPlaybackEventPost

new g_iReturn

new bool:g_bCompleteReset

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
}

public 
plugin_cfg()
{
    new 
pluginsNum get_pluginsnum()
    new 
bool:bHLTVRegistered false
    
for(new pluginIndexpluginIndex<pluginsNumpluginIndex++)
    {
        if( 
g_iNewRoundHLTV == INVALID_FORWARD && get_func_id(g_szNewRoundHLTVCallBackpluginIndex) != -)
        {
            if( !
bHLTVRegistered )
            {
                
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
                
bHLTVRegistered true
            
}
            
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")
            
g_iNewRoundHLTV CreateMultiForward(g_szNewRoundHLTVCallBackET_IGNOREFP_CELL)
        }

        if( 
g_iMapCleanedUp == INVALID_FORWARD && get_func_id(g_szMapCleanedUpCallBackpluginIndex) != -)
        {
            if( !
bHLTVRegistered )
            {
                
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
                
bHLTVRegistered true
            
}

            
// m_usResetDecals = engfunc(EngFunc_PrecacheEvent, 1, "events/decal_reset.sc")
            
g_iMapCleanedUp CreateMultiForward(g_szMapCleanedUpCallBackET_IGNORE)
        }

        if( 
g_iMapCleanedUp != INVALID_FORWARD && g_iNewRoundHLTV != INVALID_FORWARD )
        {
            break
        }
    }
}

public 
Event_TextMsg_Restart()
{
    
g_bCompleteReset true
}

public 
Event_HLTV_New_Round()
{
    static 
iRoundNum 0

    
if( g_bCompleteReset )
    {
        
g_bCompleteReset false
        iRoundNum 
0
    
}

    
iRoundNum++

    if( 
g_iNewRoundHLTV != INVALID_FORWARD )
    {
        
ExecuteForwardg_iNewRoundHLTVg_iReturniRoundNum 
    }

    if( 
g_iMapCleanedUp != INVALID_FORWARD )
    {
        
g_iFhPlaybackEventPost register_forward(FM_PlaybackEvent"OnPlaybackEvent_Post"true)
    }
}

public 
OnPlaybackEvent_Post()
{
    
unregister_forward(FM_PlaybackEventg_iFhPlaybackEventPosttrue)
    
ExecuteForwardg_iMapCleanedUpg_iReturn )




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

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