Moderators Patrick Posted March 20, 2020 Moderators Posted March 20, 2020 (edited) https://wiki.multitheftauto.com/wiki/SetElementCollisionsEnabled Note: Vehicles that are collisionless and have a driver will cause bugs. Note: Enabling a players collisions when they're inside a vehicle will cause bugs. Note: Disabling a peds collisions will cause some problems, such as it being unable to move or wrong rotation after creation. But I think setElementCollidableWith what you want. Check the example on wiki. Edited March 20, 2020 by Patrick
hrtht Posted March 20, 2020 Author Posted March 20, 2020 function ghostmode_on() local playerVehicle = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle if(playerVehicle) then -- Check the return value. for i,v in pairs(getElementsByType("vehicle")) do --LOOP through all vehicles setElementCollidableWith(v, playerVehicle, false) -- Set the collison off with the other vehicles. end outputChatBox("You are now a Ghost") end end addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command. What I need to change to get it working with players? I'm new help me man
Moderators Patrick Posted March 20, 2020 Moderators Posted March 20, 2020 3 minutes ago, hrtht said: What I need to change to get it working with players? I'm new help me man function ghostmode_on() for i,v in pairs(getElementsByType("player")) do --LOOP through all players setElementCollidableWith(v, localPlayer, false) -- Set the collison off with the other vehicles. end outputChatBox("You are now a Ghost") end addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command. Replace vehicle elements with players.
hrtht Posted March 20, 2020 Author Posted March 20, 2020 3 hours ago, Patrick said: function ghostmode_on() for i,v in pairs(getElementsByType("player")) do --LOOP through all players setElementCollidableWith(v, localPlayer, false) -- Set the collison off with the other vehicles. end outputChatBox("You are now a Ghost") end addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command. Replace vehicle elements with players. How to add a output for saying that you're no longer Ghost?
Moderators Patrick Posted March 20, 2020 Moderators Posted March 20, 2020 8 minutes ago, hrtht said: How to add a output for saying that you're no longer Ghost? I'm happy to help but you also have to learn. Some Lua tutorial for you: - https://forum.multitheftauto.com/topic/121619-Lua-for-absolute-beginners - https://forum.multitheftauto.com/topic/64228-the-ultimate-Lua-tutorial/ - https://forum.multitheftauto.com/topic/95654-tut-debugging/ - https://forum.multitheftauto.com/topic/114541-tut-events/ local status = false function ghostmode_toggle() status = not status -- toggle status if status then for i,v in pairs(getElementsByType("player")) do --LOOP through all players setElementCollidableWith(v, localPlayer, false) -- Set the collison off with the other players. end outputChatBox("You are now a Ghost") else for i,v in pairs(getElementsByType("player")) do --LOOP through all players setElementCollidableWith(v, localPlayer, true) -- Set the collison on with the other players. end outputChatBox("You aren't a Ghost") end end addCommandHandler("ghostmode", ghostmode_toggle) -- Add the /ghostmode Command.
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