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

Solved Plugin not auto-generating gamedata file.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 01-12-2020 , 04:01   Plugin not auto-generating gamedata file.
Reply With Quote #1

A plugin I made is failing to auto-generate a gamedata file, thus rendering all SDKCalls moot and failing to load the plugin.
No gamedata file of the name "l4d2_passing_fix" appears.
I followed this 2 year old post's gamedata auto-generation code, so I'm still not sure why it wouldn't work.

Tested in L4D2 listen + local server.

Code:
L 01/12/2020 - 16:54:51: [SM] Exception reported: Unable to find NextBotCreatePlayerBot<SurvivorBot> signature in gamedata file.
L 01/12/2020 - 16:54:51: [SM] Blaming: testpassingbot.smx
L 01/12/2020 - 16:54:51: [SM] Call stack trace:
L 01/12/2020 - 16:54:51: [SM]   [0] SetFailState
L 01/12/2020 - 16:54:51: [SM]   [1] Line 276, C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\TestPassingBot.sp::PrepSDKCall
L 01/12/2020 - 16:54:51: [SM]   [2] Line 267, C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\TestPassingBot.sp::GetGamedata
L 01/12/2020 - 16:54:51: [SM]   [3] Line 61, C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\TestPassingBot.sp::OnPluginStart
[SM] Plugin testpassingbot.smx failed to load: Error detected in plugin startup (see error logs).
Attached Files
File Type: sp Get Plugin or Get Source (TestPassingBot.sp - 193 views - 8.4 KB)

Last edited by Shadowysn; 01-12-2020 at 07:08.
Shadowysn is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-12-2020 , 05:20   Re: Plugin not auto-generating gamedata file.
Reply With Quote #2

PHP Code:
#include <sdktools> // You have this which already includes:
// #include <sdktools_functions> // So this isn't needed



// Change this:
#define SIG_CreateSurvivorBot_WINDOWS "\x55\x8B\x2A\x83\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\x2A\x89\x2A\x2A\x56\x57\x8B\x2A\x2A\x68\x90\x2A\x2A\x2A"

// To:
#define SIG_CreateSurvivorBot_WINDOWS "\\x55\\x8B\\x2A\\x83\\x2A\\x2A\\xA1\\x2A\\x2A\\x2A\\x2A\\x33\\x2A\\x89\\x2A\\x2A\\x56\\x57\\x8B\\x2A\\x2A\\x68\\x90"
// Also no point having the additional wildcards \x2A at the end.



// You have this:
    
if (!IsValidEntity(client)) return false;
    if (
client <= || client MaxClients) return false;

// I would:
    
if (client <= || client MaxClients) return false// Check value first before IsValidEntity...
    // if (!IsValidEntity(client)) return false; // You can just delete this line completely.
    
if (!IsClientInGame(client)) return false// Because you have this and the value range check.



// You create 100 byte string, but only need 10 chars to check "c6m3_port" (9 chars + null byte)
// char CurrentMap[100];
char CurrentMap[10];



// Change:
    
