AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Plugin not auto-generating gamedata file. (https://forums.alliedmods.net/showthread.php?t=320841)

Shadowysn 01-12-2020 04:01

Plugin not auto-generating gamedata file.
 
1 Attachment(s)
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).


Silvers 01-12-2020 05:20

Re: Plugin not auto-generating gamedata file.
 
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;



Shadowysn 01-12-2020 07:06

Re: Plugin not auto-generating gamedata file.
 
Quote:

Originally Posted by Silvers (Post 2679868)
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?

Silvers 01-12-2020 12:10

Re: Plugin not auto-generating gamedata file.
 
Quote:

Originally Posted by Shadowysn (Post 2679873)
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.

Shadowysn 01-14-2020 06:46

Re: Plugin not auto-generating gamedata file.
 
Quote:

Originally Posted by Silvers (Post 2679923)
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. :P
Basically, I'm going with 'better safe than sorry'. (Using a signature instead of modifying the survivor netprops.)

Silvers 01-14-2020 06:57

Re: Plugin not auto-generating gamedata file.
 
Quote:

Originally Posted by Shadowysn (Post 2680181)
plus changing the Main Survivor's netprops. :P

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.

Shadowysn 01-14-2020 08:08

Re: Plugin not auto-generating gamedata file.
 
Quote:

Originally Posted by Silvers (Post 2680182)
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.

Silvers 01-14-2020 08:25

Re: Plugin not auto-generating gamedata file.
 
Quote:

Originally Posted by Shadowysn (Post 2680195)
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.


All times are GMT -4. The time now is 06:14.

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