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

[CS:GO] CSGOItemsJSON


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 03-20-2023 , 17:04   [CS:GO] CSGOItemsJSON
Reply With Quote #1

hello, just a quick snippet that uses game files to generate csgoitems in a json format

PHP Code:
#pragma newdecls required
public void OnPluginStart() 
{
    
char path[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMpathsizeof(path), "../../scripts/items/items_game.txt");

    
char jsonpath[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMjsonpathsizeof(jsonpath), "../../scripts/items/items_game.json");

    
char last[4096], curr[4096];
    
char explodeString[3][4096];
    
int strings;

    
File file OpenFile(path"r");
    
File json OpenFile(jsonpath"w");

    
file.ReadLine(currsizeof(curr));
    
    while (!
file.EndOfFile()) {
        
file.ReadLine(currsizeof(curr));
        
TrimString(curr);

        if (
strcmp(curr"{") == 0) {
            if (
strlen(last) > 0json.WriteLine("%s:"last);
        } else if (
strcmp(curr"}") == 0) {
            if (
strings == 3json.WriteLine("%s: %s"explodeString[0], explodeString[2]);
            else 
json.WriteLine("%s"last);
        } else {
            if (
strings == 3json.WriteLine("%s: %s,"explodeString[0], explodeString[2]);
            else {
                if (
strcmp(last"}") == 0json.WriteLine("},");
                else 
json.WriteLine("%s"last);
            }
        }

        
strings ExplodeString(curr"\t"explodeStringsizeof(explodeString), 4096);
        
strcopy(lastsizeof(last), curr);
    }

    
delete file;
    
delete json;

__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS
OSWO 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 03:32.


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