Jump to content

dantashost

Members
  • Posts

    13
  • Joined

  • Last visited

Details

  • Gang
    dhs
  • Location
    Brazil, MS

dantashost's Achievements

Square

Square (6/54)

0

Reputation

  1. Thanks, but wait... is it possible to have colshapes in *.map files and have them be created as such upon loading (not unrecognized elements, that is)? I stored them in a xml file as you said and loaded setting the element's data.
  2. The problem isn't creating the colshape, actually everything is set correctly (expected parameter DOES match xmlNode value implicitly), I set the ID for a certain colshape to retrieve the colshape element later on (this works correctly), but I can't get a colshape's radius... getElementRadius(myColShape) neither getElementData(myColShape, "radius") work, to retrieve it I had to setElementData(myColShape, "radius") but this sounds very redundant as the element has an internal radius value already, it's like duplicating it or I'm confusing how I get a created element's data from .map loaded element's data... Now I got the bases protected from projectiles doing the following: To be able to check any projectile against a base, I had to create a queue and put every created projectile on this queue using onClientProjectileCreation (I didn't put the projectile element itself because I had problems taking it out of the array, so I stored IDs gotten from getElementID instead); onClientRender I checked if my queue (array) was empty, if it was not I looped through every projectile getElementByID(projectileID)'d for each one, and for each projectile I looped through every base (likely to increase in the future) checking if the projectile hit a certain base (sphere colshape vs. projectile), if so I set the projectile position up (z+20) then destroyElement'd it (this caused the bomb to explode! people liked to see it exploding in the air ), successfully protecting the base. This could be achieved better if onColShapeHit detected the projectile, I hope it does in the future. Big Code chunk ahead:
  3. Ok, now I'm getting a bid mad, I can't for god's sake retrieve a colSphere radius (getElementRadius doesn't allow that), can someone help me? if node then local posX = xmlNodeGetAttribute(node, "posX") local posY = xmlNodeGetAttribute(node, "posY") local posZ = xmlNodeGetAttribute(node, "posZ") local radius = xmlNodeGetAttribute(node, "radius") local colMarker = createColSphere(posX, posY, posZ, radius) if colMarker then -- If collision shape was created succesfully, attach other data to it outputChatBox("marker created with "..tostring(getElementData(colMarker, "radius")).."radius!") setElementID(colMarker, xmlNodeGetAttribute(node, "id")) setElementData(colMarker, "baseId", xmlNodeGetAttribute(node, "baseId")) end end
  4. That is nice and better than checking the explosion, thanks, but... what do you mean by delay? Is that a timer delay? If so I could add a timer when a weapon fires (I believe there's an event for that) and kill it afterwards (though I'm not sure if it's better to create 'n kill timers everytime, or have a fixed delay to check for projectiles on every frame rendering). @Edit Wait, I think we didn't communicate good enough. I don't know the projectile, how do I know what projectile I'm checking against the colshapes? I need a source-independent event, this is, any projectile fired against that specific colshape must be destroyed but I can't predict what it is/where it comes from.
  5. Basically, I've created invisible "markers" using circular colshapes to detect intruders/hostiles and prevent them from entering a certain person's "base". So far, so good, onColShapeHit detected those, but it does not work for projectiles, one for instance could throw a grenade at the base bombarding everything within its radius and consequently damaging possible personal stuff stored inside, like vehicles. The question is how can I detect and redirect (set his Z coordinate like 15units above) a FIRED projectile so it doesn't damage the base's content? Thanks in advance! PS.: Projectile is classified as an element, is this a bug? @Edit (This will sound similar to my first thread lol) While I'm still interested in how projectiles are handled, I found the https://wiki.multitheftauto.com/wiki/OnClientExplosion client event, the downside is that it's not handled server-side, but I could check if the distance between my colshape and the explosion is within the colshape radius (oh glorious geometric math) and cancelEvent, successfully preventing damage (not sure about animations though).
  6. Clever! I'll fix that right away! (also, opening a new thread so this one isn't cluttered with ongoing questions )
  7. @50p, hmmm not sure it would help as I'm creating the colshape markers server-side, but I believe I'm safe to go (I stored them in a xml file since using databases would be overkill later on). Thanks for all your help, hopefully my questions will help someone else in the future! @Edit Just to leave a more helpful thing here, so others can benefit from the script: function loadInitialBaseData() if source ~= getResourceRootElement() then return end -- This event will happen with any resource start, isolate it to this resource -- Opens db connection db = dbConnect("sqlite", "bases.db") -- Creates colshapes on the world xmlRootTree = xmlLoadFile("base_markers.xml") -- Attempt to load the xml file if xmlRootTree then -- If the xml loaded then... xmlColshapes = xmlFindChild(xmlRootTree,"colshapes",0) -- Find the hud sub-node if xmlColshapes then -- Retrieve all sub-node names or values xmlColshapesTable = xmlNodeGetChildren(xmlColshapes) -- Create a table of this branch's children for i,node in pairs(xmlColshapesTable) do -- Loop through the branch's children for sub-nodes -- If node is valid, use its attributes to create the colshape if node then local posX = xmlNodeGetAttribute(node, "posX") local posY = xmlNodeGetAttribute(node, "posY") local radius = xmlNodeGetAttribute(node, "radius") local colMarker = createColCircle(posX, posY, radius) if colMarker then -- If collision shape was created succesfully, attach other data to it setElementData(colMarker, "id", xmlNodeGetAttribute(node, "id")) setElementData(colMarker, "baseId", xmlNodeGetAttribute(node, "baseId")) end end end end xmlUnloadFile(xmlRootTree) end end addEventHandler("onResourceStart", resourceRoot,loadInitialBaseData)
  8. @50p, that settles the question thanks but now I'm afraid no objects within map files should be trusted, I was hoping that at least colshapes would work out but this definition fails too: <colcircle id="colcircle (pbase_marker_5)" collision="1" posX="2077.3999" posY="2406.1001" posZ="7.3" radius="105" baseId="object (drydock1_SFSe) (79)"/> I'm just giving up on map files since they're not reliable for real collisions, I hope that scripted colshapes create the collision for colshapes at least. Again, thank you and sorry for asking too much!
  9. BUMP! Squishy! Map files don't work at all, nothing can be sized nor scaled, it does not work for anything at all! o_o
  10. @50p, thanks! Actually it turned out simpler than I thought, but now another issue appeared: I set the marker position and its SIZE, but when the *.map is loaded the size isn't take into account (this is, it becomes size 1, I want it to cover a larger area). Same thing for scaled doors or grids, they *appear* to be bigger, but the collision only respects the default size, not the scaled one, am I missing something? Sample: <marker id="marker (cylinder) (5)" type="cylinder" color="#0000ffff" size="105" interior="0" dimension="0" alpha="0" posX="2077.3999" posY="2406.1001" posZ="7.3" rotX="0" rotY="0" rotZ="0" baseId="object (drydock1_SFSe) (79)"></marker> Tiny area! @Edit I added an event handler for onMarkerHit server-side, but it triggers within what seems to be 1unit area radius, which is not intended (I want a 80units for the marker's radius). @Edit2 While I'm still interested in understanding the issue with marker collisions (I'm inclined to believe that having everything loaded together in a single map file is better heh), I found https://wiki.multitheftauto.com/wiki/OnColShapeHit event and it suits nicely for what I want, for instance I can store a colshape in my database and assign it to an area I want to detect people who come inside. But is it the best or at least a "good" way of doing it?
  11. @50p, I'll check your map editor script, I'm very grateful for you answers, thanks! Before I leave you alone, another question raised: during a server run, if I createObject(), is it possible to get its ID to manage it in different functions (within the same script scope)? getElementByID() doesn't work on objects created on the fly with createObject(), so I suppose that's not possible at the moment, right?
  12. Thank you. Yes, I saw that function and got to remove all the objects (actually it was done before this post, but it's nice to ensure this is the right way to get it done), once everything had been removed the player literally started falling as expected but then again, do I have to build things on the world after clearing everything? I'm failing to see the connection between Map Editors and an empty world, I take I have to create everything through script after clearing the world?? Questions 1 and (partially) 2 have been aswered, any other input?
  13. Hello MTA:SA community! This is my first post in these forums, so bear with me if you find any mispelling or confusing English text (not my native language). I have a fair knowledge in programming languages, and I'm developing a game mode right now from scratch (but of course I'm learning from other open free gamemodes out there), well I've come to the point I want to build a custom map for my game mode and got a few questions regarding MAPS: 1- Is it possible to create a map from scratch without Los Santos and all the default maps that come with GTA? (I mean a whole new "world", not far positioned maps) 2- If it's possible how do I do so? Any tools or scripts written in a legible way is very welcome; if not, how do you block default maps so that they don't mix up with the world you're trying to build? 3- GTA "map" is huge and divided into "sections", or is each "section" (say, city) called a map? A brief explanation about terminologies would be cool (yes, I'm very new to MTA game modding!) 4- I know there is a Map Editor that comes along with MTA, is that the best map editting tool for customized maps, or do you recommend another one? That's it for now, if you can help in any of these it'll be much appreciated!
×
×
  • Create New...