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

[EXTENSION] Config (1.0.2)


Post New Thread Reply   
 
Thread Tools Display Modes
psychonic

BAFFLED
Join Date: May 2008
Old 08-14-2011 , 10:49   Re: [EXTENSION] Config (1.0.2)
Reply With Quote #51

Quote:
Originally Posted by Mr. Zero View Post
I'm unable to load this extension on a L4D2 server.

Code:
[09] <FAILED> file "config.ext.so": Could not find interface: ISourceMod

sm exts info 09
    File: config.ext.so
    Loaded: No (Could not find interface: ISourceMod)
Server info:
Code:
Version 2.0.8.2 (left4dead2)
Network Version 2.0.4.2
Exe build: 20:51:49 Aug  8 2011 (4657) (550)

Metamod:Source version 1.8.7
Build ID: 772:99b7a0a11fec
Loaded As: Valve Server Plugin
Compiled on: Jun 23 2011
Plugin interface version: 15:14
SourceHook version: 5:5
http://www.metamodsource.net/

SourceMod Version Information:
SourceMod Version: 1.3.8
SourcePawn Engine: SourcePawn 1.1, jit-x86 (build 1.3.8)
SourcePawn API: v1 = 4, v2 = 3
Compiled on: Jun 24 2011 17:50:35
Build ID: 3157:cf41e7301d55
http://www.sourcemod.net/
Sounds like it was possibly compiled against a newer version of SM (a 1.4 build) and so it's failing when not finding the newer version of the ISourcemod iface.
psychonic is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 03-11-2012 , 19:14   Re: [EXTENSION] Config (1.0.2)
Reply With Quote #52

I've asked in this post earlier how I can read the following out of an conf file:
Example of de_dust2 (Counter-Strike:Source)
Code:
spawnpointslist = ( 
  {
    position = [ 448.0, 2464.0, -88.0 ];
    angle = [ 0.0, 255.0, 0.0 ];
    classname = "info_player_counterterrorist";
  }, 
  {
    position = [ 352.0, 2464.0, -88.0 ];
    angle = [ 0.0, 255.0, 0.0 ];
    classname = "info_player_counterterrorist";
  }, 
  {
    position = [ 256.0, 2464.0, -88.0 ];
    angle = [ 0.0, 255.0, 0.0 ];
    classname = "info_player_counterterrorist";
  }, 
[...]
  {
    position = [ -1892.041138, 1261.15564, 32.03125 ];
    angle = [ 7.692320347, -155.0625458, 0.0 ];
    classname = "info_player_terrorist";
  } );
