diff --git a/README.md b/README.md index 52a08424..5395e44a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/maps/base.nav b/maps/base.nav new file mode 100644 index 00000000..1c9542ed Binary files /dev/null and b/maps/base.nav differ diff --git a/scripting/shavit-replay.sp b/scripting/shavit-replay.sp index 9f7313ce..0f370f6a 100644 --- a/scripting/shavit-replay.sp +++ b/scripting/shavit-replay.sp @@ -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 #include @@ -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; +}