If sender_list is either a string or a number, it will send that RPC to the specific shard with that ID. If sender_list is a table, it will be iterated upon and send it to every shard that's ID is in the table. If sender_list is nil, all connected shards(including the one this is called on) will have this RPC executed. Sender_list can be a number of different values: SendModRPCToShard ( GetShardModRPC ( namespace, name ), sender_list. SendModRPCToShard has one key difference, which is that it takes a list of Shards to send to, so its arguments look like this: Instead of GetModRPC, we call GetShardModRPC, all the arguments are the same. Instead of SendModRPCToServer, we use SendModRPCToShard, this has one difference I'll explain in the following paragraph. Instead of AddModRPCHandler, we use AddShardModRPCHandler, all the arguments are the same. Shard RPCs work largely the same as normal RPCs with a couple small differences: ![]() So what about the new RPC systems? let's take a look at those now. In your mod, you should make sure to add appropriate checks so that a client cannot abuse your RPC, whether this is checking the prefab via player.prefab to limit it to a specific character, or check if they are a server admin with player.Network:IsServerAdmin(), purely depending on what its supposed to do. So what does this mod do? This would make the player grow in size by 1 every time the player pressed the V key, at a size of 5, the players size will reset back to 1 when the V key is pressed. SendModRPCToServer ( GetModRPC ( "GrowGiantRPC", "GrowGiant" ), size ) end ![]() Size = size + 1 if size = 6 then size = 1 end Transform : SetScale ( size, size, size ) end end -This adds the handler, which means that if the server gets told "GrowGiant", - it will call our function, GrowGiant, aboveĪddModRPCHandler ( "GrowGiantRPC", "GrowGiant", GrowGiant ) -This has it send the RPC to the server when you press "v" local size = 1 local function SendGrowGiantRPC () This is the function we'll call remotely to do it's thing, in this case make you giant! local function GrowGiant ( player, size ) local valid_grow_state = true - todo: make sure the player is allowed to grow right now if valid_grow_state then So how does this all look put together, lets see: every other argument in this function call will get forwarded to the fn you added in AddModRPCHandler, so in the end it would call fn(player. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |