Giter Site home page Giter Site logo

carmineos / fivem-vstancer Goto Github PK

View Code? Open in Web Editor NEW
45.0 7.0 71.0 3.43 MB

ikt's VStancer as resource for FiveM servers to synchronize the edited vehicles with all the players.

Home Page: https://forum.fivem.net/t/release-c-vstancer/79219

License: MIT License

Batchfile 0.07% C# 99.93%
fivem

fivem-vstancer's Introduction

VStancer

Master Development
Build status Build status

Description

An attempt to use the features from ikt's VStancer as resource for FiveM servers to synchronize the edited vehicles with all the players. It is built using FiveM API and MenuAPI.

When a client edits a vehicle, it will be automatically synchronized with all the players. If a vehicle is reset to the default values it will stop from being synchronized. The synchronization is made using decorators.

The default key to open the menu is F6

Glossary

  • Track Width: It's the X offset of the vehicle's wheels bones in the entity local coords system. Because wheels model are rotated it means to have a positivie Track Width you have to assign a negative value.
  • Camber: It's the Y rotation of the vehicle's wheels bones in the entity local coords system.
  • Wheel Mod: It refers to a custom wheel you can apply on a vehicle from in-game tuning features. Since this term can create ambiguity with custom assets mods (wheel modifications), we will refers to these as "tuning wheels" and to game modifications as "wheel mods"

Features of the script

  • Edit Track Width of vehicles
  • Edit Camber of vehicles
  • Edit Tuning Wheel Size of vehicles (Requires a tuning wheel to be installed on the vehicle)
  • Edit Tuning Wheel Width of vehicles (Requires a tuning wheel to be installed on the vehicle)
  • Manage presets

Note

When a preset is created for the first time, it will use the current wheels' state as default. So in case of damaged vehicles (e.g. deformed wheels), the default values might be incorrect. Workaround: If a vehicle is damaged, be sure to fix it before to enter it and create a preset. (e.g. reset preset, fix the vehicle, exit the vehicle and enter again)

Client Commands

  • vstancer_preset: Prints the preset of the current vehicle
  • vstancer_decorators: Prints the info about decorators on the current vehicle
  • vstancer_decorators <int>: Prints the info about decorators on the vehicle with the specified int as local handle
  • vstancer_print: Prints the list of all the vehicles with any decorator of this script
  • vstancer_range <float>: Sets the specified float as the maximum distance used to refresh wheels of the vehicles with decorators
  • vstancer_debug <bool>: Enables or disables the logs to be printed in the console
  • vstancer: Toggles the menu, this command has to be enabled in the config

Config

  • Debug: Enables the debug mode, which prints some logs in the console
  • DisableMenu: Allows to disable the menu in case you want to allow editing in your own menu using the provided API
  • ExposeCommand: Enables the /vstancer command to toggle the menu
  • ExposeEvent: Enable the "vstancer:toggleMenu" event to toggle the menu
  • ScriptRange: The max distance within which each client refreshes edited vehicles
  • Timer: The value in milliseconds used by each client to do some specific timed tasks
  • ToggleMenuControl:The Control to toggle the Menu, default is 167 which is F6 (check the controls list)
  • FloatStep: The step used to increase and decrease a value
  • EnableWheelMod: Enables the script to edit wheel size and width of tuning wheels
  • EnableClientPresets: Enables the script to manage clients' presets
  • WheelLimits:
    • FrontTrackWidth: The max value you can increase or decrease the front Track Width from its default value
    • RearTrackWidth: The max value you can increase or decrease the rear Track Width from its default value
    • FrontCamber: The max value you can increase or decrease the front Camber from its default value
    • RearCamber: The max value you can increase or decrease the rear Camber from its default value
  • WheelModLimits:
    • WheelSize: The max value you can increase or decrease the size of tuning wheels from its default value
    • WheelWidth: The max value you can increase or decrease the width of tuning wheels from its default value

Exports

The script exposes some API to manage the main features from other scripts:

