-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
No need to bring this not useful 'Lua is :~'(users are :~) topic up from 2 years ago. LOCKED
-
@erisP You might want to reply at least (, even if you are not going to do anything with it).
-
@erisP Use the (dynamic) element tree. -- server local colshapeParent = createElement("colshapeParent", "blockColshapeParent") local BlockVehicle = createColCuboid ( 1573.84900,-1637.5,12, 10,6,6 ) setElementParent(BlockVehicle, colshapeParent) local BlockVehicle2 = createColCuboid ( 1573.84900,-1637.5,12, 20,6,6 ) setElementParent(BlockVehicle2, colshapeParent) -- client --[[ -- clientside colshapes do local colshapeParent = getElementByID("blockColshapeParent") if colshapeParent then local BlockVehicle2 = createColCuboid ( 1573.84900,-1637.5,12, 20,6,6 ) setElementParent(BlockVehicle2, colshapeParent) end end ]] function isInColExport () local colshapeParent = getElementByID("blockColshapeParent") if colshapeParent then local colshapes = getElementChildren(colshapeParent) for i=1, #colshapes do local colshape = colshapes[i] if isElementWithinColShape(localPlayer, colshape) then return true end end end return false end Untested. Colshapes must be created in the same resource as the parent, clientside/serverside doesn't matter.
-
You could try also something like this: https://community.multitheftauto.com/index.php?p=resources&s=details&id=13991 It is probably not what you are looking for, but it might be interesting to look at.
-
Afaik you can only disable them, which means that you can re-enable them when you are even higher.
-
Do you mean that it is inaccurate in some way? Or do you mean that you want to add spread, but that doesn't work out great? @redditing + You have to keep in mind that bullets created by a default weapon do have a different start point. They are NOT created from the weapon muzzle, but from target start. That means that if you set the target of the custom weapon to the target end position, the lines between the two weapons will cross at this point, instead of stay next to each other to the infinity-end position. So maybe try this instead: https://wiki.multitheftauto.com/wiki/GetPedTargetCollision
-
Map files Table of contents: Introduction How to read a map file? Broken map file, what to do? Editor bugged, what to do? Modify your maps outside of MTA Extra links Introduction A map-file! What is that? The name already gives away the definition. It is a file which contains a MTA map. The format makes maps portable, so that you can send them over to your friends. You can recognize map-files by the extension: .map Here is an example of a map: Syntax highlight When you open a map file in your text editor. The syntax highlight you should use is XML (HTML will work as well, but the semantic is different and could cause issues with auto complete features, that is if you have enabled those). Changing syntax highlight in for example Visual Studio Code. How to read a map file? Before we start, this is what we call a node: <tagName></tagName> If we take a closer look to the following map file: <map> <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> <object id="object (CE_grndPALCST03) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="573.09802246094" posY="-3847.013671875" posZ="3.6442375183105" rotX="0" rotY="22" rotZ="352"></object> <object id="object (CE_grndPALCST03) (2)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="572.64624023438" posY="-3769.0698242188" posZ="4.9519920349121" rotX="0" rotY="21.99462890625" rotZ="343.24649047852"></object> <object id="object (CE_grndPALCST03) (3)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="669.66534423828" posY="-3856.0627441406" posZ="3.6442375183105" rotX="0" rotY="63.99462890625" rotZ="175.99389648438"></object> </map> > we see in there the map node: <map></map> When the map is loaded <map></map> will become our map element. And inside of the map node we see more nodes: <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> In this case these two nodes will become two in-game objects. Tagname <tagName></tagName> Each node in the map file will become an element in game. !important A node has a tag name. In this case I gave it the name: "tagName" This tag name specifies in MTA the element type. For example: If it has the name <object></object>, the element-type is an object. If it has the name <ped></ped>, the element-type is a ped. What if the tag name is not matching with one of these entities? (The list is not complete, the rest can be found in this class list, only if the XML syntax is implemented) Then the elements are considered custom elements. They are not visible in game. Custom elements Custom elements have their own purposes. You often see those custom elements used in game modes, for example stealth: <mercenaryspawn id="mercenaryspawn (1)" posX="635.58117675781" posY="-3770.458984375" posZ="18.97974395752" rotX="0" rotY="0" rotZ="0"></mercenaryspawn> The tagname for this node is "mercenaryspawn". The element that is produced after loading the map, is used as a spawnpoint for in a stealth map. Custom elements are invisible. Custom elements do have an orientation. The getElementsByType function can be used to get custom elements. Attributes Attributes are properties applied to a node. They are used to attach data to an element. Example: <entity name="IIYAMA" age="5" type="device" resolutionX="1920" resolutionY="1080" displaySize="31"></entity> An attribute exist out of two parts: <entity name="value"></entity> Name Value The name specifies if the node has the attribute. <entity name></entity> <entity age></entity> If the name is "name", then the node has the attribute "name". And if the name is "age", then the node has the attribute "age". The value will be used for the data for each attribute. <entity name="IIYAMA" age="5"></entity> Identifiers (ID) Every elements can have an identifier attribute, which is used to make it accessible for scripting functions. <tagName id="identifier"></tagName> The identifier of an element can be used in getElementByID to grant access to it. Even though identifiers normally should be unique for each individual, it is not the end of the world if they are not in MTA. They might also be considered as unnecessary for map files without scripts. Element specific attributes There are some attributes that do more than just applying properties. They will change the element appearance and orientation. For example this object: <object interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> It will be created in interior 0. It will have collisions. (You can walk on it) Alpha. It's opacity is 100%. It is not doublesided. (When you stand inside of the object you can look through it. If doublesided is enabled the same colors/paint from the other side will be applied.) It's model is 6094. It is scaled 100%. (0.5 = 50%, 2 = 200%) Etc. If you want to know which attributes do have influence on the elements appearance and orientation, you have to look that up on the wiki. Here a small list of some those attributes: Broken map file, what to do? If your map file is broken. Step 1 Make a backup. + Always make a backup when re-editing your map. Settings can get lost! Step 2 The first thing you want to do, is just open it in a text-editor. Just give it a quick look and check for anything strange. The file could be empty or some strange values could be used. Do you want to know all the syntax rules (XML)? You can find a list right here: http://www.adobepress.com/articles/article.asp?p=1179145 Step 3 Remove the editor definition. This definition could cause problems in case of invalid characters. From: <map edf:definitions="COBDEF,editor_main"> <!-- Map elements --> </map> To: <map> <!-- Map elements --> </map> Step 4 If you can't find the problem, then you could validate the file. There are services out there that validate XML files. They can help you to find out where your file is broken. Validation tool by W3C: https://validator.w3.org/#validate_by_input Note: You need to do step 3 first. Else you can't parse the file. Step 5 In case of re-opening map files in the editor, but doesn't want to get open. Make a backup. Remove custom elements. See chapter How to read? Retry to open the file. Editor is bugged, what to do? Your editor could be bugged and you are not able to save the map or open a new one. The first thing you want to do is backup the editor_dump folder in your server. This folder is located between all your resources. server\mods\deathmatch\resources\editor_dump Rename the folder name. editor_dump > my_broken_map Stop the map editor. Check if there is a new editor_dump folder. If there is, rename that one as well. Start the map editor again. Modify your maps outside of MTA Sometimes you want to modify your maps without going back in to the editor. Your text-editor is in most cases the way to go. For example you want to move all objects to a new dimension. In Notepad++: Make a backup! (if you are new to this) Select in your file the part you want to replace: dimension="0" Commando: ctrl + H (replacement overlay) Fill in the replace field: dimension="1" Click on: replace ALL. Moving your map? There is a nice online tool that can help you with that: https://mtaclub.eu/converters Edit your map with the DOM (Document Object Model) Knowing JavaScript? Your browser inspector can be used to modify your maps at a higher level. (If you so desire) Extra links: Parent, child and how this is reflected in MTA https://wiki.multitheftauto.com/wiki/XML https://wiki.multitheftauto.com/wiki/Element_tree Elementdata <sync_map_element_data /> https://wiki.multitheftauto.com/wiki/Meta.xml Load maps (manually + including in meta.xml) https://wiki.multitheftauto.com/wiki/Meta.xml https://wiki.multitheftauto.com/wiki/LoadMapData Save maps https://wiki.multitheftauto.com/wiki/SaveMapData
-
Did you already add a database identifier to all your items? Because without there is a change that will be desync. About making a photo. Serverside: You can take the screenshot with: https://wiki.multitheftauto.com/wiki/TakePlayerScreenShot and receive it on: https://wiki.multitheftauto.com/wiki/OnPlayerScreenShot Or clientside: You can capture the screen with: https://wiki.multitheftauto.com/wiki/DxCreateScreenSource Get the pixels of it: https://wiki.multitheftauto.com/wiki/DxGetTexturePixels Convert the pixels to a (compressed) format: https://wiki.multitheftauto.com/wiki/DxConvertPixels
-
yes I understand that if you do not save your data inside of a database, it will be gone after restarting the resource. I lost you here. You want to replace names? Which you already have saved in the database? And then return that result back to clientside and update the list there as well?
-
You will need to decide what the input must be. If it is scrolling, clicking (on a specific something), typing, commands, that doesn't matter as long as that input can be translated to the instructions you want to give to your code. I picked commands, because you only created an input (clicking) for removing items: function Remove() if assignShow == false then return false end for i = 1,5 do if isMouseInRectPosition(assignSlots[i][1], assignSlots[i][2], assignSlots[i][3], assignSlots[i][4]) then if assigns[i] then triggerServerEvent("remove", resourceRoot, assigns[i]["key"], assigns[i]["item"]) iprint(assigns[i]["key"], assigns[i]["item"]) --[[ ... ]] But not to replace them with another one, as you instructed here:
-
That is still an alien explanation. But let me give you 2 concepts addCommandHandler("changeItem", function (cmd, index, value) index = tonumber(index) if index and value then assignItems[index]["item"] = value outputChatBox("set!") end end, false) -- not caseSensitive addCommandHandler("changeItemIfValue", function (cmd, value, newValue) if value and newValue then --[[ Loop through all items, until you find the right one, then replace it's value. ]] for i=1, #assignItems do local item = assignItems[i] if item and item["item"] == value then item["item"] = newValue outputChatBox("set!") break end end end end, false) -- not caseSensitive
-
Clean up your code and add comments, then I do not mind take a look at it. Currently I am looking at alien code...
-
It must have been an unlucky tree, nature can be ruthless sometimes. ?
-
If it is a player, use Patrick his method. If it is an object/ped/vehicle created by a single resource, stick with the second method.
-
All serverside elements are already available on clientside. The only problem is: "how to get the right one?" There are multi ways to get those, including triggerClientEvent as @Patrick said. Server local receiver receiver = getRandomPlayer() -- a random player receiver = root -- all players triggerClientEvent(receiver, "eventName_SEND_THING_OVER", resourceRoot, element) Client addEvent("eventName_SEND_THING_OVER", true) -- enable the event: string eventName, boolean true = able to receive events from serverside addEventHandler("eventName_SEND_THING_OVER", resourceRoot, -- add a handler, that will call the function when the event is triggered function (element) end, false) -- disable propagation There is also a method which I like to use to keep a dynamic list of my elements: Server local collectionElement = createElement("collection", "myVehicles") for i=1, 10 do local vehicle = createVehicle(432, i * 10, 0, 50) setElementParent(vehicle, collectionElement) -- (Note: setElementParent, doesn't work across resources) end Client function getMyVehicles (theType) local collectionElement = getElementByID("myVehicles") if collectionElement then return getElementChildren(collectionElement, theType) -- theType is optional, could be "vehicle" end return false end
-
Hmm interesting, I knew that there were objects with strange behaviours but I didn't expect it to be with trees. There is of course the wind animation used by some trees, which might be related to the bug. In that case he can try to freeze the object. setElementFrozen(Trees, true) Or if that doesn't work, attach the tree to an element 1 that isn't a tree. https://wiki.multitheftauto.com/wiki/AttachElements
-
Those can be found on the community. Possible search terms (1 at the time): browser, web, CEF
-
You put it inside of html file. (or inject it with Javascript later on) You read this (for creating a browser): https://wiki.multitheftauto.com/wiki/CreateBrowser You read this (for local hosting): https://wiki.multitheftauto.com/wiki/Local_Scheme_Handler <file /> A client-side file. < < < all website files You read this (for intern server hosting): https://wiki.multitheftauto.com/wiki/Resource_Web_Access Feel free to ask questions about the information I gave you.
-
Yes possible, by feeding it the whole video in base64. https://base64.guru/converter/encode/video Not recommended for large video's. ?
-
[URGENT] Progress (0-1) calculation between two given hours
IIYAMA replied to Dzsozi (h03)'s topic in Scripting
Do you still need help? -
yes that one + https://wiki.multitheftauto.com/wiki/SetPedAimTarget + rotate the ped see also: https://web.archive.org/web/20130728213352/http://crystalmv.net84.net/pages/scripts/npc_hlc.php
-
That is where you need to create wrappers. It is function overwrite that is executed before the original function, making sure that you can register what has happened (and undo it later). addEventHandler_ = addEventHandler local addEventHandler = function (...) -- collect the information you need, to remove the addEventHandler for a specific file/mode. return addEventHandler_(...) end Check out other multi gamemodes for inspiration.
-
Afaik elements in other dimensions are not streamedin, also by enabling the streamedin capture feature, the performance will improve getElementsByType("player", root, true) You can add another function, that makes use of the existing function and does for example: draw an X amount of lines under each other. dxDrawMultiLineTextOnElement(roomDeathmatch, {"Deathmatch", 1, 20, 255, 255, 255, 255, 2, "sans"}, { "Deathmatch", 1, 20, 255, 255, 255, 255, 2, "sans"}) function dxDrawMultiLineTextOnElement (element, ...) local lines = {...} -- etc. end
-
I take my time to reply. ?