Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
For those who wants to create Multiplayer games.

just_in_case
Moderator
Quote
2021-04-08 16:35:02

A small tip or advice to those who want to create basic multiplayer games.

you can use coppercube inbuilt ccbReadFileContent() and ccbWriteFileContent() command along with some system commands to push and pull data ( generally a text file holding variables and values).

basically, you can create unlimited uploads and downloads of text files depending on the game you wanted to create.

System Commands are the most Powerful system In Coppercube's API if you guys don't know yet.

System commands allow you to turn this game engine into a powerful tool.

recently @NGAME forum user and a member of my discord server asked me to help him out in using system commands to pull and push data to a server, I guide him to create a multiplayer game successfully and he was really happy that he is finally able to create a game with just a few line of code.

No lengthy behaviors and nothing all he has to do was to save variables and values to a text file and then push to the server and loads them from the server.

Coppercube is really a powerful piece of software. It is not just a game engine. It is capable of more than that.

"Happiness can be found in the darkest of places, if one only remembers to turn on the light." - Albus Dumbledore



ghrank
Registered User
Quote
2021-04-09 13:04:58

With the last update, also, the command window that opens when running a system command can be suppressed, so it does not pop open in front of the application.


ngame
Registered User
Quote
2021-04-09 19:56:58

Yes, just_in_case is telling the truth. I'm currently trying to adjust the game settings. I want to send the source code to the forum soon.


threedslider
Registered User
Quote
2021-04-10 16:02:39

ngame, I am looking forward for source code ! :)


sulbcon
Registered User
Quote
2021-05-27 17:16:08

so just in case,,,how do I push things to my server with system commands??? ,cos I can only do http request to get text files from the net,,, how then do I make it send text files to the net


just_in_case
Moderator
Quote
2021-05-29 04:01:53

You can use cUrl or ftp commands to connect with the ftp server and then can send the text file to the server through ftp.

For example

curl ftp://xyz.com --user username:password

This will establish the connection to the ftp server using the curl command. You can also use the curl to get the text file and output it to the directory on the local computer by using "-O" command to output file and can also send the file to the remote computer(server) using "-T" command.

There are lots of other commands possible as well you can also use third party command line arguments like exif and all but then you might need to pack all these third party tools along with you game to the end client.


sulbcon
Registered User
Quote
2021-05-29 09:49:58

pls write a sample of how to do this to a specific directory,,,text exchange is all I need and also is it with the "system" function with coppercube...


sulbcon
Registered User
Quote
2021-05-29 10:06:17

"-O"?? pls just put a sample text here for reading text from a URL( to a specific directory) and uploading to the URL using the system stuff


sulbcon
Registered User
Quote
2021-05-30 10:30:46

just to put this up again


just_in_case
Moderator
Quote
2021-05-31 05:46:56

you can use any system command within coppercube.

here is the sample code to download a sample file to directory on local computer from a remote ftp server.



system("curl ftp://server.com/filename.txt -O --user username:password");



here in the above code you need to replace server name,filename, username, and password with yours.

this will download the provided text file from the ftp server to the project directory, you can then read the text from that file using the command.

ccbReadFileContent("filename.txt")


same goes with the uploading of text file to the server.

here is the sample code to upload a desired file to the remote server

system("curl ftp://server.com/ -T filename.txt --user username:Password");


made the appropriate changes to the above command by replacing username password, filename etc.

and it will upload the file to the server.
to upload to a specific directory you can specify the path like.

ftp://server.com/directory1/ same goes for the local directory just specify the full path of the file or directory when uploading or downloading.

Hope this makes sense and you will be able to understand it now.

Note:- If you are not on Windows 10, then you might need to install Curl to your computer then only the above command will work, otherwise it can throw an error lik "curl is not recognised as external or internal command" you can pack the curl installation along with your game to make it work on the endclient as well.

Cheers


sulbcon
Registered User
Quote
2021-05-31 18:19:17

yes that's my problem thanks I'm downloading curl right away


sulbcon
Registered User
Quote
2021-05-31 18:22:23

just maybe put a direct link to where u got curl from


DouweDabbe
Guest
Quote
2021-06-02 11:49:56

I like to know
* what the performance issues are on a home server?
* And what about security on a www facing server?


just_in_case
Moderator
Quote
2021-06-02 16:02:35

I never tried using the system commands for multiplayer gmaes or for downloading and uploading data by myself but has guide @Ngame and he created a really good example of mulitplayer game using the cUrl system command.

So I can't really provide benchmarks regarding performance issues and security of the server.

But I believe since Coppercube 6.4, we can now completely hide the cmd window. So our server credentials and other sensitive info are safe and can't be accessed by the end client.

and for the Windows platform, you can use the system command to do additional things for your behavior or game also. like getting the file size or filename and then displaying it on a 2D overlay and many more.


@sulbcon you can get the curl from the @Ngame online shooter post in the announcements section of the forum he packed the installetion file along with his demo.


sulbcon
Registered User
Quote
2021-06-03 22:11:21

Okay.....


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "?nternational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact