JoaoZanetti Posted February 3, 2019 Share Posted February 3, 2019 Hi everyone! Im trying to make a resource that remove your vehicle collision when you press H. The purpose of this resource is that no one can crash in your vehicle, this function is working fine, but when you hit someone that dont have ghost activated, his car get crashed. I want to make possible if you have ghost activated no one can crash in your car and you cant crash each others cars. I added line 11 because i think that making this function again changing sides would work, but didnt happen. Spoiler local ghostOpt = false function setVehicleGhost() local sourceVehicle = getPedOccupiedVehicle(localPlayer) local vehicles = getElementsByType("vehicle") for _, vehicle in ipairs(vehicles) do -- No one can crash you setElementCollidableWith(vehicle, sourceVehicle, not ghostOpt) -- You cant crash no one setElementCollidableWith(sourceVehicle, vehicle, not ghostOpt) end end addEventHandler("onClientVehicleEnter", root, setVehicleGhost) function ghostMode() local v = getPedOccupiedVehicle(localPlayer) if(v == nil or v == false) then outputChatBox ( "#FFFFFF[#FFFFFF #7AF1B9PDB #FFFFFF]#FFFFFF#CBCECE Você precisa estar em um veiculo", 255, 255, 255, true) return end if(ghostOpt) then outputChatBox ( "#FFFFFF[#FFFFFF #7AF1B9PDB #FFFFFF]#FFFFFF#CBCECE Ghost desativado", 255, 255, 255, true) -- Ghost deactivated ghostOpt = false setVehicleGhost() else outputChatBox ( "#FFFFFF[#FFFFFF #7AF1B9PDB #FFFFFF]#FFFFFF#CBCECE Ghost ativado", 255, 255, 255, true) -- Ghost activated ghostOpt = true setVehicleGhost() end end bindKey("h", "down", ghostMode) function onStreamIn() if(ghostOpt) then if(getElementType(source) == "vehicle") then setVehicleGhost() end end end addEventHandler("onClientElementStreamIn", root, onStreamIn) Link to comment
WorthlessCynomys Posted February 3, 2019 Share Posted February 3, 2019 Hello! Make it a server side command and use triggerClientEvent to trigger an event for everyone on clientside. In this event, pass the vehicle that should be ghosted, and on clientside disable that given vehicles collision. Doing this will disable the collisions of that vehicle to all ONLINE players, making it uncollidable for everyone. Link to comment
JoaoZanetti Posted February 3, 2019 Author Share Posted February 3, 2019 1 minute ago, WorthlessCynomys said: Hello! Make it a server side command and use triggerClientEvent to trigger an event for everyone on clientside. In this event, pass the vehicle that should be ghosted, and on clientside disable that given vehicles collision. Doing this will disable the collisions of that vehicle to all ONLINE players, making it uncollidable for everyone. Thanks for your answer! But, if someone spawn a car i receive a onClientElementStreamIn event, and when i receive this i call setVehicleGhost() function again, when i use getElementsByType("vehicle") shoudnt be returned all online server vehicles? Link to comment
WorthlessCynomys Posted February 3, 2019 Share Posted February 3, 2019 12 minutes ago, JoaoZanetti said: Thanks for your answer! But, if someone spawn a car i receive a onClientElementStreamIn event, and when i receive this i call setVehicleGhost() function again, when i use getElementsByType("vehicle") shoudnt be returned all online server vehicles? GetElementsByType is side specific. Link to comment
JoaoZanetti Posted February 3, 2019 Author Share Posted February 3, 2019 30 minutes ago, WorthlessCynomys said: GetElementsByType is side specific. I didnt understand that part but i will implement what you said on first reply. Thanks. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now