View Single Post
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