Talk:CallServerFunction: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(An inmproved one discussion)
 
mNo edit summary
Line 22: Line 22:
</syntaxhighlight>
</syntaxhighlight>
[[User:LordAzamath|LordAzamath]] 19:47, 14 May 2009 (CEST)
[[User:LordAzamath|LordAzamath]] 19:47, 14 May 2009 (CEST)
----
Yeah, nice idea to save some space except for the trigger-Event solution. CallClient/ServerFunction should enshorten this. [[User:NeonBlack|NeonBlack]] 20:23, 15 May 2009 (CEST)

Revision as of 18:23, 15 May 2009

I would rather use this variant for both calling client and server functions..

[lua]
-- client side
addEvent("onServerRequest", true)
addEventHandler("onServerRequest", rootElement,
	function (funcname, ...)
		 _G[funcname](...)
	end
)
-- server side
addEvent("onClientRequest", true)
addEventHandler("onClientRequest", rootElement,
	function (funcname, ...)
		 _G[funcname](...)
	end
)
-- and call them like
	triggerServerEvent("onClientRequest", rootElement, "changeResStateS", resource, state)
-- while I have defined a function changeResStateS(resource, state) end on server side and vice versa.

LordAzamath 19:47, 14 May 2009 (CEST)


Yeah, nice idea to save some space except for the trigger-Event solution. CallClient/ServerFunction should enshorten this. NeonBlack 20:23, 15 May 2009 (CEST)