🍇
OtherScriptDevGitBook
  • 🍇About
  • 📲Support & Contact
  • ℹ️Documentation
    • 🔫 OSD-AMMUNATION
    • 📜OSD-INSURANCES
Powered by GitBook
On this page
  • INSTALLATION
  • FUNCTIONS AND API
  1. Documentation

OSD-INSURANCES

Previous🔫 OSD-AMMUNATION

Last updated 1 year ago

Our new insurance script will allow you to add a fully configurable system to your city to add different types of insurance for cars, private properties, real estate, among thousands of other options... your imagination is the limit.

Our team recommends having a minimum knowledge about script programming and installation in FiveM to be able to carry out the installation of all our products. If you do not have this knowledge, we invite you to enter our Discord to request help.

INSTALLATION

Dependencies

  • QB-Core Framework

  • Ox MySql

  • ESX 1.0 Final or ESX Legacy Framework.

  • MySql Async

  • Ox MySql or MySql Async

SCRIPT INSTALLATION

  1. Unzip the script file.

  2. Put the file called "osd-insurances" into your resources folder and be sure it´s ensured in your server cfg file.

  3. Go to osd-insurances/SHARED and excecute the file called "insert_me.sql" in the same folder you will see the items images for the insurances items.

  4. Now go to the config.lua file and edit as your prefer.

ITEMS INSTALLATION

  1. Insert the following items below into "qb-core/shared/items.lua".

  2. Go to "osd-insurances/SHARED" folder and open the "inventory_image" folder copy and paste the images into your inventory images folder.

['health_insurance']				 = {['name'] = 'health_insurance',					['label'] = 'Health Insurance Papers',				['weight'] = 0,			['type'] = 'item',		['image'] = 'health_insurance.png',		['unique'] = true,		['useable'] = true,		['shouldClose'] = false,	['combinable'] = nil,	['description'] = 'Vehicle insurance paper'},
['car_insurance']				 = {['name'] = 'car_insurance',					['label'] = 'Car Insurance Papers',				['weight'] = 0,			['type'] = 'item',		['image'] = 'car_insurance.png',		['unique'] = true,		['useable'] = true,		['shouldClose'] = false,	['combinable'] = nil,	['description'] = 'Vehicle insurance paper'},
['house_insurance']				 = {['name'] = 'house_insurance',					['label'] = 'House Insurance Papers',				['weight'] = 0,			['type'] = 'item',		['image'] = 'house_insurance.png',		['unique'] = true,		['useable'] = true,		['shouldClose'] = false,	['combinable'] = nil,	['description'] = 'Vehicle insurance paper'},

In the SHARED folder located into "osd-insurances" insert the "esx_items.sql" if you dont use weight system or "esx_items_weight.sql" if you are using weight system in your ESX Framework.

Go to "osd-insurances/SHARED" folder and open the "inventory_image" folder copy and paste the images into your inventory images folder.

In order for the metadata of the items to appear in your inventory you must add the following code (applicable for qs-inventory and qb-inventory) If you have another type of inventory please verify it yourself or open a ticket in our discord community.

QS-INVENTORY: Go to configs folder and open the metadatas.js file with a code editor.

}else if(itemData.name == 'health_insurance'){
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p><strong>Plan Owner Name: </strong><span>" +
                itemData.info.name +
                "</span></p><p><strong>Plan: </strong><span>" +
                itemData.info.plan +
                "</span></p><p><strong>Memebership: </strong><span>" +
                itemData.info.memebership 
            );
        } else if(itemData.name == 'car_insurance'){
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p><strong>Plan Owner Name: </strong><span>" +
                itemData.info.name +
                "</span></p><p><strong>Plan: </strong><span>" +
                itemData.info.plan +
                "</span></p><p><strong>Memebership: </strong><span>" +
                itemData.info.memebership 
            );
        } else if(itemData.name == 'house_insurance'){
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p><strong>Plan Owner Name: </strong><span>" +
                itemData.info.name +
                "</span></p><p><strong>Plan: </strong><span>" +
                itemData.info.plan +
                "</span></p><p><strong>Memebership: </strong><span>" +
                itemData.info.memebership 
            );

