Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/11/21 in Posts

  1. You're welcome, friend! I really enjoy people like you who are willing to go on this difficult journey to learn programming. May you have a good future inside of the MTA community!
    1 point
  2. The easiest and recommended way to check for validity of the theVehicle variable is to ask the Lua runtime whether theVehicle is not nil and not false. You can do that with a simple if-condition where the condition consists of the variable only. Like this: ... local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) if (theVehicle) then local vehType = getVehicleType(theVehicle) -- Warning is Here ... This check is sufficient due to the documentation of the getPedOccupiedVehicle function. It says that it returns false only if the player is not inside of a vehicle. Else it returns a vehicle element which is never false and never nil. Don't worry about yourself. You seem to be progressing in the right direction. ?
    1 point
  3. Have you downloaded the traffic resource from MTA community? Take a look into it. It has got the things you need.
    1 point
  4. دائماً مبدع يـ طرب استمر .
    1 point
  5. You should be able to solve the first part of the question by yourself using the same approach that you used for the player but now based on the player's vehicle. To implement the second part you need to know about safe coordinates for vehicle placement that are not inside water and connect that to the first part of the question using the setElementPosition function. Since MTA by default does not provide you with a function to retrieve recommended land positions I suggest you to try taking the traffic path nodes from the MTA community traffic resource. The path node definitions are located in the definitions folder. The most interesting function inside of the resource is the following (traffic_common.lua): function pathsNodeFindClosest ( x, y, z ) local areaID = getAreaFromPos ( x, y, z ) local minDist, minNode local nodeX, nodeY, dist -- for id,node in pairs( AREA_PATHS[areaID] ) do for id,node in pairs( AREA_PATHS_ALL[areaID].veh ) do nodeX, nodeY = node.x, node.y dist = (x - nodeX)*(x - nodeX) + (y - nodeY)*(y - nodeY) if not minDist or dist < minDist then minDist = dist minNode = node end end return minNode end It is a pretty icky mathematical solution to your problem because this function does not return a point on the path lines but just the points that are stored in the database as start and end points of lines, but it is better than having nothing! Use this function by passing the vehicle position inside of the water to it and it will return a node object with fields x, y, and z. You will have to find a ground position based on the point above ground (for ex. the node x, y and z). I suggest you use the getGroundPosition function. A popular candidate for calculating the ground-offset of vehicles is the getElementDistanceFromCentreOfMassToBaseOfModel function. Just add this distance to the ground z coordinate and you should obtain a good vehicle placement position based on the 0, 0, 0 euler rotation. You will have to slice parts of the resource away and put them into your own because there are no exported functions for the traffic resource. Have fun!
    1 point
  6. Hi there! Time sure flies fast, doesn't it? It has been a while since the last post from us so we would like to give you an update on what has been going on recently with MTA:SA. We have got two highlights for you this time. The community Do you remember our Community website? It has served us well over the years but has also caught some rust in the process. Therefore, we would like to re-visit it and improve your experience with discovering and publishing resources. Our plan is to build a new community website from the ground up using modern technologies, and we would like to hear from you what you would like to see on the new platform. Please respond to this thread with your ideas and suggestions. Technically inclined users can take a look at the first pass of our specification document. Development progress As for the mod itself, we have received many pull requests (patch contributions) on our GitHub from open source contributors lately. One of such contributions is a brand new feature: custom IFP animations support, coming from one of our community members, Saml1er. He managed to get this to work nicely in MTA:SA, while ensuring that our coding standards are met so we could include it without too much hassle. Saml1er even made a video which showcases what this feature is all about. You can find it below: We intend this to be a part of our upcoming 1.5.6 release which we hope will come soon, but you can try it out now by using a nightly build: https://nightly.multitheftauto.com/ Tips for using this can be found on our wiki: https://wiki.multitheftauto.com/wiki/EngineLoadIFP That's all for now. Take care and enjoy the summer! — MTA Team
    1 point
  7. Haven't tested, but perhaps this would give you something: local resource = getResourceFromName(getElementID(resourceRoot)) where resourceRoot is the predefined global variable, which is equal to getResourceRootElement() - but of course, you'd not be using this resource root element as otherwise you'd just use getThisResource().
    1 point
×
×
  • Create New...