Jump to content

[HELP] Vehicle Faction


Recommended Posts

hi guys i have a problem for vehicle factions!

 

local policeVehicles =
{
	{597, 1645.125, -1367.453125, 17.443872451782},
	{597, 1641.125, -1367.453125, 17.443872451782},
	{597, 1637.125, -1367.453125, 17.443872451782},
	{597, 1633.125, -1367.453125, 17.443872451782},
	{597, 1629.125, -1367.453125, 17.443872451782},
	{597, 1625.125, -1367.453125, 17.443872451782},
	{447, 1680.181640625, -1418.8740234375, 85.044067382813},
	{447, 1680.181640625, -1400.8740234375, 85.044067382813},
	{447, 1680.181640625, -1382.8740234375, 85.044067382813},
}
local police = "Police"

addEventHandler("onResourceStart",resourceRoot,function()
	for _, v in ipairs(policeVehicles) do
		local veh = createVehicle(v[1],v[2],v[3],v[4],0,0,v[5]) -- spawn a car
		setElementData(veh,"carFaction",police) -- set car's faction
	end
end)

function vh ( player, seat )
	if seat == 0 then -- allow to sit only next to the driver
		if getElementData(source,"carFaction") == police then -- check car
			if getElementData(player,"faction") == police then -- check player
				cancelEvent()
				outputChatBox ( "#ffff00Shoma Dar Faction F.B.I Nistid!", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), vh )

what is this problem ?

all players can enter Police Vehicle :/

@JeViCo

Link to comment

fixed i guess

local policeVehicles =
{
	{597, 1645.125, -1367.453125, 17.443872451782},
	{597, 1641.125, -1367.453125, 17.443872451782},
	{597, 1637.125, -1367.453125, 17.443872451782},
	{597, 1633.125, -1367.453125, 17.443872451782},
	{597, 1629.125, -1367.453125, 17.443872451782},
	{597, 1625.125, -1367.453125, 17.443872451782},
	{447, 1680.181640625, -1418.8740234375, 85.044067382813},
	{447, 1680.181640625, -1400.8740234375, 85.044067382813},
	{447, 1680.181640625, -1382.8740234375, 85.044067382813},
}
local police = "Police"

addEventHandler("onResourceStart",resourceRoot,function()
	for _, v in ipairs(policeVehicles) do
		local veh = createVehicle(v[1],v[2],v[3],v[4]) -- spawn a car
		setElementData(veh,"carFaction",police) -- set car's faction
	end
end)

function vh ( player, seat )
	if seat == 0 then -- allow to sit only next to the driver
		if getElementData(source,"carFaction") == police then -- check car
			if getElementData(player,"faction") ~= police then -- check player
				cancelEvent()
				outputChatBox ( "#ffff00Shoma Dar Faction F.B.I Nistid!", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), vh )

 

Link to comment
9 minutes ago, JeViCo said:

fixed i guess


local policeVehicles =
{
	{597, 1645.125, -1367.453125, 17.443872451782},
	{597, 1641.125, -1367.453125, 17.443872451782},
	{597, 1637.125, -1367.453125, 17.443872451782},
	{597, 1633.125, -1367.453125, 17.443872451782},
	{597, 1629.125, -1367.453125, 17.443872451782},
	{597, 1625.125, -1367.453125, 17.443872451782},
	{447, 1680.181640625, -1418.8740234375, 85.044067382813},
	{447, 1680.181640625, -1400.8740234375, 85.044067382813},
	{447, 1680.181640625, -1382.8740234375, 85.044067382813},
}
local police = "Police"

addEventHandler("onResourceStart",resourceRoot,function()
	for _, v in ipairs(policeVehicles) do
		local veh = createVehicle(v[1],v[2],v[3],v[4]) -- spawn a car
		setElementData(veh,"carFaction",police) -- set car's faction
	end
end)

function vh ( player, seat )
	if seat == 0 then -- allow to sit only next to the driver
		if getElementData(source,"carFaction") == police then -- check car
			if getElementData(player,"faction") ~= police then -- check player
				cancelEvent()
				outputChatBox ( "#ffff00Shoma Dar Faction F.B.I Nistid!", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), vh )

 

faction member Police can't enter vehicle :|

 

Link to comment
9 minutes ago, WorthlessCynomys said:

Do you set the element data of the member of the police faction? I mean I'm quite sure that element data is not the only thing determining whether someone is police or not. 


I want to make only members of the police cops be able to board the policeVehicles!
Edited by Mσнαмα∂ Hєℓιѕн
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...