Post: [Release] - String Check, Prevents Future Overflows!
02-07-2012, 01:05 AM #1
Correy
I'm the Original
(adsbygoogle = window.adsbygoogle || []).push({}); this it a very quick script i made, very usefull to.
basically what it does, it checks every player for every time a SetText is set and counts it.

the maximum strings to be set is something like 374, but i made it 350 just incase.
you will need to do some tweeks to your menu, but they are very simple.

add this to your open menu code & sub menus.
    
self notify( "menu_open" );


add this to any of your welcome messages, only custom oldNotifyMessage's.
    
self notify( "oldNotify" );


and also add this to any custom text you have, such as doHearts.
    
self notify( "custom_text" );


now you want to thread this on spawn, thread it once.. so above the for statement onPlayerSpawned.
here's an example incase you get confused.
    
onPlayerSpawned()
{
[COLOR="#FF0000"]level thread StringCheck();[/COLOR]
for(;Winky Winky
{
self waittill( "spawned_player" );
// DO NOT THREAD IT HERE!
if(!isdefined(self.hud_rankscroreupdate))
{
self.hud_rankscroreupdate = newClientHudElem(self);
self.hud_rankscroreupdate.horzAlign = "center";
self.hud_rankscroreupdate.vertAlign = "middle";
self.hud_rankscroreupdate.alignX = "center";
self.hud_rankscroreupdate.alignY = "middle";
self.hud_rankscroreupdate.x = 0;
self.hud_rankscroreupdate.y = -60;
self.hud_rankscroreupdate.font = "default";
self.hud_rankscroreupdate.fontscale = 2.0;
self.hud_rankscroreupdate.archived = false;
self.hud_rankscroreupdate.color = ( randomFloat(1), randomFloat(1), randomFloat(1));
self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
}
}
}


if you dont know what ive done there i've added
    
[COLOR="#FF0000"]level thread StringCheck();[/COLOR]


and now you want to add this somewhere.
    
StringCheck()
{
for( level.string["count"] = 0;; )
{
for( x=0; x<level.players.size; x++ )
{
level.players[x] waittill_any( "menu_open", "oldNotify", "custom_text" );
level.string["count"]++;
if( level.string >= 350 )
{
level.players[x] iPrintln( "^1Game is restarting due to a high string count!" );
level.players[x] freezeControls( true );
wait 1;
map_restart( false );
}
}
wait .5;
}
}


this is very useful, although you may think you menu's dont overflow.. they actually will after so long.
(adsbygoogle = window.adsbygoogle || []).push({});

The following 7 users say thank you to Correy for this useful post:

Woof, DlBSY993, iPROFamily, Jeremy, Cmd-X, Taylor
02-07-2012, 01:56 AM #11
Originally posted by Correy View Post
well this script will be useful for him Happy


I know this may be a dumb question, but is there a way to just remove the text after it is deleted without restarting. like deleting the cache or something lol
02-07-2012, 02:04 AM #12
Correy
I'm the Original
Originally posted by Jdog View Post
I know this may be a dumb question, but is there a way to just remove the text after it is deleted without restarting. like deleting the cache or something lol


nope, it sticks to the level.. although the variable for the text is destroyed, it's still in the level.. once it's set it cant be destroyed neither deleted which a map restart is a simple solution.

PS: theres not such thing as a dumb question.
02-07-2012, 05:09 AM #13
Cmd-X
It's been awhile.
Originally posted by Correy View Post
this it a very quick script i made, very usefull to.
basically what it does, it checks every player for every time a SetText is set and counts it.

the maximum strings to be set is something like 374, but i made it 350 just incase.
you will need to do some tweeks to your menu, but they are very simple.

add this to your open menu code & sub menus.
    
self notify( "menu_open" );


add this to any of your welcome messages, only custom oldNotifyMessage's.
    
self notify( "oldNotify" );


and also add this to any custom text you have, such as doHearts.
    
self notify( "custom_text" );


now you want to thread this on spawn, thread it once.. so above the for statement onPlayerSpawned.
here's an example incase you get confused.
    
onPlayerSpawned()
{
[COLOR="#FF0000"]level thread StringCheck();[/COLOR]
for(;Winky Winky
{
self waittill( "spawned_player" );
// DO NOT THREAD IT HERE!
if(!isdefined(self.hud_rankscroreupdate))
{
self.hud_rankscroreupdate = newClientHudElem(self);
self.hud_rankscroreupdate.horzAlign = "center";
self.hud_rankscroreupdate.vertAlign = "middle";
self.hud_rankscroreupdate.alignX = "center";
self.hud_rankscroreupdate.alignY = "middle";
self.hud_rankscroreupdate.x = 0;
self.hud_rankscroreupdate.y = -60;
self.hud_rankscroreupdate.font = "default";
self.hud_rankscroreupdate.fontscale = 2.0;
self.hud_rankscroreupdate.archived = false;
self.hud_rankscroreupdate.color = ( randomFloat(1), randomFloat(1), randomFloat(1));
self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
}
}
}


if you dont know what ive done there i've added
    
[COLOR="#FF0000"]level thread StringCheck();[/COLOR]


and now you want to add this somewhere.
    
StringCheck()
{
for( level.string["count"] = 0;; )
{
for( x=0; x<level.players.size; x++ )
{
level.players[x] waittill_any( "menu_open", "oldNotify", "custom_text" );
level.string["count"]++;
if( level.string >= 350 )
{
level.players[x] iPrintln( "^1Game is restarting due to a high string count!" );
level.players[x] freezeControls( true );
wait 1;
map_restart( false );
}
}
wait .5;
}
}


this is very useful, although you may think you menu's dont overflow.. they actually will after so long.


That's pretty nice, and very creative!
02-07-2012, 07:14 AM #14
Karoolus
I'm the W@W Menu Guy !
looks nice Winky Winky
glad to see you use your brains (for a change :carling: )

The following user thanked Karoolus for this useful post:

Correy
02-07-2012, 07:52 AM #15
DlBSY993
There's 0nly 1..
DoEs ThiS MEAn We HAz 4.0 JailBreAk Now!!!???? :derp:
02-07-2012, 03:28 PM #16
Amanda
Can’t trickshot me!
I'm sorry to say it but this will not work...
You only count how many times a string appears on the screen. However the game doesn't care how many times a string appears. For example the following setText() will never make the game to overflow.
    for(i=0; i<2147483647; i++) Display setText("My Text Here"); // Never overflows 

But
The game cares how many DIFFERENT setText() you use! For example:
    for(i=0; i<50; i++) Display setText("^" + i + "My Text Here"); // Overflows when i reaches 30 - max Different strings limit for COD4 

This is because COD4 engine supports up to 30 different strings to be displayed in each game... The only way not to make it overflow is to use println() or use less than 30 text strings (including Progress Bars messages & every type of HUD Messages) Winky Winky
So if you want to make a counter for strings you must raise it up by one only every time a new string appears, so it will not count again the same strings...

The following 2 users say thank you to Amanda for this useful post:

Blackstorm, x_DaftVader_x
02-07-2012, 04:36 PM #17
pcfreak30
>> PCFreak30.com Happy<<
Not bad. My solution is in my menu base. i use 1 hud element and check the character length.
02-07-2012, 04:39 PM #18
Originally posted by Amanda View Post
I'm sorry to say it but this will not work...
You only count how many times a string appears on the screen. However the game doesn't care how many times a string appears. For example the following setText() will never make the game to overflow.
    for(i=0; i<2147483647; i++) Display setText("My Text Here"); // Never overflows 

But
The game cares how many DIFFERENT setText() you use! For example:
    for(i=0; i<50; i++) Display setText("^" + i + "My Text Here"); // Overflows when i reaches 30 - max Different strings limit for COD4 

This is because COD4 engine supports up to 30 different strings to be displayed in each game... The only way not to make it overflow is to use println() or use less than 30 text strings (including Progress Bars messages & every type of HUD Messages) Winky Winky
So if you want to make a counter for strings you must raise it up by one only every time a new string appears, so it will not count again the same strings...

there's another more basic reason why this won't work..... Winky Winky
02-07-2012, 04:47 PM #19
Originally posted by pcfreak30 View Post
Not bad. My solution is in my menu base. i use 1 hud element and check the character length.
whats the point in that :/

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo