Jump to content

some way to stream a file


karlis

Recommended Posts

hi, i was wondering, is it possible to stream a file(not script, but image, sound etc), while script itself is running

here is lame example, but its purpose is only to show the idea(yes i know theres no filewrite() clientside)

--SERVER
file=fileOpen("myimage.png")
while not fileIsEOF(file) do
triggerClientEvent(getRootElement(),"onsendfile",getRootElement(),fileread("myimage.png",500))
end
 
--CLIENT
file=fileCreate("myimgrecived.png")
addEvent("onsendfile",true)
addEventHandler("onsendfile",getRootElement(),function(buffer)
fileWrite(file,buffer)
end)

Link to comment

If there is no fileWrite client-side then it's not possible. I think you didn't construct your question properly.. First, you say "i was wondering if it's possible" but then you say "i know there is no fileWrite clientside"... So basically, you answer your question in a question.

Besides, you'd get error/warning if you'd want to open a file in client-side script, like guiCreateStaticImage with that streamed image because functions like guiCreateStaticImage, playSound, etc. need to know that file is available to use (). Try to place a .png image in client-side resource and try to open it with client-side script. You know the file exists but resource can't see it (no in meta.xml).

Link to comment

lol k, i know that i can specify them in meta, i was asking is it possible to send them while resource running, only on request, and for 1 player only

and i know there is also some io.write function in lua, so i asked this

well you ansvered, so ok thanks

edit: dak, yes i saw this, but this is clearly for scripts only

Link to comment
lol k, i know that i can specify them in meta, i was asking is it possible to send them while resource running, only on request, and for 1 player only

and i know there is also some io.write function in lua, so i asked this

well you ansvered, so ok thanks

edit: dak, yes i saw this, but this is clearly for scripts only

Most of Lua libraries are blocked by MTA, so is io.

Link to comment
so gamesnerts example is totally invalid :evil:
...
function keepImageLoaded()
dxDrawImage(0,0,0,0,"imagefile.ext")
end
addEventHandler("onClientRender",getRootElement(),keepImageLoaded)

This is basically what it comes down to. You just draw *cough* the image with size 0x0. This means you can't see it, but the picture is still being loaded.

I prefer having something like:

image = fileOpen("lol.png")
 
...
 
dxDrawImage(x, y, w, h, image)

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...