Jump to content

Client or Server Side ?


DarkLink

Recommended Posts

Hey guys, i have some problem here.

Everytime i start to look for functions that i need to use on my script, i always wonder which ones i should look?

Server Side or Client Side?

Like u should know there are many functions with nearly the same name on client and server side, i dont know which to chose for what situations..

Did u guys understand, my question here?

Sorry my bad english :/

Thanks alot in advance. I think i must know the differences, and when to use which.. so i can start doing scripts with my head.

Thanks again ;)

Link to comment

server side functions you can use for all players, lets chose event bindKey.

In server side, you can do this

function onJoin ( ) 
  bindKey ( source, "N", "down", functionName )  
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin ) 
  

So, this will bind N key for some function, when player joins.

If you are using client side , then you dont need to add player argument, because its only for one player, who's using client side ( everyone can use ...)

function onJoin ( ) 
  bindKey ( "N", "down", functionName )  
end 
addEventHandler ( "onClientResourceStart", getRootElement(), onJoin ) 

I hope you can understand me,..

Edited by Guest
Link to comment

client side code is executed by the computer of the player while server side code is executed by the machine the server runs on. this has a huge impact on the usability of functions.

for example setWeather can be used to set the current weather for everyone (server side) or just for a single person (client side).

in some cases it doesn't really matter what you choose. as all client side files are downloaded by everyone you can also use setWeather client side for everyone. but keep in mind that client side code needs this procedure of downloading and client side code is easy to access for everyone on your server, so they might take the code, steal it or grab important information from it.

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...