Generate .nav files

This commit is contained in:
Shavitush 2015-09-21 02:22:43 +03:00
parent 193ee1e052
commit 519a647a53
3 changed files with 59 additions and 5 deletions

View File

@ -45,7 +45,8 @@ a bhop server should be simple
```
2. Copy the desired .smx files to your plugins (addons/sourcemod/plugins) folder
2.1. Copy shavit.games.txt to /gamedata if you have DHooks installed.
3. Restart your server.
3. Copy base.nav to the `maps` folder.
4. Restart your server.
# Required plugins:
shavit-core - no other plugin will work without it.

BIN
maps/base.nav Normal file

Binary file not shown.

View File

@ -19,7 +19,6 @@
*/
// I have no idea if this plugin will work with CS:S, sorry.
// USE WITH https://forums.alliedmods.net/showthread.php?t=231077
#include <sourcemod>
#include <cstrike>
@ -118,6 +117,21 @@ public void OnClientPutInServer(int client)
public void OnMapStart()
{
GetCurrentMap(gS_Map, 128);
RemoveMapPath(gS_Map, gS_Map, 128);
char sTempMap[140];
Format(sTempMap, 140, "maps/%s.nav", gS_Map);
if(!FileExists(sTempMap))
{
File_Copy("maps/base.nav", sTempMap);
ForceChangeLevel(gS_Map, ".nav file generate");
return;
}
ConVar bot_zombie = FindConVar("bot_zombie");
// idk if it exists in CS:S, safety check ;p
@ -154,9 +168,6 @@ public void OnMapStart()
CreateDirectory(sPath, 511);
}
GetCurrentMap(gS_Map, 128);
RemoveMapPath(gS_Map, gS_Map, 128);
for(int i = 0; i < MAX_STYLES; i++)
{
gA_Frames[i] = new ArrayList(5);
@ -496,3 +507,45 @@ stock bool RemoveMapPath(const char[] map, char[] destination, int maxlen)
return true;
}
/*
* 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 char[] source, const char[] destination)
{
Handle file_source = OpenFile(source, "rb");
if(file_source == null)
{
return false;
}
Handle file_destination = OpenFile(destination, "wb");
if(file_destination == null)
{
delete file_source;
return false;
}
int buffer[32];
int cache;
while(!IsEndOfFile(file_source))
{
cache = ReadFile(file_source, buffer, 32, 1);
WriteFile(file_destination, buffer, cache, 1);
}
delete file_source;
delete file_destination;
return true;
}