Estevam2d Posted June 12, 2015 Share Posted June 12, 2015 how use isElementCollidableWith for the vehicle Trailer ID 591 may be in ghost mode? I've tried many ways . Link to comment
Miika Posted June 12, 2015 Share Posted June 12, 2015 Maybe you need to check wiki Client-only function This function can be used to check whether specified element is collidable with another element. Note: You can only use this function with the element types listed below. *Player*Ped*Vehicle*Object Syntax: bool isElementCollidableWith ( element theElement, element withElement ) OOP Syntax Method: element:isCollidableWith(...)Pair: setElementCollidableWith Required Arguments *theElement: The element which colliding you want to get*withElement: The other element which colliding with the first entity you want to get Returns Returns true if the elements collide with eachother, false otherwise. Example This example adds the command togglecol which toggles the collision between the player and ped. local tPed = {} addEventHandler( "onClientPlayerSpawn", localPlayer, function() local x, y, z = getElementPosition(source) if isElement(tPed["thePed"]) then destroyElement(tPed["thePed"]) end -- Creates a random ped near player tPed["thePed"] = createPed(math.random(209, 238), x+1, y+1, z) end ) function toggleColisionFunc() if not isElement(tPed["thePed"]) then return end -- Is the local player collidable with the ped? local isCollidable = isElementCollidableWith( localPlayer, tPed["thePed"] ) -- Toggles the colision with the ped. setElementCollidableWith( localPlayer, tPed["thePed"], not isCollidable ) end -- Adds a command handler to enable/disable colisions with the ped addCommandHandler("togglecol", toggleColisionFunc) Link to comment
Estevam2d Posted June 12, 2015 Author Share Posted June 12, 2015 I've checked the wiki, and when I use isElementCollidableWith in a vehicle starts to fly. prevent what a player and ped collide I already know how to do. Link to comment
Mr.unpredictable. Posted June 12, 2015 Share Posted June 12, 2015 I've checked the wiki, and when I use isElementCollidableWith in a vehicle starts to fly.prevent what a player and ped collide I already know how to do. Can you explain your problem better? Like what are you trying to do Link to comment
Estevam2d Posted June 12, 2015 Author Share Posted June 12, 2015 I want my trailer in ghost mode, preventing other players hit him. but when I try to use my setElementCollidableWith trailer starts to fly. Link to comment
Tomas Posted June 12, 2015 Share Posted June 12, 2015 I want my trailer in ghost mode, preventing other players hit him. but when I try to use my setElementCollidableWith trailer starts to fly. Post your code. Link to comment
Estevam2d Posted June 13, 2015 Author Share Posted June 13, 2015 function Caminhao() if (isElement(CargaCar[client])) then exports.BMVmsg:sendClientMessage ( "Você já esta com uma carga, entregue depois volte aqui para pegar outra" ,source, 255, 0, 0, true, 10 ) else if (isElement(RaceVehicle[client])) then destroyElement(RaceVehicle[client]) end if (isElement(CargaCar[client])) then destroyElement(CargaCar[client]) end triggerClientEvent (source,"Carga8On", source ) setPlayerTeam(source, Camiin) setPlayerNametagColor ( source, 255, 255, 0 ) setElementModel(source, 34) RaceVehicle[client] = createVehicle ( 515, -1048.572, -1246.281, 130.456,0 ,0 , 179 ) warpPedIntoVehicle ( source, RaceVehicle[client] ) CargaCar[client] = createVehicle ( 591, -1048.572, -1246.281, 130.456,0 ,0 , 179) ActiveTrailer[client] = setTimer(attachTrailerToVehicle,50,0, RaceVehicle[client], CargaCar[client] ) setElementCollisionsEnabled(CargaCar[client], false) --this makes the trailer fly end end addEvent("SetMotorista8", true) addEventHandler("SetMotorista8", root, Caminhao) Link to comment
Tomas Posted June 13, 2015 Share Posted June 13, 2015 function Caminhao() if (isElement(CargaCar[client])) then exports.BMVmsg:sendClientMessage ( "Você já esta com uma carga, entregue depois volte aqui para pegar outra" ,source, 255, 0, 0, true, 10 ) else if (isElement(RaceVehicle[client])) then destroyElement(RaceVehicle[client]) end if (isElement(CargaCar[client])) then destroyElement(CargaCar[client]) end triggerClientEvent (source,"Carga8On", source ) setPlayerTeam(source, Camiin) setPlayerNametagColor ( source, 255, 255, 0 ) setElementModel(source, 34) RaceVehicle[client] = createVehicle ( 515, -1048.572, -1246.281, 130.456,0 ,0 , 179 ) warpPedIntoVehicle ( source, RaceVehicle[client] ) CargaCar[client] = createVehicle ( 591, -1048.572, -1246.281, 130.456,0 ,0 , 179) ActiveTrailer[client] = setTimer(attachTrailerToVehicle,50,0, RaceVehicle[client], CargaCar[client] ) setElementCollisionsEnabled(RaceVehicle[client], false) setElementCollisionsEnabled(CargaCar[client], false) end end addEvent("SetMotorista8", true) addEventHandler("SetMotorista8", root, Caminhao) 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