[Temporary] Print Slicer

vcmptr

  • Jr. Member
  • This user novice scripter.
  • Posts: 60
[Temporary] Print Slicer
« on July 22nd, 2015, 12:14 PM »Last edited on August 8th, 2015, 01:01 PM
This bug still not fixed. I can't wait for fix. I created temporary print function.

Code: [Select]
function PrintSlicer()
{
local PrintBackup = print;
print <- function(string)
{
if(string!=null)
{
string = ""+string+""
if(string.len()>512)
{
  local x = string.len()/512;
  local cpt = 0;
  for(local i = 0; i != x; i++)
{
   cpt += 512;
   PrintBackup(string.slice(cpt-512, cpt));
}
  PrintBackup(string.slice(cpt, (cpt+(string.len()%512))));
  PrintBackup("Sliced prints ("+(x+1)+" slices) ");
}
 else PrintBackup(string);
}
}
}
How to apply?
Just call function in onScriptLoad.
My English is not good.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,807
[Temporary] Re: Print Slicer
« Reply #1, on July 22nd, 2015, 12:30 PM »Last edited on July 22nd, 2015, 01:24 PM
You guys know you can backup the original print and overwrite it with your own without needing to change everything in your script to use `print2`. Like this example:
Code: [Select]
local PrintBackup = print;
print <- function(msg)
{
    PrintBackup("Now calling the actual print");
    PrintBackup(msg);
}

print("Testing overwrite");

Thus, allowing you to implement a fragmented print function.
Code: [Select]
local PrintBackup = print;
print <- function( msg )
{
    for (local n = 0, m = msg.len(); n < m; n += 512)
    {
        if ( (n + 512) > m )
            PrintBackup( msg.slice( n ) );
        else
            PrintBackup( msg.slice( n, (n + 512) ) );
    }
}

In case the issue is unbearable. I never had to deal with strings that long tbh :-\
.

vcmptr

  • Jr. Member
  • This user novice scripter.
  • Posts: 60
[Temporary] Re: Print Slicer
« Reply #2, on July 22nd, 2015, 02:10 PM »
Quote from S.L.C on July 22nd, 2015, 12:30 PM
You guys know you can backup the original print and overwrite it with your own without needing to change everything in your script to use `print2`. Like this example:
Code: [Select]
local PrintBackup = print;
print <- function(msg)
{
    PrintBackup("Now calling the actual print");
    PrintBackup(msg);
}

print("Testing overwrite");

Thus, allowing you to implement a fragmented print function.
Code: [Select]
local PrintBackup = print;
print <- function( msg )
{
    for (local n = 0, m = msg.len(); n < m; n += 512)
    {
        if ( (n + 512) > m )
            PrintBackup( msg.slice( n ) );
        else
            PrintBackup( msg.slice( n, (n + 512) ) );
    }
}

In case the issue is unbearable. I never had to deal with strings that long tbh :-\
You are man! :D Thanks!  I will update script. :)
My English is not good.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,807
.

vcmptr

  • Jr. Member
  • This user novice scripter.
  • Posts: 60
My English is not good.