Jump to content

[HELP] Element data


xXGhostXx

Recommended Posts

Hi guys ❤️

I have problem in element data functions :(

This code for police department vehicle faction

local policeVehicles =
{
	{597, 1531.6806640625, -1668.15234375, 13.3828125},
}
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])
		setElementData(veh,"carFaction",police)
	end
end)

function vh ( player, seat )
	if seat == 0 then
		if getElementData(source,"carFaction") == police then
			if getElementData(player,"faction") ~= police then
				cancelEvent()
				outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), vh )

but i set element data police cant enter vehicle :(

function pd(thePlayer)
    setElementData(thePlayer,"Police")
end
addCommandHandler("police",pd)

Please answer me.

Link to comment
local policeVehicles =
{
	{597, 1531.6806640625, -1668.15234375, 13.3828125},
}
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])
		setElementData(veh,"carFaction",police)
	end
end)

function vh ( player, seat )
	if seat == 0 then
		if getElementData(source,"carFaction") == police then
			if getElementData(player,"Faction" ~= "Police") then
				cancelEvent()
				outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), vh )

 

try adding onVehicleEnter to the script  i sent

Link to comment
1 hour ago, Knuck said:

local policeVehicles =
{
	{597, 1531.6806640625, -1668.15234375, 13.3828125},
}
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])
		setElementData(veh,"carFaction",police)
	end
end)

function vh ( player, seat )
	if seat == 0 then
		if getElementData(source,"carFaction") == police then
			if getElementData(player,"Faction" ~= "Police") then
				cancelEvent()
				outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), vh )

 

try adding onVehicleEnter to the script  i sent

Not Work

Link to comment

try this?

local policeVehicles =
{
	{597, 1531.6806640625, -1668.15234375, 13.3828125},
}
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])
		setElementData(veh,"carFaction",police)
	end
end)

function vh ( player, seat )
	if seat == 0 then
		if getElementData(source,"carFaction") == police and getElementData(player,"Faction" ~= police then
			cancelEvent()
			outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)
		end
	end
end
addEventHandler ( "onVehicleStartEnter", root, vh )

 

Edited by Fist
Link to comment
6 minutes ago, Fist said:

try this?


local policeVehicles =
{
	{597, 1531.6806640625, -1668.15234375, 13.3828125},
}
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])
		setElementData(veh,"carFaction",police)
	end
end)

function vh ( player, seat )
	if seat == 0 then
		if getElementData(source,"carFaction") == police and getElementData(player,"Faction" ~= police then
			cancelEvent()
			outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)
		end
	end
end
addEventHandler ( "onVehicleStartEnter", root, vh )

 

Vehicle not spawned !

Not worked :(

Link to comment

Try put in PD script 

function pd(thePlayer) 
  setElementData(thePlayer, "faction", "Police") 
end 
local policeVehicles =
{
	{597, 1531.6806640625, -1668.15234375, 13.3828125},
}
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])
		setElementData(veh,"carFaction",police)
	end
end)

function vh ( player, seat )
	if seat == 0 then
		if getElementData(source,"carFaction") == police then
			if getElementData(player,"faction") ~= police then
				cancelEvent()
				outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)
			end
		end
	end
end
addEventHandler ( "onVehicleStartEnter", root, vh )

?

 

Edited by Dimos7
Link to comment
11 hours ago, Dimos7 said:

Try put in PD script 


function pd(thePlayer)   setElementData(thePlayer, "faction", "Police") end 

local policeVehicles ={	{597, 1531.6806640625, -1668.15234375, 13.3828125},}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])		setElementData(veh,"carFaction",police)	endend)function vh ( player, seat )	if seat == 0 then		if getElementData(source,"carFaction") == police then			if getElementData(player,"faction") ~= police then				cancelEvent()				outputChatBox ( "#ffff00your are not in police department faction", player,240,155,15,true)			end		end	endendaddEventHandler ( "onVehicleStartEnter", root, vh )<span class=?">

  

Thanks ❤️

I fixed problem with you !

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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