Raised This Month: $51 Target: $400
 12% 

Map change event?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-20-2017 , 15:25   Map change event?
Reply With Quote #1

https://forums.alliedmods.net/showthread.php?t=302153 - currently the plugin displays the MOTD only when the map changes normally. If an admin changes it with amx_map or a plugin delays the change, the event won't be triggered. I'm using register_message(SVC_INTERMISSION, "OnIntermission") - any other alternative?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
JusTGo
Veteran Member
Join Date: Mar 2013
Old 10-20-2017 , 15:59   Re: Map change event?
Reply With Quote #2

only for amxx 1.8.3:
PHP Code:
/**
 * Called when the mod tries to change the map.
 *
 * @note This is *only* called if the mod itself handles the map change. The
 *       server command "changelevel", which is used by many plugins, will not
 *       trigger this forward. Unfortunately, this means that in practice this
 *       forward can be unreliable and will not be called in many situations.
 * @note AMXX 1.8.3 has added the engine_changelevel() function, which will utilize
 *       the correct engine function to change the map, and therefore trigger
 *       this forward.
 *
 * @param map   Map that the mod tries to change to
 *
 * @return      PLUGIN_CONTINUE to let the mod change the map
 *              PLUGIN_HANDLED or higher to prevent the map change
 */
forward server_changelevel(map[]); 
__________________
JusTGo is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-20-2017 , 17:01   Re: Map change event?
Reply With Quote #3

According to the description, it does the same thing.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-20-2017 , 17:57   Re: Map change event?
Reply With Quote #4

IIRC, when SVC_INTERMISSION is triggered, the scoreboard is shown and you can't show anything over it (at least in DOD).

When you change the map with amx_map, the map is changed immediately so there is no time to show anything anyways.
__________________
fysiks is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 10-20-2017 , 18:15   Re: Map change event?
Reply With Quote #5

in amxx 1.8.3 amx_map uses engine_changelevel that triggers server_changelevel() so you can return plugin handled there show your motd then set a task to change the map. but yeah map managers plugin idk if this works for them for ex: galileo...ect
__________________
JusTGo is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 10-21-2017 , 03:43   Re: Map change event?
Reply With Quote #6

According to fysik's reply, you have no other choice but editing the amx_map .sma and creating a new forward that will be called when amx_map CMD is called (register_concmd).
__________________

Last edited by edon1337; 10-21-2017 at 03:44.
edon1337 is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 10-21-2017 , 06:23   Re: Map change event?
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
IIRC, when SVC_INTERMISSION is triggered, the scoreboard is shown and you can't show anything over it (at least in DOD).

When you change the map with amx_map, the map is changed immediately so there is no time to show anything anyways.
You can display some stuff at least on CS, with manually triggered intermission you can do almost anything, so I guess it's the same with the end-of-map one too.


@OP, when changing with amx_map / amx_mapmenu or whatever, even if you manage to hook it, I doubt you will be able to display anything, and if the motd even loads in time for the players, they won't get to read anything

for your plugin I would suggest writing in the docs suggesting people to change mp_chattime to something longer so people have time to read, and providing alternatives to the original amxmodx admin plugins (admincmd, vote, menu, votemenu) where you change the map gracefully. I know it sounds like a pain in the ass but it's possible, look at Advanced Bans with banmenu.

it's a nice plugin so I hope there's some better alternative but I doubt it
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-21-2017 , 11:09   Re: Map change event?
Reply With Quote #8

This will detect any time a map is changed, regardless of how it was done. Unfortunately it's not a simple 1-line event method but it works.

Detection method:
  • Current map is different than previous map
  • The time the previous map was saved (on mapchange/restart) in the vault is less than X seconds ago.
PHP Code:

#include <amxmodx>
#include <nvault>

new const Version[] = "0.1";

new 
g_Vault;

new 
MapChangeThreshold 3;

public 
plugin_init() 
{
    
register_plugin"Map Change Detector" Version "bugsy" );

    
g_Vault nvault_open"mapchangedetection" );
    
    new 
szPrevMapName32 ] , iTimestamp szCurrentMapName32 ];
    
    
get_mapnameszCurrentMapName charsmaxszCurrentMapName ) );
    
    if ( 
nvault_lookupg_Vault "PrevMapName" szPrevMapName charsmaxszPrevMapName ) , iTimestamp ) && ( ( get_systime() - iTimestamp ) <= MapChangeThreshold ) && !equalszPrevMapName szCurrentMapName ) )
    {
        
//Map change
    
}
}

public 
plugin_end()
{
    new 
szMapName32 ];
    
    
get_mapnameszMapName charsmaxszMapName ) );
    
    
nvault_setg_Vault "PrevMapName" szMapName );
    
    
nvault_closeg_Vault );

__________________

Last edited by Bugsy; 10-21-2017 at 11:10.
Bugsy is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 10-21-2017 , 12:03   Re: Map change event?
Reply With Quote #9

Nice Bugsy but I don't think that will help him. He want's to show a MOTD before the map is changed to a new map.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-21-2017 , 12:16   Re: Map change event?
Reply With Quote #10

Ah my bad, I didn't click the link to his plugin.

I have an idea.. I'll work on it and post if it works.
__________________
Bugsy is offline
Reply



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 02:53.


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