Talk:CallServerFunction

From Multi Theft Auto: Wiki
Revision as of 17:47, 14 May 2009 by LordAzamath (talk | contribs) (An inmproved one discussion)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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)