PDA

View Full Version : [COD2] Random string hud



Moczulak
26th March 2017, 20:56
Hi all,
Does anyone know how to show the screen random hud?
The point is that I would like to create a hud but the string would be selected from the string array.

Look this:


inithudtext()
{
level.vote_maptext1 = newHudElem();
level.vote_maptext1.archived = false;
level.vote_maptext1.x = 434; // 434
level.vote_maptext1.y = level.mapvotehudoffset + 253;
level.vote_maptext1.sort = 1;
level.vote_maptext1 setText(level.mapcandidate[0]["mapname"]);

iprintln(level.mapcandidate[0]["mapname"]);
}

It work only this
iprintln(level.mapcandidate[0]["mapname"]); but hud is invisible..
Please help me someone.

IzNoGoD
26th March 2017, 21:35
You're probably forgetting to developer 1.

Moczulak
26th March 2017, 21:57
How to add precacheString, which came from the array?

PS. Thanks for developer 1 :)

Ni3ls
27th March 2017, 07:11
You have to rewrite it. Precache the mapnames like they are showed

IzNoGoD
27th March 2017, 11:00
And with what error does the thing crash when you run it with developer 1?

voron00
27th March 2017, 16:07
Alright, if you use libcod you can use use new makelocalizedstring function:


// Find free localized string index
index = findFreeConfigStringIndex(1310, 256);

// Set configstring
setConfigString(index, level.mapcandidate[0]["mapname"]);

// Your Hud Stuff
level.votemap0 setText(makeLocalizedString(level.mapcandidate[0]["mapname"]));

findFreeConfigStringIndex(start, end)
{
for (i = start + 1; i < start + end; i++)
{
configstring = getConfigString(i);
if (!isDefined(configstring))
return i;
}

return undefined;
}


Just tested it, works quite nicely.

Or you can use the old fashioned way and replace strings on a client (iznogod's settext wrapper)

Moczulak
27th March 2017, 20:02
Thank you for your involvement :)

But i have this error:



******* script compile error *******
unknown function: (file 'maps/mp/gametypes/_mapvote.gsc', line 328)
configstring = getConfigString(i);
*
************************************
Sys_Error: Error during initialization:
script compile error
(see console for details)

Moczulak
27th March 2017, 20:10
IzNoGOD the error message is that you can not precachestring (level.mapcandidate [0] ["mapname"]); To use in a script only, but only when the map loads, and i mean that the script that draws the map is only at the end of it draws, so i would like to add precachestring (level.mapcandidate [0] ["mapname"]); Only when will download map compilation.

voron00
27th March 2017, 20:17
Thank you for your involvement :)
But i have this error:



Alright, if you use libcod you can use use new makelocalizedstring function:


10 char. bla-bla

Moczulak
27th March 2017, 20:27
I'm using function precacheString(); to defined strings.

what is this 10 char?

kung foo man
27th March 2017, 23:26
0 char

kung foo man
27th March 2017, 23:28
Ok, rekted the 10 char test now, minimum is 1 char and quote strings are counted.

Moczulak: you need to install libcod (https://killtube.org/showthread.php?2454-Work-in-progress-Setup-CoD2-on-your-ubuntu-14-04-server)

IzNoGoD
27th March 2017, 23:44
Alright, if you use libcod you can use use new makelocalizedstring function:


// Find free localized string index
index = findFreeConfigStringIndex(1310, 256);

// Set configstring
setConfigString(index, level.mapcandidate[0]["mapname"]);

// Your Hud Stuff
level.votemap0 setText(makeLocalizedString(level.mapcandidate[0]["mapname"]));

findFreeConfigStringIndex(start, end)
{
for (i = start + 1; i < start + end; i++)
{
configstring = getConfigString(i);
if (!isDefined(configstring))
return i;
}

return undefined;
}


Just tested it, works quite nicely.

Or you can use the old fashioned way and replace strings on a client (iznogod's settext wrapper)

Dont forget to check if index is a proper index. Might be undefined if the configstrings are all used up.

Default cod configstring functions can take care of this for you, including a "is it already duplicated somewhere else" check.