|
Senior Member
Join Date: Sep 2015
Location: Location:
|
01-12-2020
, 07:06
Re: Plugin not auto-generating gamedata file.
|
#3
|
Quote:
Originally Posted by Silvers
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 <= 0 || client > MaxClients) return false;
// I would: if (client <= 0 || 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_NAME, GAMEDATA); char filePath[PLATFORM_MAX_PATH]; BuildPath(Path_SM, filePath, sizeof(filePath), "gamedata/%s.txt", GAMEDATA); Handle fileHandle = OpenFile(filePath, "a+"); // Why append to the file?
// To: char filePath[PLATFORM_MAX_PATH]; BuildPath(Path_SM, filePath, sizeof(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_NAME, GAMEDATA); 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 client, int 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(client, 2); //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 == 0 ) CreateTimer(1.0, Timer_KickBebopFakeClient, GetClientUserId(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 timer, any 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?
__________________
Last edited by Shadowysn; 01-12-2020 at 07:31.
|
|
|
|