-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
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. ?
-
Have you already checked other dx libraries? It would be a waste of time to figure out everything from scratch don't you think? For example:
-
[URGENT] Progress (0-1) calculation between two given hours
IIYAMA replied to Dzsozi (h03)'s topic in Scripting
Use getTickCount (milliseconds) if you do it based on machine time. Use getRealTime().timestamp (seconds) if you want realtime. When doing the calculations, start with the highest dimension. hours = math.floor(seconds / (60 * 60)) seconds = seconds - (hours * 60 * 60) progress = seconds / (60 * 60) You can also use %, to cut off large dimensions. Starting with the dimension you do not needs. Need hours + rest? = cut off days But that doesn't work for days/years, since there are not always 365 days in a year. Progress goes from 0 to 0,9999999999. -
I do not know that script, but I can explain Lua OOP a little bit. At the very basic OOP is about creating objects and consider them as things and not just a data type, in Lua that is in this case a table. And as you know, you can add a lot of things in tables. It is a container used to keep things together. In the concept OOP, functions are part of this container as well. To keep things together, all functions that are saved inside can be used as being part of the table(container) it SELF. Which is where the keyword self comes from. Some people refere to `functions` that are inside of tables/objects as `methods`. Because those functions are used to modify or use data from the table, it becomes an action that the table can do. self is a key word, that reference to the table, where a method/function is saved in. If the function is not called from the table(container), self will become unavailable. The concept here is to keep the self/table as close as possible to the action the function must perform. t = {} function t:printSelf() print(self) end t:printSelf() ----- t = {123} function t:getValue () print(self[1]) end t:getValue()
-
It is possible, but what is the real problem? - The synchronisation concept for the data? Or - How to use OOP?
-
Unfortunately that might not be the case. For example if you have 2 of those red boxes in each other and rotate 1 of them. There is another method that might be helpful if only 0, 90, 180 270 are used. Step 1, normalize the width, height and depth. So that rotation doesn't play any role anymore. https://wiki.multitheftauto.com/wiki/GetElementBoundingBox getPositionFromElementOffset < https://wiki.multitheftauto.com/wiki/GetElementMatrix Not required: Change your ^imationary^ camera from top to bottom. Get the center position X from both. Compare the distance: distanceX = [positionX_box1, positionX_box2] if distanceX < (sizeX_box1 / 2) + (sizeX_box2 / 2) then Do the same for the Y and Z axis. When all are true, there is a collision.
- 8 replies
-
- 2
-
-
- object
- intersection
-
(and 3 more)
Tagged with:
-
But keep in mind that the solution is not bullet proof. If the red box was 45 degrees rotated clockwise and moved a little bit higher, the collision detection would fail.
- 8 replies
-
- 1
-
-
- object
- intersection
-
(and 3 more)
Tagged with:
-
You could also use this function. https://wiki.multitheftauto.com/wiki/IsInsideColShape https://wiki.multitheftauto.com/wiki/GetElementBoundingBox If you run it 8x times for each corner, per object = 16x. Then it will detect most of the collisions, except when no corners are inside each other. There is also something by crystamv. https://web.archive.org/web/20160507103732/http://crystalmv.net84.net/pages/scripts/server_coldata.php But that one only supports peds and vehicles. But you could modify it to also support objects
- 8 replies
-
- 1
-
-
- object
- intersection
-
(and 3 more)
Tagged with:
-
You can multiply the colshape size by 1.5. But keep in mind that rotation values that are higher than: (rotation % 90) > 0 Will make the calculations invalid.
- 8 replies
-
- object
- intersection
-
(and 3 more)
Tagged with:
-
Moved to correct language section. (Not sure if this is the correct sub-section...???)
-
@koragg Unfortunately I will be away for a long while, so I can't test it out. Please ignore the following if this is not helpful. The code below was one of my experiments to create an animator. While it maybe working very well, it also was not worthed to add something as big inside of my resources, because of the size and feature count. But what it does is setting up parameters/arguments and adding animations to them. opacityStart = 0 opacityStart = 255 opacityStart = 0 So you might consider use it as inspiration to creating your own animator, smaller/bigger. (or copy this...) Uses https://forum.multitheftauto.com/topic/103866-enchantment-client-render-events-enchanting/
-
Moved to resources, since it was a scripting request.
