Jump to content

Split arguments to pieces?


Recommended Posts

I'm currently using the function takePlayerScreenshot and i need to transfer the data to client side for preview but sometimes the string size of the screenshot data is over 65535 characters and that is over the argument length limit in triggerClientEvent.

How i could split that argument to pieces and send it and then combine the pieces client side?

Link to comment

Solution is create table.

And check sub string like 1,65535.

And send with parts to client.

Like this:

  
function fPack ( str ) 
    local t = { } 
    local new = str 
    while #new >= 65535 do 
        t[ #t + 1 ] = string.sub( new, 1, 65535 ) 
        triggerClientEvent( root, 'onSomeEvent', root, t[ #t ] ) 
        new = string.gsub( new, string.sub( new, 1, 65535 ), '' ) 
    end 
    t[ #t + 1 ] = string.sub( new, 1, #new ) 
    triggerClientEvent( root, 'onSomeEvent', root, t[ #t ] ) 
    if #t == 0 then 
        t[1] = new 
    end 
    return t 
end 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...