Has some useful server utilities
| Utilities | Has some useful server utilities |
| Functions | |
| clientRPC | Think of this function as if you’re calling a client function directly from the server. |
| umsgSend | Makes sending umsgs a blast. |
| play3DSound | Plays a 3D sound, the further away from the point the player is, the softer the sound will be. |
| getAllReadyPlayers | Similar to player.GetAll(), except it only returns players that have ULib ready to go. |
| replicatedWritableCvar | This function also creates a cvar on the client that can be modified and will be sent back to the server. |
| isDedicatedServer | The normal GM10 bind is broken, this fixes it. |
function ULib.clientRPC( plys, fn, ... )
Think of this function as if you’re calling a client function directly from the server. You state who should run it, what the name of the function is, and then a list of parameters to pass to that function on the client. ULib handles the rest. Parameters can be any data type that’s allowed on the network and of any size. Send huge tables or strings, it’s all the same, and it all works.
| filter | The Player object, table of Player objects for who you want to send this to, nil sends to everyone. |
| fn | A string of the function to run on the client. Does not need to be in the global namespace, “myTable.myFunction” works too. |
| ... | Optional The parameters to pass to the function. |
| v2.40 | Initial. |
function ULib.umsgSend( v, queue )
Makes sending umsgs a blast. You don’t have to bother knowing what type you’re sending, just use ULib.umsgRcv() on the client. Note that while you can send tables with this function, you’re limited by the max umsg size. If you’re sending a large amount of data, consider using clientRPC() instead.
| v | The value to send. |
| queue | (For use by clientRPC() ONLY) A boolean of whether the messages should be queued with RPC or not. |
function ULib.play3DSound( sound, vector, volume, pitch )
Plays a 3D sound, the further away from the point the player is, the softer the sound will be.
| sound | The sound to play, relative to the sound folder. |
| vector | The point to play the sound at. |
| volume | (Optional, defaults to 1) The volume to make the sound. |
| pitch | (Optional, defaults to 1) The pitch to make the sound, 1 = normal. |
function ULib.replicatedWritableCvar( sv_cvar, cl_cvar, default_value, save, notify, access )
This function also creates a cvar on the client that can be modified and will be sent back to the server.
| sv_cvar | The string of server side cvar. |
| cl_cvar | The string of the client side cvar. THIS MUST BE DIFFERENT FROM THE sv_cvar VALUE. |
| default_value | The string of the default value for the cvar. |
| save | Boolean of whether or not the value is persistent across map changes. This uses garry’s way, which has lots of issues. We recommend you watch the cvar for changes and handle saving yourself. |
| notify | Boolean of whether or not value changes are announced on the server |
| access | The string of the access required for a client to actually change the value. |
The server-side cvar object.
| v2.40 | Initial. |
Think of this function as if you’re calling a client function directly from the server.
function ULib.clientRPC( plys, fn, ... )
Makes sending umsgs a blast.
function ULib.umsgSend( v, queue )
Plays a 3D sound, the further away from the point the player is, the softer the sound will be.
function ULib.play3DSound( sound, vector, volume, pitch )
Similar to player.GetAll(), except it only returns players that have ULib ready to go.
function ULib.getAllReadyPlayers()
This function also creates a cvar on the client that can be modified and will be sent back to the server.
function ULib.replicatedWritableCvar( sv_cvar, cl_cvar, default_value, save, notify, access )
The normal GM10 bind is broken, this fixes it.
function isDedicatedServer() -- The normal GM10 function isn't working, let's define a hack