Jump to content

CollidableWith mode Ghost


Recommended Posts

Maybe you need to check wiki :D

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.

Syntax:

bool isElementCollidableWith ( element theElement, element withElement ) 

OOP Syntax

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
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
  
    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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...