nmrih / source-game

Bugs and issues reporting for NMRiH1
http://store.steampowered.com/app/224260
58 stars 25 forks source link

[Feature Request] Ability for clients to precache downloaded particles #1465

Closed dysphie closed 2 months ago

dysphie commented 2 months ago

Right now, servers can’t display custom particles to clients. The client downloads the particle file but never precaches it. There’s a hacky workaround that involves serving a mapname_manifest.txt file, but it’s pretty spammy and conflicts with other servers’ custom content. Plus, it doesn’t even work if the map packs its own manifest file. Perhaps clients could simply cache particles in download?

Repro code:

public void OnPluginStart()
{
    RegConsoleCmd("sm_particle", Cmd_Particle);
}

public void OnMapStart()
{
    AddFileToDownloadsTable("particles/custom.pcf");
    AddFileToDownloadsTable("maps/nmo_dev_world_particles.txt");
    PrecacheGeneric("particles/custom.pcf", true);
}

Action Cmd_Particle(int client, int args)
{
    client = 1;

    float origin[3];
    GetClientEyePosition(client, origin);

    int entity = CreateEntityByName("info_particle_system");

    DispatchKeyValue(entity, "start_active", "1");
    DispatchKeyValue(entity, "effect_name", "my_custom_effect");
    DispatchSpawn(entity);
    TeleportEntity(entity , origin);
    ActivateEntity(entity);

    // Prints "Attempted to precache unknown particle system" or something
    return Plugin_Handled;
}
felis-catus commented 2 months ago

Implemented in src-r7424.