QB-INVENTORY: Line 448 around in qb-inventory/html/js/app.js


}else if(itemData.name == 'health_insurance'){
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p><strong>Plan Owner Name: </strong><span>" +
                itemData.info.name +
                "</span></p><p><strong>Plan: </strong><span>" +
                itemData.info.plan +
                "</span></p><p><strong>Memebership: </strong><span>" +
                itemData.info.memebership 
            );
        } else if(itemData.name == 'car_insurance'){
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p><strong>Plan Owner Name: </strong><span>" +
                itemData.info.name +
                "</span></p><p><strong>Plan: </strong><span>" +
                itemData.info.plan +
                "</span></p><p><strong>Memebership: </strong><span>" +
                itemData.info.memebership 
            );
        } else if(itemData.name == 'house_insurance'){
            $(".item-info-title").html("<p>" + itemData.label + "</p>");
            $(".item-info-description").html(
                "<p><strong>Plan Owner Name: </strong><span>" +
                itemData.info.name +
                "</span></p><p><strong>Plan: </strong><span>" +
                itemData.info.plan +
                "</span></p><p><strong>Memebership: </strong><span>" +
                itemData.info.memebership 
            );

FUNCTIONS AND API

Our system allows you to use a small api that we have added so that you can use our script and adapt it to other scripts that you want. Next we will explain and give examples of the correct use of our api.

If you wanna know what kind of insurance plan has a player you can use a function to get that information.

THIS FUNCTION CAN BE USED ONLY SERVER-SIDE NOT CLIENT-SIDE

exports['osd-insurances']:GetPlayerPlan(source)

EXAMPLE:

local source = source
local player_plan = exports['osd-insurances']:GetPlayerPlan(source)

if player_plan == 'Vehicle' then
    -- add your code here
end

This will help you to know the type of membership the player has, suppose you want a player to only be able to access an area if they have Diamond membership.

THIS FUNCTION CAN BE USED ONLY SERVER-SIDE NOT CLIENT-SIDE

exports['osd-insurances']:GetPlayerMembership(source)
EXAMPLE:

local source = source
local player_membership = exports['osd-insurances']:GetPlayerMembership(source)

if player_membership == 'Plan Diamond' then
    -- add your code here
end

We do not know if this will really be useful but we include it just in case. If you want to know when will be the next date that the player must pay his plan, you can do so using the following code.

THIS FUNCTION CAN BE USED ONLY SERVER-SIDE NOT CLIENT-SIDE

EXAMPLE

local source = source
local player_next_payment = exports['osd-insurances']:GetPlayerNextPayment(source)
local day, month, year = os.date("*t").day, os.date("*t").month, os.date("*t").year
local concated_date = day..'/'..month..'/'..year

if concated_date == player_next_payment then
    --add your cool code here
end

FOR QB-CORE USERS EXAMPLE USING QB-AMBULANCEJOB

RegisterNetEvent('hospital:server:SendToBed', function(bedId, isRevive)
	local src = source
	local Player = QBCore.Functions.GetPlayer(src)
	local player_plan = exports['osd-insurances']:GetPlayerPlan(src)
	local player_membership = exports['osd-insurances']:GetPlayerMembership(src)
	local bill_descount = 0
	if player_plan == 'Health' then
	   if player_membership == 'Plan Bronze' then
		-- So if player has the plan bronze let´s made a descount of 500 usd on the bill
		bill_descount = 500
	    elseif player_membership == 'Plan Gold' then
		-- continue using your imagination xd
		bill_descount = 500
	    elseif player_membership == 'Plan Diamond' then
	        -- continue using your imagination xd
		bill_descount = 500
	    end
	end
	TriggerClientEvent('hospital:client:SendToBed', src, bedId, Config.Locations["beds"][bedId], isRevive)
	TriggerClientEvent('hospital:client:SetBed', -1, bedId, true)
	-- So here the to Config.BillCost we going to rest the bill descount cause the player has a memebership
	Player.Functions.RemoveMoney("bank", (Config.BillCost - bill_descount) , "respawned-at-hospital")
	exports['qb-management']:AddMoney("ambulance", Config.BillCost)
	TriggerClientEvent('hospital:client:SendBillEmail', src, (Config.BillCost - bill_descount))
end)

FOR ESX USERS EXAMPLE USING ESX_AMBULANCEJOB

ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(source, cb)
	local xPlayer = ESX.GetPlayerFromId(source)
	local player_plan = exports['osd-insurances']:GetPlayerPlan(source)
	local player_membership = exports['osd-insurances']:GetPlayerMembership(source)
	
	if Config.OxInventory and Config.RemoveItemsAfterRPDeath then
		exports.ox_inventory:ClearInventory(xPlayer.source)
		return cb()
	end

	if Config.RemoveCashAfterRPDeath then
		if xPlayer.getMoney() > 0 then
	           if player_plan == 'Health' then
			if player_membership == 'Diamond' then -- SO if player has the diamond memebership let's keep the money on his wallet and we will not remove it in case he dies and must appear at the hospital.
			    -- do nothing
			else -- else(if player dosent´have the diamond let´s remove the wallet money :)))
			   xPlayer.removeMoney(xPlayer.getMoney(), "Death")
			end
		    end
		end

		if xPlayer.getAccount('black_money').money > 0 then
		   if player_plan == 'Health' then
			if player_membership == 'Diamond' then -- SO if player has the diamond memebership let's keep the money on his wallet and we will not remove it in case he dies and must appear at the hospital.
			    -- do nothing
			else -- else(if player dosent´have the diamond let´s remove the wallet money :)))
			   xPlayer.setAccountMoney('black_money', 0, "Death")
			end
		    end
		end
	end

	if Config.RemoveItemsAfterRPDeath then
		for i = 1, #xPlayer.inventory, 1 do
			if xPlayer.inventory[i].count > 0 then
				xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0)
			end
		end
	end

	if Config.OxInventory then return cb() end

	local playerLoadout = {}
	if Config.RemoveWeaponsAfterRPDeath then
		for i = 1, #xPlayer.loadout, 1 do
			xPlayer.removeWeapon(xPlayer.loadout[i].name)
		end
	else -- save weapons & restore em' since spawnmanager removes them
		for i = 1, #xPlayer.loadout, 1 do
			table.insert(playerLoadout, xPlayer.loadout[i])
		end

		-- give back wepaons after a couple of seconds
		CreateThread(function()
			Wait(5000)
			for i = 1, #playerLoadout, 1 do
				if playerLoadout[i].label ~= nil then
					xPlayer.addWeapon(playerLoadout[i].name, playerLoadout[i].ammo)
				end
			end
		end)
	end

	cb()
end)

ℹ️
📜
📲Support & Contact