bool SetWheelPreset(int vehicle, float frontTrackWidth, float frontCamber, float rearTrackWidth, float rearCamber);
float[] GetWheelPreset(int vehicle);
bool ResetWheelPreset(int vehicle);
float[] GetFrontCamber(int vehicle);
float[] GetRearCamber(int vehicle);
float[] GetFrontTrackWidth(int vehicle);
float[] GetRearTrackWidth(int vehicle);
bool SetFrontCamber(int vehicle, float value);
bool SetRearCamber(int vehicle, float value);
bool SetFrontTrackWidth(int vehicle, float value);
bool SetRearTrackWidth(int vehicle, float value);
bool SaveClientPreset(string presetName, int vehicle);
bool LoadClientPreset(string presetName, int vehicle);
bool DeleteClientPreset(string presetName);
string[] GetClientPresetList();

NOTE Current API don't support editing of tuning wheel data (wheelSize and wheelWidth) yet.

Remember that API require the resource to be called exactly “vstancer”

API Usage

  • SetWheelPreset

    • int vehicle: the handle of the vehicle entity
    • float frontTrackWidth: the value you want to assign as front track width
    • float frontCamber: the value you want to assign as front camber
    • float rearTrackWidth: the value you want to assign as rear track width
    • float rearCamber: the value you want to assign as rear camber
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].SetWheelPreset(vehicle, frontTrackWidth, frontCamber, rearTrackWidth, rearCamber);

    Lua:

    local result = exports["vstancer"]:SetWheelPreset(vehicle, frontTrackWidth, frontCamber, rearTrackWidth, rearCamber)
  • GetWheelPreset

    • int vehicle: the handle of the vehicle entity
    • float result: the array containing the oreset values in this order frontTrackWidth, frontCamber, rearTrackWidth, rearCamber.
    Example

    C#:

    float[] result = Exports["vstancer"].GetWheelPreset(vehicle);

    Lua:

    local result = exports["vstancer"]:GetWheelPreset(vehicle);
  • ResetWheelPreset

    • int vehicle: the handle of the vehicle entity
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].ResetWheelPreset(vehicle);

    Lua:

    local result = exports["vstancer"]:ResetWheelPreset(vehicle);
  • GetFrontCamber

    • int vehicle: the handle of the vehicle entity
    • float[] frontCamber: an array which contains the value as first element if the request has success, otherwise is empty
    Example

    C#:

    float[] frontCamber = Exports["vstancer"].GetFrontCamber(vehicle);

    Lua:

    local frontCamber = exports["vstancer"]:GetFrontCamber(vehicle);
  • GetRearCamber

    • int vehicle: the handle of the vehicle entity
    • float[] rearCamber: an array which contains the value as first element if the request has success, otherwise is empty
    Example

    C#:

    float[] rearCamber = Exports["vstancer"].GetRearCamber(vehicle);

    Lua:

    local rearCamber = exports["vstancer"]:GetRearCamber(vehicle);
  • GetFrontTrackWidth

    • int vehicle: the handle of the vehicle entity
    • float[] frontTrackWidth: an array which contains the value as first element if the request has success, otherwise is empty
    Example

    C#:

    float[] frontTrackWidth = Exports["vstancer"].GetFrontTrackWidth(vehicle);

    Lua:

    local frontTrackWidth = exports["vstancer"]:GetFrontTrackWidth(vehicle);
  • GetRearTrackWidth

    • int vehicle: the handle of the vehicle entity
    • float[] rearTrackWidth: an array which contains the value as first element if the request has success, otherwise is empty
    Example

    C#:

    float[] rearTrackWidth = Exports["vstancer"].GetRearTrackWidth(vehicle);

    Lua:

    local rearTrackWidth = exports["vstancer"]:GetRearTrackWidth(vehicle);
  • SetFrontCamber

    • int vehicle: the handle of the vehicle entity
    • float frontCamber: the value you want to assign as front camber
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].SetFrontCamber(vehicle, frontCamber);

    Lua:

    local result = exports["vstancer"]:SetFrontCamber(vehicle, frontCamber);
  • SetRearCamber

    • int vehicle: the handle of the vehicle entity
    • float rearCamber: the value you want to assign as rear camber
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].SetRearCamber(vehicle, rearCamber);

    Lua:

    local result = exports["vstancer"]:SetRearCamber(vehicle, rearCamber);
  • SetFrontTrackWidth

    • int vehicle: the handle of the vehicle entity
    • float frontTrackWidth: the value you want to assign as front track width
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].SetFrontTrackWidth(vehicle, frontTrackWidth);

    Lua:

    local result = exports["vstancer"]:SetFrontTrackWidth(vehicle, frontTrackWidth);
  • SetRearTrackWidth

    • int vehicle: the handle of the vehicle entity
    • float rearTrackWidth: the value you want to assign as rear track width
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].SetRearTrackWidth(vehicle, rearTrackWidth);

    Lua:

    local result = exports["vstancer"]:SetRearTrackWidth(vehicle, rearTrackWidth);
  • SaveClientPreset

    • string presetName: the name you want to use for the saved preset
    • int vehicle: the handle of the vehicle entity you want to save the preset from
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].SaveClientPreset(presetName, vehicle);

    Lua:

    local result = exports["vstancer"]:SaveClientPreset(presetName, vehicle);
  • LoadClientPreset

    • string presetName: the name of the preset you want to load
    • int vehicle: the handle of the vehicle entity you want to load the preset on
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].LoadClientPreset(presetName, vehicle);

    Lua:

    local result = exports["vstancer"]:LoadClientPreset(presetName, vehicle);
  • DeleteClientPreset

    • string presetName: the name of the preset you want to delete
    • bool result: returns true if the action successfully executed otherwise false
    Example

    C#:

    bool result = Exports["vstancer"].DeleteClientPreset(presetName);

    Lua:

    local result = exports["vstancer"]:DeleteClientPreset(presetName);
  • GetClientPresetList

    • string[] presetList: the list of all the presets saved locally
    Example

    C#:

    string[] presetList = Exports["vstancer"].GetClientPresetList();

    Lua:

    local presetList = exports["vstancer"]:GetClientPresetList();

