4 Commits

Author SHA1 Message Date
3bf55873ed Bump deps/json from a259ecc to 0457de2
Bumps [deps/json](https://github.com/nlohmann/json) from `a259ecc` to `0457de2`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](a259ecc51e...0457de21cf)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 07:42:25 +00:00
38a860e4ce Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-12-15 15:05:41 -06:00
3995bed200 update 2023-12-15 15:05:36 -06:00
3502a70933 Update README.md 2023-12-15 15:03:41 -06:00
3 changed files with 7 additions and 12 deletions

View File

@ -91,13 +91,15 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio
* `<array of strings> FS_ListFiles(<folder string>)` Returns a list of files inside of the folder given. * `<array of strings> FS_ListFiles(<folder string>)` Returns a list of files inside of the folder given.
```gsc ```gsc
files = FS_ListFiles("testfolder/"); folder = "testfolder/";
files = FS_ListFiles(folder);
for (i = 0; i < files.size; i++) for (i = 0; i < files.size; i++)
{ {
file = files[i]; // will be "testfolder/<filename>" filename = files[i];
// do something with the filename // do something with the filename
filepath = folder + filename;
} }
``` ```

2
deps/json vendored

Submodule deps/json updated: a259ecc51e...0457de21cf

View File

@ -404,14 +404,7 @@ namespace fileio
gsc::function::add("fs_listfiles", []() gsc::function::add("fs_listfiles", []()
{ {
std::string dir = game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER); auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
if (dir.ends_with("\\") || dir.ends_with("/"))
{
dir = dir.substr(0, dir.length() - 1);
}
auto fpath = build_base_path(dir);
int numfiles; int numfiles;
auto* files = game::FS_ListFiles(fpath.c_str(), "", game::FS_LIST_ALL, &numfiles); auto* files = game::FS_ListFiles(fpath.c_str(), "", game::FS_LIST_ALL, &numfiles);
@ -419,7 +412,7 @@ namespace fileio
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER); game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
for (int i = 0; i < numfiles; i++) for (int i = 0; i < numfiles; i++)
{ {
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, (dir + "/" + files[i]).c_str()); game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, files[i]);
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER); game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
} }