GithubHelp home page GithubHelp logo

Comments (9)

T-Maxxx avatar T-Maxxx commented on July 19, 2024

Stop using SetText() with dynamically generated strings.

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

@T-Maxxx is there a solution to it?
i assume the problem is that each hud settext(dynamicStuff) creates a new string reference. once all configstring handles are used that error pops up.
is there a way to manually free a unused string handle?

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

i think that shows how to use it correctly .. but im not sure :)

self.hudhs.label = &"^5Headshots :^0 &&1";
self.hudhs setValue(self.headshots);

source: http://files.hiperz.com/cod4/%5E5myf_%5E1v1/promod/_huds.gsc

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

This list cleared each map change. On pure server without scripts available about 400 configstrings.
I'm not sure about "&&1" in label string but setValue works only with decimal or float values. There should be concatenation, not format parsing for label and value. And OrigiTosko using player names as strings.
If you set "a" as configstring, it will be used instead of new configstring when called settext("a") again.

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

oh i see .. not a solution then. however the same placeholders are visible here #42 so i would assume there is a way to do it.

maybe .label = &"conststr &&1"; combined with setText(dynamicStr); works

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

It will also consume configstring.
CS is a way to send text from server to client.

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

solved it i think.

setHudTextSafe(hudelem, txt)
{
    if(!isDefined(hudelem))
        return;
    hudelem setText(txt);
    hudelem clearAllTextAfterHudElem();
}

testhud()
{

    if(!isDefined(self.hudkillstreak))
    {
        self.hudkillstreak = newClientHudElem(self);
        self.hudkillstreak.x = 110;
        self.hudkillstreak.y = 13; 
        self.hudkillstreak.alignx = "left";
        self.hudkillstreak.horzAlign = "left";
        self.hudkillstreak.fontscale = 1.4;
        //self.hudkillstreak.label = &"^5Killstreak :^0 &&1";
        self.hudkillstreak fadeOverTime(.5);
        self.hudkillstreak.hidewheninmenu = true;
        self.hudkillstreak.alpha = 1;
        self.hudkillstreak.glowAlpha = 1;
        self.hudkillstreak.glowColor = (0.3, 0.3, 0.3);
    }

    while(1)
    {
        level.counter++;
        text = "str:" + level.counter;

        setHudTextSafe(self.hudkillstreak, text);
        wait 0.5;
    }
}
...
self thread testhud(); // ran this after spawn (dont know if that is relevant)

note: it appears that it is enough to run clearAllTextAfterHudElem() on just one hudelement. so if you use multiple elements at once, you just need to clear one. i have no idea if that is anyhow relevant to performance. also clearing a dummy hudelement once a second might provide a more general solution to the problem.

altough there are some weird warnings in the console :S
Warning: abandoning const config string model slot for string §Overflow on 1335
Warning: abandoning const config string model slot for string §str:591

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

i also haven't tested this with multiple players ...

@OrigiTosko you could try to replace all hud setText(text) calls with the setHudTextSafe(hud, text) function i posted above. i think it's worth giving it a shot.

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

This is not a solution! It clears ALL CSs after this element CS whether used or not!
But! I have an idea :) I will make pull request soon.

from cod4x_server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.