Jump to content

Client-side Server-side


Recommended Posts

I can't grasp the whole client-side and server-side. Can someone try brief me a little which part of the game does the server controls?
Because I was trying to,

GLOBAL.ThePlayer.components[...]

But it errors,

452: attempt to index field 'components' (a nil value)

 

Link to comment
Share on other sites

what exactly do you want to know?

components are controlled by server to 99% (some like "talker" are also at clients, cause they do display text)
So if you try to access components, you have to make sure that this code is only executed at server.
To find out in a script who executes it, you can use this small script from Maris aka star:

 

local SERVER_SIDE = nil
local DEDICATED_SIDE = nil
local CLIENT_SIDE = nil
local ONLY_CLIENT_SIDE = nil
-- code from star:
-- Also notice that if SERVER_SIDE is nil and CLIENT_SIDE is nil too, that means the mod is force enabled and its working on main screen. I guess. 
if GLOBAL.TheNet:GetIsServer() then
	SERVER_SIDE = true
	if GLOBAL.TheNet:IsDedicated() then
		--Нельзя использовать GetServerIsDedicated, т.к. это лишь сообщает о сервере, а не о текущей машине.
		--Хотя... Не суть. Все равно же проходим через GetIsServer.
		DEDICATED_SIDE = true
	else
		CLIENT_SIDE = true --А это оригинальное решение вечной проблемы "ismastersim".
		--Следует использовать только для инициализации сетевых переменных, не совмещая с "return" выходом из префаба!!
	end
elseif GLOBAL.TheNet:GetIsClient() then
	SERVER_SIDE = false
	CLIENT_SIDE = true
	ONLY_CLIENT_SIDE = true
end

then you can use in your code "if SERVER_SIDE then"

Edited by Serpens
Link to comment
Share on other sites

Components are ran server side, unless they are specific components like the talker. Replicas are 'components' that run with limited functionality on the client side. You can get a lot of details from the replicas of an entity on the client-side.

Link to comment
Share on other sites

Forgive me for the illogical questions. After I know that a 'Finder' mod is not possible to be client_only_mod.
I decided to go with my second mod in mind.

It's a working prototype. I'll be working on it from time to time.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...