hConf LoadGameConfigFile(GAMEDATA);
    if (
hConf == null)
    {
        
PrintToServer("[SM] %s unable to get %s.txt gamedata file. Generating..."PLUGIN_NAMEGAMEDATA);
        
char filePath[PLATFORM_MAX_PATH];
        
BuildPath(Path_SMfilePathsizeof(filePath), "gamedata/%s.txt"GAMEDATA);
        
        
Handle fileHandle OpenFile(filePath"a+"); // Why append to the file?

// To:
    
char filePath[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMfilePathsizeof(filePath), "gamedata/%s.txt"GAMEDATA);
    if( 
FileExists(filePath) )
    {
        
hConf LoadGameConfigFile(GAMEDATA); // For some reason this doesn't return null even for invalid files, so check they exist first.
    
} else {
        
PrintToServer("[SM] %s unable to get %s.txt gamedata file. Generating..."PLUGIN_NAMEGAMEDATA);
        
        
Handle fileHandle OpenFile(filePath"w"); 






Aside from that, you don't need SDKCall to create survivor bot. I use this modified from Bebop plugin:
PHP Code:
public Action sm_bot(int clientint args)
{
    
// init ret value
    
bool ret false;
    
    
// create fake client
    
client 0;
    
client CreateFakeClient("bebop_bot_fakeclient");
    
    
// if entity is valid
    
if (client != 0)
    {
        
// move into survivor team
        
ChangeClientTeam(client2);
        
//FakeClientCommand(client, "jointeam %i", ID_TEAM_SURVIVOR);
        
        // set entity classname to survivorbot
        
if (DispatchKeyValue(client"classname""survivorbot") == true)
        {
            
// spawn the client
            
if (DispatchSpawn(client) == true)
            {
                if( 
args == )
                    
CreateTimer(1.0Timer_KickBebopFakeClientGetClientUserId(client), TIMER_REPEAT);
                
ret true;
            }
        }
        
        
// if something went wrong kick the created fake client
        
if (ret == false)
        {
            
KickClient(client"");
        }
    }

    return 
Plugin_Handled;
}
public 
Action Timer_KickBebopFakeClient(Handle timerany client)
{
    
client GetClientOfUserId(client);
    if (
client && IsClientConnected(client))
    {
        
KickClient(client"client_is_bebop_fakeclient");
    }
    
    return 
Plugin_Stop;

__________________
Silvers is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 01-12-2020 , 07:06   Re: Plugin not auto-generating gamedata file.
Reply With Quote #3

Quote:
Originally Posted by Silvers View Post
PHP Code:
#include <sdktools> // You have this which already includes:
// #include <sdktools_functions> // So this isn't needed



// Change this:
#define SIG_CreateSurvivorBot_WINDOWS "\x55\x8B\x2A\x83\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\x2A\x89\x2A\x2A\x56\x57\x8B\x2A\x2A\x68\x90\x2A\x2A\x2A"

// To:
#define SIG_CreateSurvivorBot_WINDOWS "\\x55\\x8B\\x2A\\x83\\x2A\\x2A\\xA1\\x2A\\x2A\\x2A\\x2A\\x33\\x2A\\x89\\x2A\\x2A\\x56\\x57\\x8B\\x2A\\x2A\\x68\\x90"
// Also no point having the additional wildcards \x2A at the end.



// You have this:
    
if (!IsValidEntity(client)) return false;
    if (
client <= || client MaxClients) return false;

// I would:
    
if (client <= || client MaxClients) return false// Check value first before IsValidEntity...
    // if (!IsValidEntity(client)) return false; // You can just delete this line completely.
    
if (!IsClientInGame(client)) return false// Because you have this and the value range check.



// You create 100 byte string, but only need 10 chars to check "c6m3_port" (9 chars + null byte)
// char CurrentMap[100];
char CurrentMap[10];



// Change:
    
hConf LoadGameConfigFile(GAMEDATA);
    if (
hConf == null)
    {
        
PrintToServer("[SM] %s unable to get %s.txt gamedata file. Generating..."PLUGIN_NAMEGAMEDATA);
        
char filePath[PLATFORM_MAX_PATH];
        
BuildPath(Path_SMfilePathsizeof(filePath), "gamedata/%s.txt"GAMEDATA);
        
        
Handle fileHandle OpenFile(filePath"a+"); // Why append to the file?

// To:
    
char filePath[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMfilePathsizeof(filePath), "gamedata/%s.txt"GAMEDATA);
    if( 
FileExists(filePath) )
    {
        
hConf LoadGameConfigFile(GAMEDATA); // For some reason this doesn't return null even for invalid files, so check they exist first.
    
} else {
        
PrintToServer("[SM] %s unable to get %s.txt gamedata file. Generating..."PLUGIN_NAMEGAMEDATA);
        
        
Handle fileHandle OpenFile(filePath"w"); 






Aside from that, you don't need SDKCall to create survivor bot. I use this modified from Bebop plugin:
PHP Code:
public Action sm_bot(int clientint args)
{
    
// init ret value
    
bool ret false;
    
    
// create fake client
    
client 0;
    
client CreateFakeClient("bebop_bot_fakeclient");
    
    
// if entity is valid
    
if (client != 0)
    {
        
// move into survivor team
        
ChangeClientTeam(client2);
        
//FakeClientCommand(client, "jointeam %i", ID_TEAM_SURVIVOR);
        
        // set entity classname to survivorbot
        
if (DispatchKeyValue(client"classname""survivorbot") == true)
        {
            
// spawn the client
            
if (DispatchSpawn(client) == true)
            {
                if( 
args == )
                    
CreateTimer(1.0Timer_KickBebopFakeClientGetClientUserId(client), TIMER_REPEAT);
                
ret true;
            }
        }
        
        
// if something went wrong kick the created fake client
        
if (ret == false)
        {
            
KickClient(client"");
        }
    }

    return 
Plugin_Handled;
}
public 
Action Timer_KickBebopFakeClient(Handle timerany client)
{
    
client GetClientOfUserId(client);
    if (
client && IsClientConnected(client))
    {
        
KickClient(client"client_is_bebop_fakeclient");
    }
    
    return 
Plugin_Stop;

Oh man, I've been doing all the signature defines and config checks wrong... I'm gonna have to re-edit the rest of the sig defines for my plugins.

By the way, I was attempting to spawn a bot for The Passing Survivors team, not the Main Survivors team. Remember Edison's post?
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4

Last edited by Shadowysn; 01-12-2020 at 07:31.
Shadowysn is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-12-2020 , 12:10   Re: Plugin not auto-generating gamedata file.
Reply With Quote #4

Quote:
Originally Posted by Shadowysn View Post
Oh man, I've been doing all the signature defines and config checks wrong... I'm gonna have to re-edit the rest of the sig defines for my plugins.

By the way, I was attempting to spawn a bot for The Passing Survivors team, not the Main Survivors team. Remember Edison's post?
You can check my Holdout plugin which does the same thing basically, except I block that map due to various problems.
__________________
Silvers is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 01-14-2020 , 06:46   Re: Plugin not auto-generating gamedata file.
Reply With Quote #5

Quote:
Originally Posted by Silvers View Post
You can check my Holdout plugin which does the same thing basically, except I block that map due to various problems.
I wanted to spawn survivor bots for The Passing team without dabbling with the Main Survivors team's netprops, which involved me having to find the signature for NextBotCreatePlayerBot<SurvivorBot>.

You're using info_l4d1_survivor_spawn in your Holdout plugin plus changing the Main Survivor's netprops.
Basically, I'm going with 'better safe than sorry'. (Using a signature instead of modifying the survivor netprops.)
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4

Last edited by Shadowysn; 01-14-2020 at 06:51.
Shadowysn is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-14-2020 , 06:57   Re: Plugin not auto-generating gamedata file.
Reply With Quote #6

Quote:
Originally Posted by Shadowysn View Post
plus changing the Main Survivor's netprops.
They're only changed away from the netprop of the holdout survivor spawning and changed back straight away. This is to avoid normal players being teleported to the holdout survivors position due to them having the same netprop, that's just the way the game works and was coded.
__________________
Silvers is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 01-14-2020 , 08:08   Re: Plugin not auto-generating gamedata file.
Reply With Quote #7

Quote:
Originally Posted by Silvers View Post
They're only changed away from the netprop of the holdout survivor spawning and changed back straight away. This is to avoid normal players being teleported to the holdout survivors position due to them having the same netprop, that's just the way the game works and was coded.
Didn't mean to say they're changed permanently, just that they were changed.
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4
Shadowysn is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-14-2020 , 08:25   Re: Plugin not auto-generating gamedata file.
Reply With Quote #8

Quote:
Originally Posted by Shadowysn View Post
Didn't mean to say they're changed permanently, just that they were changed.
I don't know why mentioned it anyway? What's the problem?

PHP Code:
    AvoidCharacter(charactertrue);
    
AcceptEntityInput(entity"SpawnSurvivor");
    
AvoidCharacter(characterfalse); 
Change, spawn, change back.

Anyway glad your method is working.
__________________

Last edited by Silvers; 01-14-2020 at 09:20.
Silvers is offline
Reply


Thread Tools
Display Modes

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 11:14.


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