Question
Blitz3D Forums/Blitz3D Programming/Question
| ||
Is there anyway you can load a file from a url? |
| ||
Yes. Look at the tcp ip command reference. Have a look at the example. If you know the url to the file you want you can simply write the output of the http response to a file on the local machine or directly into memory such as in a bank or similar. |
| ||
not sure how to directly into memory. could tell me how to do that? |
| ||
Well....instead of passing the output to a file stream pass it to a bank. Check up the bank and file stream examples in the docs - they are quite easy to follow and cover pretty much everything you are asking. |
| ||
how will load sound or models or other resources? |
| ||
using bank |
| ||
Standard blitz commands won't load sound from a bank. There may be libraries that do this though. Non animated models can be recreated (with the addvertex,addtriangle,create surface) commands from data at runtime. Standard blitz commands won't create animated models at runtime either (not bone or md2 anyway) - however once again a library may exist for this. Alternatively - you could save them to disk temporarily, then load the models and sounds into memory before removing them again. |
| ||
Actually, you can play a sound directly from an URL using PlayMusic(url) and control it using the channels functions. |
| ||
I actually provided one in the code archives some time ago: http://www.blitzbasic.com/codearcs/codearcs.php?code=2279 It also supports downloading of chunked content, which is important if you want to retrieve PHP generated output. |
| ||
Can I use open\read file from url? without downloading the file? |
| ||
In my example, the content gets downloaded. But I guess you could adapt the code so it works for just reading text. Please note, that chunked reading is very important! PHP scripts which have a runtime above a certain threshold will always yield chunked output. |
| ||
in tcp how do I send a text? when I type hello world! in input command? the game displays the text like text,0,0,txtstring$ from tcp game server. |
| ||
That's a pretty vague question. Is your game HTTP based in any way? If so, you would have to do a HTTP post request. If your game is peer to peer based and using plain TCP, then it's pretty simple. WriteString(tcpStream, "Hello World") Otherwise, if you want a more defined answer, then please post a question containing all relevant details. |
| ||
How do I load a txt file with tcp I am loading a database user file as txt file how would I do this? |
| ||
I want to write a text file to tcp game server and read text file from tcp game server. |
| ||
I need help how do I run .bb file with blitzcc with batch script? |
| ||
To load a txt file, use the code from the link bytecode77 provided, then just read it using readfile$(filename$) and then the read functions... About sending a text file to the game server, I think it would be easier to send chunks of it as a TCP message and read them at the game server when you receive them. About running them with batch script, not sure, but I think blitzcc.exe accepts a file as a command line, try something like " blitzcc.exe filename$ " |