Here is some sections you can check: Simplify When you design your net communication it's important to make it effective as possible. This section is not recommended for beginners due to complexity.
![ilibrary mod ilibrary mod](https://minecraftmodz.com/wp-content/uploads/2019/04/1556221418_738_cucumber-library-mod-1-12-2-a-core-library-for-minecraft.jpg)
You are still able to ask user for input, the concern is in validity of that input. Before you publish your code, try as hard as you can to break it. You should look out for negative numbers, people sending net messages very fast, people trying to write entities that should never be written, as long as many other things. Don't be lazy and only check data in the realm where it can be easily manipulated.
![ilibrary mod ilibrary mod](https://minecraftmod.org/wp-content/uploads/2017/10/Mantle-Mod-1068x601.png)
To prevent this, follow 1 simple rule:ĭon't preform checks on user input clientside then assume that they are fine serverside. This means people could send their own net messages, from outside the script that it was created in, gaining access to ban any player on your server. However, there are no checks to see if the player is actually an admin or not. This net message bans a player when the BanPlayer net message is sent to the server.
#Ilibrary mod code#
Can you figure out what could happen if this code was actually used on a server? Receive( "BanPlayer", function( len, ply ) You can also send a message to every connected player serverside using net.Broadcastįor reading data, there are functions for each writable type of data above, generally being net.Read(Type).
![ilibrary mod ilibrary mod](https://staticdelivery.nexusmods.com/mods/110/images/9563-4-1329216369.jpg)
To send the message, use net.Send on the server, or net.SendToServer on the client. To send data, after calling the net.Start function, you can use the following functions, each for their specified data type: Generally empty net messages are used as a simple way of alerting the player of something that has happened on the server which the client does not know about unless the server tells them about it, for example, after a certain time has passed on the server, an empty net message could be sent to the client to tell them that a menu should be opened. We send an empty net message, next we will look at sending data in net messages.