Clientside/Serverside

Hello there,
I am new to FiveM and I dont get the concept of the client/serverside of things. For example, if a player wants to spawn a vehicle, why should a function like that be client side implemented? Wouldn’t it be better if its serverside to check credentials or requirements of the player before spawning the car? Then spawn it on serverside? If its handled on client side, It can easily get abused, right? How is the security aspect in that? I am quite confused.

Spawning a vehicle is not client side. In order for someone to spawn a vehicle on your server, you will have to have the resource installed on your server in order for your server to load that vehicle in game.

Client Side: These files are located on your computer therefore they aren’t streamed to the server since they are local on your computer.

Server Side: These files are located on your server therefore they are streamed to other users on your server.

Thanks for the reply! :slight_smile:

I am looking a this example someone posted. There are 2 scripts right? Server and client side.

  local spawned_car = CreateVehicle(vehicle, coords, GetEntityHeading(myPed), true, false)

is executed on clientside?

No, that’s server side. If you’re looking for a simple way to spawn cars with a chat command like /car CARNAME, I would suggest checking this out.

Servers don’t run any game code, nor can they because GTA V isn’t open source.

Therefore, the client has to be considered trusted anyway, since they will run the game simulation for each and every entity. There’s various ways you can safeguard stuff to make sure no ‘invalid’ entities get spawned, but typically entity creation will be done client-side at this time.

Ok so everything is serverside there, I was confused by the naming then. I don’t really look for a car spawn, I am trying to get the concept here. Thanks for your help.

I dont expect the server to run any game code but what happens if a client sends faked pakets? Will it be broadcasted to all other players on the server? Do they see the effects of his actions (for example a car spawn)?