Raised This Month: $32 Target: $400
 8% 

To hook or not to hook, that is the question.


Post New Thread Reply   
 
Thread Tools Display Modes
PatriotGames
AlliedModders Donor
Join Date: Feb 2012
Location: root@irs:/# rm -rf /
Old 02-15-2019 , 20:46   Re: To hook or not to hook, that is the question.
Reply With Quote #11

Quote:
Originally Posted by Ilusion9 View Post
Or to block that change to happen.

PHP Code:

public void OnPluginStart() 

    
g_cvMPGameMode FindConVar("mp_gamemode"); 

    if (
g_cvMPGameMode != null
    { 
        
g_cvMPGameMode.AddChangeHook(vMPGameModeHook); 
    } 



public 
void vMPGameModeHook(ConVar convar, const char[] oldVal, const char[] newVal

    if (!
StrEqual(newVal"versus")) 
    { 
        
g_cvMPGameMode.SetString("versus"));
    } 

Thanks for that practical example. Having run public co-op and versus servers for years, I can appreciate the ability to force or lock the server's game mode.

PG
PatriotGames is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 02-16-2019 , 09:51   Re: To hook or not to hook, that is the question.
Reply With Quote #12

Quote:
Originally Posted by Ilusion9 View Post
Or to block that change to happen.

PHP Code:

public void OnPluginStart() 

    
g_cvMPGameMode FindConVar("mp_gamemode"); 

    if (
g_cvMPGameMode != null
    { 
        
g_cvMPGameMode.AddChangeHook(vMPGameModeHook); 
    } 



public 
void vMPGameModeHook(ConVar convar, const char[] oldVal, const char[] newVal

    if (!
StrEqual(newVal"versus")) 
    { 
        
g_cvMPGameMode.SetString("versus"));
    } 

This. I see servers all the time where players entering via lobby accidentally will change the server settings. An extremely-easy fix for what seems to plague a lot of operators.
Skyy 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 21:55.


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