RFC

From NPC for VCMP 0.4 Servers
Revision as of 15:34, 26 January 2023 by Habi (talk | contribs)
Jump to navigation Jump to search

This function was added in v1.6 beta and will not work on previous versions.


Description:
This method is used to call client functions from server script using streams as medium. Calling RFC will returns function which can be used to call remote functions of npcscripts( i.e. functions in npcscripts: StartRecordingPlayback, SendDeathInfo, .. ) when called with their parameters. Note that a single call to RFC(..) will return function and a double call RFC(..)(param1, param2, .. ) where param1, param2 are parameters of remote function only will call the remote function.


Parameters:

(npcid, [string]funcname)

npcid : The ID of the target npc on whose environment the function will be searched.
funcname : The name of the remote function


Return Values:
This will return a function object which can be used as if it is the remote function itself.(except of return values)


Example

Server Side

StartPlayback <- RFC(0, "StartRecordingPlayback"); //creates a function object locally. Not yet communicate with npc.
StartPlayback(1,"runtolake"); //will search and execute StartRecordingPlayback(1, "runtolake") on npcscript.(of NPC with ID 0 )

//You can also do this in one line
RFC(0,"print")("Hello how are you"); //will print the text: 'Hello how are you' on npc console(console can be shown by ShowNPCConsole() ) of npc with ID 0.