Raised This Month: $32 Target: $400
 8% 

Solved [CSGO] NAV Generator Workshop Map Fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-12-2022 , 12:07   [CSGO] NAV Generator Workshop Map Fix
Reply With Quote #1

I tried using https://forums.alliedmods.net/showthread.php?p=2069582 to generate blank nav meshes for workshop maps on my server.

However, the nav files do not get placed in the actual workshop folder for the map, they just get placed in the maps folder with the map name and that does not work for workshop maps.

If anyone knows how to edit this plugin to make it place the .nav file in the maps/workshop/(id) folder instead of just maps/ your help would be greatly appreciated.

Code:
#include <sourcemod>

#pragma semicolon 1

#define PLUGIN_VERSION "1.0"

public Plugin:myinfo = 
{
	name = "Auto NAV file creator",
	description = "Plugin that automatically creates a .nav file for the current map, meant to be used for custom AIs like replay bots.",
	author = "shavit",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/member.php?u=163134"
}

public OnPluginStart()
{
	CreateConVar("sm_navfilegenerator", PLUGIN_VERSION, "Plugin version", FCVAR_NOTIFY|FCVAR_DONTRECORD|FCVAR_PLUGIN);
}

public OnMapStart()
{
	new String:map[64];
	GetCurrentMap(map, 64);
	
	Format(map, 64, "maps/%s.nav", map);
	
	if(!FileExists(map))
	{
		File_Copy("maps/base.nav", map);
		
		GetCurrentMap(map, 64);
		ForceChangeLevel(map, ".nav file generate");
	}
}

/*
 * Copies file source to destination
 * Based on code of javalia:
 * http://forums.alliedmods.net/showthread.php?t=159895
 *
 * @param source		Input file
 * @param destination	Output file
 */
stock bool:File_Copy(const String:source[], const String:destination[])
{
	new Handle:file_source = OpenFile(source, "rb");

	if (file_source == INVALID_HANDLE) {
		return false;
	}

	new Handle:file_destination = OpenFile(destination, "wb");

	if (file_destination == INVALID_HANDLE) {
		CloseHandle(file_source);
		return false;
	}

	new buffer[32];
	new cache;

	while (!IsEndOfFile(file_source)) {
		cache = ReadFile(file_source, buffer, 32, 1);
		WriteFile(file_destination, buffer, cache, 1);
	}

	CloseHandle(file_source);
	CloseHandle(file_destination);

	return true;
}

Last edited by AuricYoutube; 01-13-2022 at 00:18.
AuricYoutube is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-13-2022 , 00:18   Re: [CSGO] NAV Generator Workshop Map Fix
Reply With Quote #2

Nevermind, got some code from https://github.com/shavitush/bhoptimer.

Quote:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#include <maps-folder-stocks>

char gS_Map[PLATFORM_MAX_PATH];

public void OnPluginStart()
{
CreateAllNavFiles();
}

public void OnMapStart()
{
GetCurrentMap(gS_Map, sizeof(gS_Map));
WriteNavMesh(gS_Map);
GetMapDisplayName(gS_Map, gS_Map, sizeof(gS_Map));
WriteNavMesh(gS_Map);
SetCommandFlags("nav_load", GetCommandFlags("nav_load") & ~FCVAR_CHEAT);
ServerCommand("nav_load");
}
My pasted code is a bit jank but I don't really know how to code and the plugin works so I am not going to bother changing it.

Credit to Avocado and Shavit.
Attached Files
File Type: inc maps-folder-stocks.inc (7.5 KB, 41 views)
AuricYoutube 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:47.


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