xXGhostXx Posted October 4, 2018 Share Posted October 4, 2018 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
xXGhostXx Posted October 4, 2018 Author Share Posted October 4, 2018 Please answer me ! @Knuck @N3xT @Dimos7 Link to comment
MIKI785 Posted October 4, 2018 Share Posted October 4, 2018 You're not setting any value. Link to comment
xXGhostXx Posted October 4, 2018 Author Share Posted October 4, 2018 2 minutes ago, MIKI785 said: You're not setting any value. This is your help ? Link to comment
MIKI785 Posted October 4, 2018 Share Posted October 4, 2018 Yes? I've told you what's wrong. Also, I can't see getElementData with the same data name anywhere. Link to comment
VenomOG Posted October 4, 2018 Share Posted October 4, 2018 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
xXGhostXx Posted October 4, 2018 Author Share Posted October 4, 2018 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
Fist Posted October 4, 2018 Share Posted October 4, 2018 (edited) 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 October 4, 2018 by Fist Link to comment
xXGhostXx Posted October 4, 2018 Author Share Posted October 4, 2018 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
Dimos7 Posted October 4, 2018 Share Posted October 4, 2018 (edited) 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 October 4, 2018 by Dimos7 Link to comment
xXGhostXx Posted October 5, 2018 Author Share Posted October 5, 2018 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 )?"> Thanks I fixed problem with you ! Link to comment
Recommended Posts