BulleTTime Posted April 16, 2009 Share Posted April 16, 2009 Hey, For my script, i need to create a ColCuboid to check if an vehicle is inside the garage. Is there any way to use the client functions for it, would anyone make an working example of that? Thanks Link to comment
Thehookerkiller01 Posted April 18, 2009 Share Posted April 18, 2009 Hey,For my script, i need to create a ColCuboid to check if an vehicle is inside the garage. Is there any way to use the client functions for it, would anyone make an working example of that? Thanks Maybe try: function onColShapeHit ( thePlayer, matchingDimension ) if ( getElementType ( thePlayer ) == "player" ) then -- your function here end end Link to comment
Lordy Posted April 18, 2009 Share Posted April 18, 2009 And what would your example do? Just another function defined, nothing else. Please don't give some bullshit advice if you don't know what you are doing. BulletTime, you can create a colRectangle in the coordinates of the garage and then isElementWithinColShape. local colshape = createColRectangle(x, y, width, depth) -- and later if isElementWithInColShape(theVehicle, colshape) then -- blah end Note that you can't use this just out of the box, you need to define the x, y, width, height, and vehicle and all the other things too, but this is just something that it should look like. Link to comment
Mr.Hankey Posted April 18, 2009 Share Posted April 18, 2009 As you said you wanted it to be dynamic i think this would be a good solution but note that it's client-side and untested. garageCols = {} --table to store garage colshapes in function garageColShapeHit (element, matchingDimension) --get's called whenever an element enters a garage colshape --blablubb end function isElementInGarage (element, garageID) --example function to check if a given element is inside the specified garage if isElementWithinColShape (element, garageCols[garageID]) then return true end return false end function createGarageCol (garageID) if (garageID) then--if there is a garageID argument local posX, posY, posZ = getGaragePosition(garageID)--get the garage position local sizeX, sizeY, sizeZ = getGarageSize(garageID)--get the garage size if posX and sizeX then--if the functions above did not return false local colCuboid = createColCuboid (posX, posY, posZ, sizeX, sizeY, sizeZ)--create the colshape addEventHandler ("onClientColShapeHit", colCuboid, garageColShapeHit)--attach it's hit handler to the function "garageColShapeHit" garageCols[garageID] = colCuboid --store the colshape element in the garageCols table using the garageID as the index end end end im not sure if the positions will really match in this example but you should easily be able to correct them using some basic math 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