Source Download I am open to any kind of feedback. Report suggestions and bugs you find.

Build

Open the postbuild.bat and edit the path of the resource folder. If in Debug configuration, the post build event will copy the following files to the specified path: the built assembly of the script, the config.json, the fxmanifest.lua.

Requirements

The script uses MenuAPI by Vespura to render the UI, it uses FiveM built-in resource dependency, so the script will only work if MenuAPI resource is found and running and comes already with a built assembly so that it's ready to use.

Installation

  1. Download the zip file from the release page
  2. Extract the content of the zip to the resources folder of your server (it should be a folder named vstancer)
  3. Enable the resource in your server config (start vstancer)

Todo

  • Add API for wheel mod data
  • Update local presets API to support wheel mod data
  • Add limits check for API
  • Add limits check for preset loading
  • Workaround wheel mod data being reset after any tuning component is changed
  • Clean duplicated code
  • API shouldn't allow to edit vehicles other players are driving

Roadmap

Once FiveM exposes extra-natives to edit SubHandlingData fields at runtime, the script will allow to edit XYZ rotation using the native handling fields of CCarHandlingData such as fToeFront, fToeRear, fCamberFront, fCamberRear, fCastor. (This will also improve a lot performances as such values won't need to be set each tick)

Credits

Support

If you would like to support my work, you can through:

fivem-vstancer's People

Contributors

carmineos avatar neos7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fivem-vstancer's Issues

No Support?

I really need support on this, I can't install MenuAPI because there are absolutely no tutorials on it, even none on how to install vStancer, I've been working on this for HOURS! Make a discord server for support so people can get help, please. The Vespura people won't even help me.

Menu Placement

Just a reminder to add the option to be able to move the vStancer menu to the left side of the screen

Mod Exports (WheelModLimits )

Hi, how to exports WheelModLimits to change wheelSize and wheelWidth, cause with SetWheelPreset only save / changed WheelLimits on my esx, it's possible to add new exports for WheelModLimits ?

help

im new to this coding and creating, can you guide me on how to do the to do list

Vstancer conflicts with NativeUI

Hello,

Hoping someone can help out, I just installed this vstancer into my server but I also had a custom NativeUI menu in lua that I made and installed on my server. The NativeUI menu worked perfect but once I installed the vstancer, my menu no longer appears. If I remove vstancer it will work again but once I add it back the menu will no longer show up. The menu is set to open with F7 but I also tried different keys. I am suspecting that something with MenuAPI is conflicting with NativeUI. Is this possible and is there a way to work around it/

Thank you

Height and steering angle

Hi mate,

Would it be possible to add height and steering angle? The calls for these are below.

fSteeringLock
fSuspensionRaise

I'd love to be able to do this myself but i can hardly wipe my own arse ;)

Doesnt compile

Tried to compile the code my self and it didn't work. The compiler (Visual Studio) finds a problem at the 43rd line of VStancer.Client.csproj . To be clear I didn't change any of the code I just wanted to check the code myself. The error is

Error MSB3073 The command "if '' == '' (

Hope to fix it soon. Thanks in advance

Saving in db

Hello i use script which make exports to vstancer but how i can make it when i make changes in my script to save in db and when u put car in garage and take out to be with last settings ?

Need help with vstancer

[ 653281] [b2944_GTAProce] MainThrd/ ^3[WARNING] [vstancer] Closing all menus because this resource is being stopped, to prevent the UI Prompts getting stuck.^7
[ 653344] [b2944_GTAProce] UV loop: httpClient/ Required resources: vstancer
[ 653375] [b2944_GTAProce] MainThrd/ OnConnectionProgress: Loading content manifest...
[ 653391] [b2944_GTAProce] 12368/ ResourceCache::AddEntry: Saved cache:v1:cff29dd51087eeef9b5be71ddbf833c94d388709 to the index cache.
[ 653406] [b2944_GTAProce] MainThrd/ Creating script environments for vstancer
[ 653578] [b2944_GTAProce] MainThrd/ Loaded VStancer.Client.net, Version=1.4.320.0, Culture=neutral, PublicKeyToken=null into ScriptDomain_973252458
[ 653594] [b2944_GTAProce] MainThrd/ Loaded MenuAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null into ScriptDomain_973252458
[ 653609] [b2944_GTAProce] MainThrd/ Instantiated instance of script MenuAPI.MenuController.
[ 653625] [b2944_GTAProce] MainThrd/ Registering EventHandler onResourceStop for attributed method OnResourceStop, with parameters System.RuntimeType
[ 653625] [b2944_GTAProce] MainThrd/ Loaded Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed into ScriptDomain_973252458
[ 653734] [b2944_GTAProce] MainThrd/ MainScript: Loaded config from config.json
[ 653750] [b2944_GTAProce] MainThrd/ Instantiated instance of script VStancer.Client.Scripts.MainScript.
[ 653750] [b2944_GTAProce] MainThrd/ OnConnectionProgress: Mounted vstancer (1 of 1)
[ 676078] [b2944_GTAProce] MainThrd/ MainScript: Missing bool argument
[ 683344] [b2944_GTAProce] MainThrd/
[ 832516] [b2944_GTAProce] MainThrd/

Source code didn't update!

I want to translate vstancer but the source code did not update so I cannot find some functions such as "Suspension Menu" in my visual studio

height?

can we expect to see height added soon ? loving this so far

vehiclelayouts.meta

I have noticed you cannot adjust suspension on vehicles that do not have "vehiclelayouts.meta". Is there a way around this?

Option to disable key enhancement

Hi,

Not an issue but a remark...
Maybe is a good idea to make a boolean in the config file to remove the ToggleMenuControl. Ofc we can put nothing in config file to not let it trigger, but is will alway execute the native that is not nessesary. It is great that enableing/disableing event is in the config file already. I will make it work only ls cusom can have access to the menu.

Widescreen aspect ratio warning spam

I run a widescreen monitor (almost 21:9) and my console is spammed with warnings. I tried looking into the code but only saw that the alignment is changed once. I do not have this issue with vMenu so it's probably not an issue with the MenuAPI.
image

Any chance of donate to get exports for wheelsize/wheelwidth

Hi,

im using the exports for the stance very well now.

I wanted to ask if there is any chance to donate some money to get exports for wheelsize/width also.

Maybe also some performance update. I dont know if its normal but for us it takes about 0.34ms.

Greetings.

Requests for the Script

Hey,

just found the script and played with it for a while.

Since my server is an roleplay server where I dont want anyone to be able to change their tyre width or camber anywhere and anytime. I would appreciate the feature to set one or multiple jobs that can open the menu so that I can put in the job names in the config and only these jobs can open it then.

If its already a thing in the script pls let me now.

Paintsmoker

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.