Berni helped me a lot, so thank you Berni!
He pointed out the different types in libconfig (http://www.hyperrealm.com/libconfig/....html#Settings)

So in the example above, we have a list called spawnpointslist, it contains groups (groups can't have names) and those groups contains values (array, array and string for position, angle and classname).

Load:
To read/load this file I'm using the following code:
PHP Code:
stock LoadSpawnPointsFromFile(){
    
    new 
Handle:hSpawnPointsList ConfigLookup(g_hSpawnPoint_MapConfig"spawnpointslist");
    if(
hSpawnPointsList == INVALID_HANDLE){
        
        
LogError("can't load spawn points from file, it appears to be empty");
        return;
    }
    new 
length ConfigSettingLength(hSpawnPointsList);
    
    for (new 
i=0i<lengthi++) {
        
        new 
Handle:hSpawnPoint ConfigSettingGetElement(hSpawnPointsListi);
        
        new 
Handle:hPosition ConfigSettingGetMember(hSpawnPoint"position");
        new 
Float:position[3];
        
ConfigSettingGetVector(hPosition,position);
        
        
//PrintToServer("LOAD spawnpoint - %fx; %fy; %fz;",position[0],position[1],position[2]);
        
        
new Handle:hAngle ConfigSettingGetMember(hSpawnPoint"angle");
        new 
Float:angle[3];
        
ConfigSettingGetVector(hAngle,angle);
        
        new 
Handle:hClassname ConfigSettingGetMember(hSpawnPoint"classname");
        new 
String:classname[MAX_NAME_LENGTH];
        
ConfigSettingGetString(hClassnameclassnamesizeof(classname));
        
        
CreateSpawnPoint(position,angle,classname);
        
//never close setting handles!
    
}
    
    
LogMessage("loaded %d spawn points from file",length);
    
//dont close the global config handle to keep using it for the hole map.

The easy way to get an array with a size of 3 (aka vector):
PHP Code:
stock ConfigSettingGetVector(Handle:SettingFloat:vec[3]){
    
    
vec[0] = ConfigSettingGetFloat(ConfigSettingGetElement(Setting0));
    
vec[1] = ConfigSettingGetFloat(ConfigSettingGetElement(Setting1));
    
vec[2] = ConfigSettingGetFloat(ConfigSettingGetElement(Setting2));

Save:
So I want to save those spawn points too.
I'm using 2 functions for this, since I want to save one spawn point only or all at once.
PHP Code:
stock SaveSpawnPointsToFile(const bool:fetchSpawnPointsFirst=false){
    
    new 
countSpawnPoints 0;
    
    if(
fetchSpawnPointsFirst){
        
        
//'clear' spawn points memory by creating a new config handle
        
CloseHandle(g_hSpawnPoint_MapConfig);
        
g_hSpawnPoint_MapConfig ConfigCreate();
        
ConfigSettingAdd(ConfigRootSetting(g_hSpawnPoint_MapConfig),"spawnpointslist",ST_List);
        
        for(new 
i=0;i<sizeof(g_szSpawnPointClassNames);i++){
            
            new 
entity = -1;
            while ((
entity FindEntityByClassname(entityg_szSpawnPointClassNames[i])) != INVALID_ENT_REFERENCE) {
                
                new 
Float:position[3];
                
Entity_GetAbsOrigin(entity,position);
                
                new 
Float:angle[3];
                
Entity_GetAbsAngles(entity,angle);
                
                
SaveSpawnPoint(position,angle,g_szSpawnPointClassNames[i]);
                
                
countSpawnPoints++;
                
//never close setting handles!
            
}
        }
    }
    else {
        
        
countSpawnPoints ConfigSettingLength(ConfigLookup(g_hSpawnPoint_MapConfig"spawnpointslist"));
    }
    
    if(
ConfigWriteFile(g_hSpawnPoint_MapConfig,g_szConfig_Path)){
        
        
LogMessage("successfully written %d spawn points into a file at %s",countSpawnPoints,g_szConfig_Path);
    }
    else {
        
        
SetFailState("can't write file at %s",g_szConfig_Path);
    }
    
//dont close the global config handle to keep using it for the hole map.

So this actually does the push into the config handle:
PHP Code:
stock SaveSpawnPoint(const Float:position[3], const Float:angle[3], const String:classname[MAX_NAME_LENGTH]){
    
    new 
Handle:hSpawnPointsList ConfigLookup(g_hSpawnPoint_MapConfig"spawnpointslist");
    
    new 
Handle:hSpawnPoint ConfigSettingAdd(hSpawnPointsList,"spawnpoint",ST_Group);
    
    new 
Handle:hPosition ConfigSettingAdd(hSpawnPoint,"position",ST_Array);
    
ConfigSettingSetVector(hPositionposition);
    
    
//PrintToServer("spawnpoint %d - %fx; %fy; %fz;",entity,position[0],position[1],position[2]);
    
    
new Handle:hAngle ConfigSettingAdd(hSpawnPoint,"angle",ST_Array);
    
ConfigSettingSetVector(hAngleangle);
    
    new 
Handle:hClassname ConfigSettingAdd(hSpawnPoint,"classname",ST_String);
    
ConfigSettingSetString(hClassname,classname);
    
    
//DON'T CLOSE SETTING HANDLES!

The easy way to set an array with a size of 3 (aka vector):
PHP Code:
stock ConfigSettingSetVector(Handle:Setting, const Float:vec[3]){
    
    
ConfigSettingSetFloat(ConfigSettingAdd(Setting,"",ST_Float), vec[0]);
    
ConfigSettingSetFloat(ConfigSettingAdd(Setting,"",ST_Float), vec[1]);
    
ConfigSettingSetFloat(ConfigSettingAdd(Setting,"",ST_Float), vec[2]);

I hope this helps those who are stuck like I was.
Please don't as questions about this code snipped in this thread, to keep this thread clean!
Contact me via PM and I'll answer your questions and edit this post.
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]

Last edited by Chanz; 05-03-2012 at 07:40.
Chanz is offline
painkiller
Senior Member
Join Date: Jun 2011
Old 05-15-2015 , 16:38   Re: [EXTENSION] Config (1.0.2)
Reply With Quote #53

Hi, i have this problem in Black Mesa Source.

[SM] Unable to load extension "config.ext": /home/gameserver/server/bms/bms/addons/sourcemod/extensions/config.ext.so: cannot open shared object file: No such file or directory
painkiller 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 01:44.


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