Integrations

Integrations Guide

You need msk_core! - Download it here

This Guide show examples on how to integrate msk_vehiclekeys into f.e.: VehicleShops, etc.

It is already integrated in MSK EngineToggle and MSK Garage

EngineToggle Scripts
okokVehicleShop
  • Go to okokVehicleshop\cl_utils.lua and edit the following Events:

RegisterNetEvent(Config.EventPrefix..":giveKeys")
AddEventHandler(Config.EventPrefix..":giveKeys", function(vehicle)
    Wait(2000) -- to make sure u are in the vehicle when the key is given
    exports.msk_vehiclekeys:AddPrimaryKey(vehicle)
end)

RegisterNetEvent(Config.EventPrefix..":giveKeysTestDrive")
AddEventHandler(Config.EventPrefix..":giveKeysTestDrive", function(vehicle)
    Wait(2000) -- to make sure u are in the vehicle when the key is given
    exports.msk_vehiclekeys:AddTempKey(vehicle)
end)

RegisterNetEvent(Config.EventPrefix..":giveKeysTowTruck")
AddEventHandler(Config.EventPrefix..":giveKeysTowTruck", function(vehicle)
    Wait(2000) -- to make sure u are in the vehicle when the key is given
    exports.msk_vehiclekeys:AddTempKey(vehicle)
end)

RegisterNetEvent(Config.EventPrefix..":onFinishTestDrive")
AddEventHandler(Config.EventPrefix..":onFinishTestDrive", function(vehicle)
    exports.msk_vehiclekeys:RemoveTempKey(vehicle)
end)

RegisterNetEvent(Config.EventPrefix..":deleteVehicle")
AddEventHandler(Config.EventPrefix..":deleteVehicle", function()
    if sellingVehicle ~= nil then
	exports.msk_vehiclekeys:RemovePrimaryKey(sellingVehicle)
	DeleteEntity(sellingVehicle)
	sellingVehicle = nil
    end
end)
dealerships_creator
  • Go to dealerships_creator/integrations/cl_integrations.lua and add the following Events:

AddEventHandler("dealerships_creator:testDrive:vehicleSpawned", function(vehicle, vehicleNetId)
    SetVehicleFuelLevel(vehicle, 100.0)
    exports.msk_vehiclekeys:AddTempKey(vehicle)
end)
  • Go to dealerships_creator/integrations/sv_integrations.lua and add the following Events:

AddEventHandler("dealerships_creator:giveVehicleToPlayerId", function(playerId, vehicleName, plate)
    Wait(2000) -- To make sure the vehicle is saved in databasse
    exports.msk_vehiclekeys:AddPrimaryKey({source = playerId}, {plate = plate})
end)
jobs_creator
  • Go to jobs_creator/integrations/cl_integrations.lua and add the following Events:

AddEventHandler("jobs_creator:permanent_garage:vehicleSpawned", function(vehicle, vehicleName, vehiclePlate)
    Wait(2000) -- to make sure u are in the vehicle when the key is given
    exports.msk_vehiclekeys:AddPrimaryKey(vehicle)
end)

AddEventHandler("jobs_creator:permanent_garage:vehicleParked", function(vehicleModel, vehiclePlate)
    exports.msk_vehiclekeys:RemovePrimaryKey({plate = vehiclePlate, model = vehicleModel})
end)

AddEventHandler("jobs_creator:garage_owned:vehicleSpawned", function(vehicle, vehicleName, vehiclePlate)
    Wait(2000) -- to make sure u are in the vehicle when the key is given
    exports.msk_vehiclekeys:AddPrimaryKey(vehicle)
end)

AddEventHandler("jobs_creator:garage_owned:vehicleParked", function(vehicleModel, vehiclePlate)
    exports.msk_vehiclekeys:RemovePrimaryKey({plate = vehiclePlate, model = vehicleModel})
end)

AddEventHandler("jobs_creator:temporary_garage:vehicleSpawned", function(vehicle, vehicleName, vehiclePlate)
    Wait(2000) -- to make sure u are in the vehicle when the key is given
    exports.msk_vehiclekeys:AddTempKey(vehicle)
end)

AddEventHandler("jobs_creator:temporary_garage:vehicleParked", function(vehicleModel, vehiclePlate)
    exports.msk_vehiclekeys:RemoveTempKey({plate = vehiclePlate, model = vehicleModel})
end)
qs-advancedgarages
  • Go to qs-advancedgarages\config\config.lua and insert the following on line ~186

local mskvehiclekeys = GetResourceState('msk_vehiclekeys') == 'started'
  • Then insert the following at line 208-210

elseif mskvehiclekeys then
    return 'msk_vehiclekeys'
else
  • Create a new file named msk_vehiclekeys.lua and place this file into: qs-advancedgarages\client\custom\vehiclekeys

  • Add the following code into this file:

if Config.Vehiclekeys ~= 'msk_vehiclekeys' then
    return
end

function AddVehiclekeys(vehicle, plate, item)
    exports.msk_vehiclekeys:AddPrimaryKey(vehicle)
end

function RemoveVehiclekeys(vehicle, plate)
    exports.msk_vehiclekeys:RemovePrimaryKey(vehicle)
end

Last updated