AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Check Running Mod (https://forums.alliedmods.net/showthread.php?t=300013)

DarthMan 08-02-2017 07:33

[ H3LP ] Check Running Mod
 
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 !

edon1337 08-02-2017 07:44

Re: [ H3LP ] Check Running Mod
 
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 ;



DarthMan 08-02-2017 07:50

Re: [ H3LP ] Check Running Mod
 
Quote:

Originally Posted by edon1337 (Post 2539242)
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.

edon1337 08-02-2017 08:03

Re: [ H3LP ] Check Running Mod
 
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.

klippy 08-02-2017 08:04

Re: [ H3LP ] Check Running Mod
 
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.


All times are GMT -4. The time now is 22:50.

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