AlliedModders

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

Backstabnoob 06-06-2012 14:10

changelevel
 
Is there any way to hook "changelevel" command, so you can change the map to something else before the server does?

jimaway 06-06-2012 14:25

Re: changelevel
 
public server_changelevel ( map[] )

rak 06-06-2012 19:37

Re: changelevel
 
or you can hook the intermission and change the map or change the cvar "amx_nextmap"

ConnorMcLeod 06-07-2012 00:21

Re: changelevel
 
To hook changelevel command i'm affraid you have to hook engine, using orpheu or rage module.

hornet 06-07-2012 09:59

Re: changelevel
 
Quote:

Originally Posted by jimaway (Post 1723804)
public server_changelevel ( map[] )

There's no return for that forward. It's called afterwards.


You can't actually hook CGameRules::ChangeLevel, use GoToIntermission instead. The advantage of this is that it will not be called when a server admin changes the map via amxmodmenu or amx_map:

Code:
#include <amxmodx> #include <orpheu> #include <orpheu_stocks> new g_pGameRules; public plugin_precache() {     OrpheuRegisterHook( OrpheuGetFunction( "InstallGameRules" ), "On_InstallGameRules", OrpheuHookPost ); } public plugin_init() {     OrpheuRegisterHookFromObject( g_pGameRules, "GoToIntermission", "CGameRules", "On_GoToIntermission" ); } public On_InstallGameRules() {     g_pGameRules = OrpheuGetReturn(); } public OrpheuHookReturn: On_GoToIntermission() {     /* Change level / set short task to change level here / change amx_nextmap */ }

WaLkMaN 05-06-2023 09:53

Re: changelevel
 
Quote:

Originally Posted by hornet (Post 1724258)
There's no return for that forward. It's called afterwards.


You can't actually hook CGameRules::ChangeLevel, use GoToIntermission instead. The advantage of this is that it will not be called when a server admin changes the map via amxmodmenu or amx_map:

Code:
#include <amxmodx> #include <orpheu> #include <orpheu_stocks> new g_pGameRules; public plugin_precache() {     OrpheuRegisterHook( OrpheuGetFunction( "InstallGameRules" ), "On_InstallGameRules", OrpheuHookPost ); } public plugin_init() {     OrpheuRegisterHookFromObject( g_pGameRules, "GoToIntermission", "CGameRules", "On_GoToIntermission" ); } public On_InstallGameRules() {     g_pGameRules = OrpheuGetReturn(); } public OrpheuHookReturn: On_GoToIntermission() {     /* Change level / set short task to change level here / change amx_nextmap */ }

With ReAPI:

Code:
#include <amxmodx> #include <reapi> public plugin_init() {     RegisterHookChain( RG_CSGameRules_GoToIntermission, "On_GoToIntermission", true ); } public On_GoToIntermission() {     /* Change level / set short task to change level here / change amx_nextmap */ }


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

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