xXGhostXx Posted October 4, 2018 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.
xXGhostXx Posted October 4, 2018 Author Posted October 4, 2018 Please answer me ! @Knuck @N3xT @Dimos7
MIKI785 Posted October 4, 2018 Posted October 4, 2018 You're not setting any value. Lua Scripter Owner of mshost.cz MTA portal.
xXGhostXx Posted October 4, 2018 Author Posted October 4, 2018 2 minutes ago, MIKI785 said: You're not setting any value. This is your help ?
MIKI785 Posted October 4, 2018 Posted October 4, 2018 Yes? I've told you what's wrong. Also, I can't see getElementData with the same data name anywhere. Lua Scripter Owner of mshost.cz MTA portal.
VenomOG Posted October 4, 2018 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
xXGhostXx Posted October 4, 2018 Author 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
Fist Posted October 4, 2018 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
xXGhostXx Posted October 4, 2018 Author 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
Dimos7 Posted October 4, 2018 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
xXGhostXx Posted October 5, 2018 Author 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 !
Recommended Posts