Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Check Running Mod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 08-02-2017 , 07:33   [ H3LP ] Check Running Mod
Reply With Quote #1

Hello. is there any way to check if the mod is HL or TFC before plugin-init where the global vars and other stuff are defined? I want to set some of the default models depending on the mod, valve or tfc. So for example if the game is hl, var[] = "a model" , for tfc var[] = "another model". Thanks !

Last edited by DarthMan; 08-02-2017 at 08:54. Reason: Solved
DarthMan is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-02-2017 , 07:44   Re: [ H3LP ] Check Running Mod
Reply With Quote #2

PHP Code:
#include < amxmodx >

new szDefaultModel32 ] ;

public 
plugin_precache( ) {

    new 
szModName10 ] ;
    
get_modnameszModNamecharsmaxszModName ) ) ;

    if( 
equalszModName"valve" ) ) 
    
copyszDefaultModelcharsmaxszDefaultModel ), "hl.mdl" ) ;
    
    else if( 
equalszModName"tfc" ) )
    
copyszDefaultModelcharsmaxszDefaultModel ), "tfc.mdl" ) ;

    return 
PLUGIN_CONTINUE ;

__________________

Last edited by edon1337; 08-02-2017 at 08:19.
edon1337 is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 08-02-2017 , 07:50   Re: [ H3LP ] Check Running Mod
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
PHP Code:
#include < amxmodx >

new szDefaultModel32 ] ;

public 
plugin_precache( ) {

    new 
szModName12 ] ;
    
get_modnameszModNamecharsmaxszModName ) ) ;

    if( 
equalszModName"valve" ) ) 
    
copyszDefaultModelcharsmaxszDefaultModel ), "hl.mdl" ) ;
    
    else if( 
equalszModName"tfc" ) )
    
copyszDefaultModelcharsmaxszDefaultModel ), "tfc.mdl" ) ;

    return 
PLUGIN_CONTINUE ;

So it can not be done other way so that the array size won't be defined? I mean in the include part. Something like #if blabla #endif.
DarthMan is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-02-2017 , 08:03   Re: [ H3LP ] Check Running Mod
Reply With Quote #4

AFAIK plugin_natives is the first called function but I'm not sure what #if and #endif have to do with this because they're used by the compiler. If you mean that when the code inside #if and #endif is called I'm not really sure.
__________________

Last edited by edon1337; 08-02-2017 at 08:09.
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-02-2017 , 08:04   Re: [ H3LP ] Check Running Mod
Reply With Quote #5

No, #if, #endif and similar (preprocessor directives) are evaluated at compile-time. The compiler can't know on which game you'll be running your plugin.
You can let the user compiling your code to choose it by having them define what game it is (like #define GAME_TFC or #define GAME_VALVE) but that's as far as you can get, you'll have to resort to runtime checks, like what Edon has shown.

Last edited by klippy; 08-02-2017 at 08:05.
klippy 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 22:50.


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