C# GTAV Multiplayer Intermediate Layer


The resouce itself:

Made C# client-server resource which would help developers to structure their gamemodes with callbacks. In clientside there are currently 103 different callbacks and 97 in serverside. You can see all callbacks from here: https://github.com/Caupz/GTAV-MPFramework with all the instructions to how to get it running.

There are some additional features that are in experimental mode like random wind and weather system. Those can be enable/disable through object properties (more info at github). If you also want to enable debug logs on client events then set ClientCore object.debug = true;

I’m going to post a few of them here:

...
OnPlayerStartedOnVehicle(Player player);
OnPlayerStoppedOnVehicle(Player player);
OnVehicleHealthGain(Player player, int vehicleNetworkId, int vehicleHealth, float vehicleBodyHealth, float vehicleEngineHealth, float vehiclePetrolTankHealth);
OnVehicleHealthLoss(Player player, int vehicleNetworkId, int vehicleHealth, float vehicleBodyHealth, float vehicleEngineHealth, float vehiclePetrolTankHealth);
OnVehicleCrash(Player player, int vehicleNetworkId);
OnPlayerStartedAiming(Player player, uint weapon);
OnPlayerStoppedAiming(Player player, uint weapon);
OnPlayerReadyToShoot(Player player, uint weapon);
OnPlayerNotReadyToShoot(Player player);
OnPlayerEnteredMainMenu(Player player);
OnPlayerLeftMainMenu(Player player);
...

I have tested all events/callbacks in client- & serverside how you want to call them except the OnPlayerStunned ones.

There are going to be updates in next few weeks when I have more time, going to have to run at the moment. Just thought it would help already someone…

2 Likes

Is that perfromance good?

About your “main tick loop” :

API.Wait(0); 

Should await Basescript.Delay instead

1 Like

Oh yeah right. Thanks for the suggestion. Will be making the change when I get to the computer. :slight_smile:

I will talk about the performance when I get behind computer.

//Edit: Made adjustments to the API.Wait part.
//Edit 2: I ran this in my pretty empty cnr testing gamemode: @negbook

Every tick 1 row was logged how long the main function took to finish.
ticksspent

There were resouces includes like:

  • ensure cnr // my demo gamemode
  • ensure fxmigrant
  • ensure mapmanager
  • ensure chat
  • ensure spawnmanager
  • ensure sessionmanager
  • ensure fivem
  • ensure hardcap
  • ensure rcon-log
  • ensure baseevents

My PC:

  • 8GB DDR3 1333MHz
  • Intel i5-6400 2.70GHz
  • GTX 960 4GB

Graphics settings were this and that… Blur and such effects normal (low as possible) and texture and geometry complexity Ultra.

1 Like

Update to the resource

Moved following features from clientside to serverside so all players would be synced with the same environmental values:

  • Realtime to gametime
  • Random wind force and direction
  • Random weather setting and transitioning

Some new stuff in serverside:

  • Added debug option and some logs to there if debug is true
  • Added following events:
    OnSecondUpdate
    OnMinuteUpdate
    OnHourUpdate

I have not tested them in serverside yet, but should work because in clientside they did. Will be do more testing in next few days.

Peace :v:

1 Like

Good job man :+1:

1 Like