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

[SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as needed)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-23-2013 , 11:45   [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as needed)
Reply With Quote #1

So, in NativeVotes, I need to know what game a server is running so I use the correct usermessages. I'd been using GuessSDKVersion, but this has been deprecated in favor of GetEngineVersion in newer 1.5 and 1.6 snapshots.

So, I wrote this stock to deal with it. It returns an EngineVersion. If the server supports GetEngineVersion, it returns that. Otherwise, it calls GuessSDKVersion and converts that value into an EngineVersion based on the engine version and game directory.

Note: Using this requires SourceMod 1.5 hg3864 or newer, or SourceMod 1.6 hg3961 or newer to compile.

Note 2: You must mark GetEngineVersion as optional to work on older versions... it's pointless to use this stock if you don't.

Note 3: You will get a compile warning using this as GuessSDKVersion is deprecated.

PHP Code:
// Using this stock REQUIRES you to add the following to AskPluginLoad2:
// MarkNativeAsOptional("GetEngineVersion");
stock EngineVersion:GetEngineVersionCompat()
{
    new 
EngineVersion:version;
    if (
GetFeatureStatus(FeatureType_Native"GetEngineVersion") != FeatureStatus_Available)
    {
        new 
sdkVersion GuessSDKVersion();
        switch (
sdkVersion)
        {
            case 
SOURCE_SDK_ORIGINAL:
            {
                
version Engine_Original;
            }
            
            case 
SOURCE_SDK_DARKMESSIAH:
            {
                
version Engine_DarkMessiah;
            }
            
            case 
SOURCE_SDK_EPISODE1:
            {
                
version Engine_SourceSDK2006;
            }
            
            case 
SOURCE_SDK_EPISODE2:
            {
                
version Engine_SourceSDK2007;
            }
            
            case 
SOURCE_SDK_BLOODYGOODTIME:
            {
                
version Engine_BloodyGoodTime;
            }
            
            case 
SOURCE_SDK_EYE:
            {
                
version Engine_EYE;
            }
            
            case 
SOURCE_SDK_CSS:
            {
                
version Engine_CSS;
            }
            
            case 
SOURCE_SDK_EPISODE2VALVE:
            {
                
decl String:gameFolder[PLATFORM_MAX_PATH];
                
GetGameFolderName(gameFolderPLATFORM_MAX_PATH);
                if (
StrEqual(gameFolder"dod"false))
                {
                    
version Engine_DODS;
                }
                else if (
StrEqual(gameFolder"hl2mp"false))
                {
                    
version Engine_HL2DM;
                }
                else
                {
                    
version Engine_TF2;
                }
            }
            
            case 
SOURCE_SDK_LEFT4DEAD:
            {
                
version Engine_Left4Dead;
            }
            
            case 
SOURCE_SDK_LEFT4DEAD2:
            {
                
decl String:gameFolder[PLATFORM_MAX_PATH];
                
GetGameFolderName(gameFolderPLATFORM_MAX_PATH);
                if (
StrEqual(gameFolder"nucleardawn"false))
                {
                    
version Engine_NuclearDawn;
                }
                else
                {
                    
version Engine_Left4Dead2;
                }
            }
            
            case 
SOURCE_SDK_ALIENSWARM:
            {
                
version Engine_AlienSwarm;
            }
            
            case 
SOURCE_SDK_CSGO:
            {
                
version Engine_CSGO;
            }
            
            default:
            {
                
version Engine_Unknown;
            }
        }
    }
    else
    {
        
version GetEngineVersion();
    }
    
    return 
version;

Let me know if you know of other games that need to be converted that aren't explicitly in this list.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-03-2013 at 09:32.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 08-23-2013 , 12:58   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #2

Nice idea.
psychonic is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-01-2013 , 16:58   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #3

How to use this stock please ?

Sincerely,
eric0279 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-01-2013 , 17:01   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #4

Quote:
Originally Posted by eric0279 View Post
How to use this stock please ?

Sincerely,
You put it in your script and call it instead of GetEngineVersion. It returns an EngineVersion. Then you compare that to Engine_CSGO, Engine_TF2, etc... to find out what game it is.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-01-2013 , 22:34   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #5

a example please ?

I have add this stock and MarkNativeAsOptional("GetEngineVersion"); in to block but same warning...

PHP Code:
if (GetEngineVersion() == Engine_Left4Dead){ 
should be ?

I tested :
PHP Code:
if (GetEngineVersionCompat()== Engine_Left4Dead){ 
PHP Code:
if (EngineVersion:GetEngineVersionCompat() == Engine_Left4Dead){{ 
return :
Quote:
//l4d_votepoll_fix.
sp(14 : warning 234: symbol "GuessSDKVersion" is marked as deprecated: See Get
EngineVersion()
Thanks for answer Powerlord.
eric0279 is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 09-01-2013 , 23:05   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #6

read "note 3" of the post.
Code:
if(GetEngineVersionCompat() == Engine_Left4Dead)
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-01-2013 , 23:28   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #7

ok I did not pay attention so it does serve me for nothing if I do not want a warning.

Thank you.
eric0279 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-02-2013 , 00:55   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #8

Quote:
Originally Posted by eric0279 View Post
ok I did not pay attention so it does serve me for nothing if I do not want a warning.

Thank you.
The only purpose for this snippet is to have compatibility with 1.4 and older 1.5 hg releases in addition to the newer 1.5 hg releases.

Unfortunately, that will add a warning instead of just completely failing to run on those.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-02-2013 at 00:55.
Powerlord is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 09-02-2013 , 00:59   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #9

om#g. wt#?
you are not going to use an useful feature because of a warning?
warnings and errors(by errors i mean some that appear at the game console) aren't necessarily bad things. in this case, the warning is needed to bring compatibility of this function to hosts using an old version of sourcemod.
@edit: sorry, by the time i wrote this, powerlord hadn't replied yet.
__________________
sie sind das essen und wir sind die jäger!

Last edited by Bimbo1; 09-02-2013 at 01:01.
Bimbo1 is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-02-2013 , 07:21   Re: [SNIPPET] GetEngineVersionCompat (use GetEngineVersion or GuessSDKVersion as need
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
The only purpose for this snippet is to have compatibility with 1.4 and older 1.5 hg releases in addition to the newer 1.5 hg releases.

Unfortunately, that will add a warning instead of just completely failing to run on those.
I thought that would remove the warning.

Quote:
om#g. wt#?
you are not going to use an useful feature because of a warning?
warnings and errors(by errors i mean some that appear at the game console) aren't necessarily bad things. in this case, the warning is needed to bring compatibility of this function to hosts using an old version of sourcemod.
yes

The function is great but I do not like having warning
eric0279 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 08:00.


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