-
Posts
6,089 -
Joined
-
Last visited
-
Days Won
216
Everything posted by IIYAMA
-
If you didn't come here for scripting, then please use the things that are already available to you. https://wiki.multitheftauto.com/wiki/Server_Commands#whois /whois <nick/playername> /whowas <nick/playername>
-
Nope, your current problems: - Exported content is always a copy. So if you were to pass a table from one resource to another, then the content might be the same, but it is not the same table. To get a better understanding of this: 1. Create two resources.(if you haven't done that already) 2. Create in one resource a table. 3. Debug the table like this: theTable = {} print(tostring(theTable)) 4. Export the table to the 2e resource. 5. Repeat step [3] in the 2e resource. It will tell you that both tables do have a different userdata. That means they are not the same. ________________ - You can't pass functions to another resource. (Except as a string as I did in my example) And if you did it as a string, it would be a copy of it. The reason why you can't do this is because a function has a function block which only exist at the place where it is created. Which comes to this conclusion: The environment of both resources can't be merged. Which would be merged if: - Tables can be shared between resources. - Functions can be accessed without exporting. @Dzsozi (h03)
-
In the real world it cost time to steer from 0° to 45° degrees right? If they didn't apply the same principle in gta san, where ever you were to turn right/left your car would simply rollover. (Just like a dog would do, when he has to earn his candy) So they decided to do this if you were to press your left arrow. This wheel animation is time as well as fps related.
-
If you look carefully in the video to the first few cars that driving past, you can clearly see that the wheels are steering with 100% to the left and the right. Which makes it look very unnatural. With the set analog function, you can also steer 30% to the right or the left. But remember: controlstates are an indirect method to control an ped or car. They do not adjust the orientation of elementen, they are actions to behave like it. The outcome can be entirely different depending on a lot of factors. One last thing: from 0 t/m 100 steering cost time.
-
The frame rate is indeed a factor. Also the code runs on different place in the memory. The timing can be variable. You can smooth or force the key pressing a bit with: https://wiki.multitheftauto.com/wiki/SetPedAnalogControlState You can also use that to calculate the amount of steering from point to point. (that is if you want to go a level higher)
-
@JeViCo
-
Nope, it doesn't work like that. You can't change arguments of events after they are fired. But you can do something like this. function choosed(processed, colors) if not processed then if choosed then triggerEvent("onDGSPickerChoose", root, true, colors) end end end addEventHandler("onDGSPickerChoose", root, choosed, false) -- addEventHandler("onResourceStart", resourceRoot, function () setElementData(root, "onDGSPickerChoose_blocking", true, false) end) addEventHandler("onResourceStop", resourceRoot, function () removeElementData(root, "onDGSPickerChoose_blocking") end) addEventHandler("onDGSPickerChoose", root, function(processed, rgba) if not getElementData(root, "onDGSPickerChoose_blocking") or processed then end end, false) triggerEvent("onDGSPickerChoose", root, false, {255, 100, 100, 255})
-
https://wiki.multitheftauto.com/wiki/Client_Commands#showcol /showcol To have access to this command: https://wiki.multitheftauto.com/wiki/SetDevelopmentMode
-
Sure, if you know how to do port forwarding: https://sourceforge.net/projects/npp-plugins/files/NppDocShare/ However, git is basically better if you have multiple stakeholders and a shared production-line/project.
-
https://wiki.multitheftauto.com/wiki/AddEvent It is an option to prevent events, to trigger the handlers from either the client or server. If you put the option on a clientside script to false, it will ignore events triggered from serverside scripts. If you put the option on a serverside script to false, it will ignore events triggered from clientside scripts. It doesn't prevent triggering from other files(unless it is from the other [server/client]side) and it also doesn't prevent triggering from other resources. ?
-
Start first with making your API: https://wiki.multitheftauto.com/wiki/Resource_Web_Access or/and https://wiki.multitheftauto.com/wiki/Javascript_SDK
-
------------------ ------ function function functionName () end -- < end ------------------ ------ if statement if true then end -- < end ------------------ ------ if statement with elseif and else if true then elseif true then else end -- < end ------------------ ------ do-end block do end -- < end ------------------ ------ loops for i=1, 10 do end -- < end -- for i, v in ipairs({1, 2, 3}) do end -- < end -- while true do end -- < end ------ Cheat sheet. More info: Starting here: https://www.lua.org/pil/4.3.html https://www.lua.org/pil/4.3.2.html https://www.lua.org/pil/4.3.1.html https://www.lua.org/pil/4.3.4.html https://www.lua.org/pil/4.3.5.html https://www.lua.org/pil/5.html
-
The most basic lua syntax for that would be: (without tables) local posX1, posY1, posZ1, rotX1, rotY1, rotZ1 = 2445, 788789, 768879, 0, 90, 0 local posX2, posY2, posZ2, rotX2, rotY2, rotZ2 = 2445, 788789, 768879, 0, 0, 0 moveObject ( barrafc, 1000, posX1, posY1, posZ1, rotX1, rotY1, rotZ1 ) -- A to B moveObject ( barrafc, 1000, posX2, posY2, posZ2, rotX2, rotY2, rotZ2 ) -- B to A
-
Define the static start and end orientation and transform to there. Just like a train on a railroad, it can only move between the stations but not further or sidewards.
-
Hmm good question. I think they didn't add this feature in case of passwords and other security/privacy sensitive commands.
-
addCommandHandler("test", function (player, command, ...) iprint("The responsible player/console:", player) iprint("The command:", command) iprint("The arguments:", ...) local arguments = {...} iprint("The first and second argument:", arguments[1], ",", arguments[2]) end) Serverside @arciCZ This is the sky.
-
Adjust the handler timing: https://wiki.multitheftauto.com/wiki/AddEventHandler OR (if not working) Pick a different processing moment: https://wiki.multitheftauto.com/wiki/Game_Processing_Order https://wiki.multitheftauto.com/wiki/OnClientPreRender https://wiki.multitheftauto.com/wiki/OnClientHUDRender https://wiki.multitheftauto.com/wiki/OnClientRender
-
The /\ availableMissions /\ variable is from your previous code make sure you check and clean that for yourself too. call ( getResourceFromName (resourceName), resourceConnections[resourceName].communicator, "getCommunicationFunctions", 'function reConnect() call( getResourceFromName ("missionManager"), "reConnect") end') If the problem from above doesn't solve the this problem: Make sure to debug everything: iprint(getResourceFromName ("missionManager")) Can it find the resource? <script src="connect.lua" type="server"/> Is the export line applied to the target resource? This will not work because of the problem from above. @Dzsozi (h03)
-
Small fix, line 7: (forgot to pass the text through the reConnected function (in the string). call ( getResourceFromName (resourceName), availableMissions[resourceName].communicator, "getCommunicationFunctions", 'function reConnect(...) call( getResourceFromName ("missionManager"), "reConnect", ...) end') "" = string (woman) '' = string (man) Nah, they are the same. There are two types in case you want to use string characters inside of the string. So: "''" -- the string contains these characters: '' '""' -- the string contains these characters: "" In the code I posted, I didn't past a function through it. BUT I past un-executed code (as text) from RESOURCE A to RESOURCE B. This is what loadstring does: a = 1 local functionForLoadedCode = loadstring("a = a + 1") -- load the string before execute it. And return a function which will run the code. functionForLoadedCode() -- The code has been executed! print(a) -- 2 functionForLoadedCode() -- The code has been executed! print(a) -- 3 for i=1, 1000 do functionForLoadedCode() -- The code has been executed! X 1000! Woohoo! end print(a) -- 1003 https://www.lua.org/pil/8.html Don't know, might be caused by the timing.(as resources can't be called before they are loaded) Better use the "onResourceStart" event before the calling. And don't forget to make the function call able within the meta.xml. @Dzsozi (h03)
-
Your current problem is that you can't manipulate the same table in two different resources, right? ------------------------------- | ------------------------------- | Environment 1 | Environment 2 | ------------------------------- | ------------------------------- This is indeed a very annoying problem. But lets get back to the possibilities we have. <export /> This exports functions from this resource, so other resources can use them with call function: The function name type Whether function is exported server-side or client-side (valid values are: "client", "server" and "shared") http: Can the function be called via HTTP (true/false) https://wiki.multitheftauto.com/wiki/Meta.xml UNTESTED Example below is untested, but it will probably do something similar to what you want. Write a good wiring example. availableMissions = {} function startMission(resourceName, ...) if resourceName and availableMissions[resourceName] then if availableMissions[resourceName].communicator then call ( getResourceFromName (resourceName), availableMissions[resourceName].communicator, ...) end end end function addMission (missionData) local resourceName = getResourceName(sourceResource) -- https://forum.multitheftauto.com/topic/33407-list-of-predefined-variables/ -- https://wiki.multitheftauto.com/wiki/Call availableMissions[resourceName] = missionData --availableMissions[missionData.resourceName] = missionData end local mission = {} function communicator (functionName, ...) mission[functionName](...) end mission.startFunction = function(text) outputChatBox(text) end call ( getResourceFromName ("missionManager"), "addMission", {communicator = "communicator", resourceName = "example"} ) call ( getResourceFromName ("missionManager"), "startMission", "startFunction", "Hi!" ) UNTESTED You can also build an example which can be dynamic upgrade-able. local resourceConnections = {} function connect (resourceData) local resourceName = getResourceName(sourceResource) resourceConnections[resourceName] = resourceData if resourceData.communicationFunctions then call ( getResourceFromName (resourceName), availableMissions[resourceName].communicator, "getCommunicationFunctions", 'function reConnect() call( getResourceFromName ("missionManager"), "reConnect") end') end return true end function reConnect (text) outputChatBox(text) -- ... end local resourceFunctions = {} function communicator (functionName, ...) resourceFunctions[functionName](...) end function resourceFunctions.getCommunicationFunctions (communicationFunctions) loadstring(communicationFunctions)() end local connected = call( getResourceFromName ("missionManager"), "connect", {communicator = "communicator", communicationFunctions = true}) iprint(connected) reConnect("hmm does this work???") Damn it is brain fu... while writing this example without any testing.
-
In case of a local-server. JavaScript + browser might do the trick as well: https://wiki.multitheftauto.com/wiki/ExecuteBrowserJavascript https://stackoverflow.com/questions/189430/detect-the-internet-connection-is-offline if (navigator.onLine == true) { console.log("This might work"); } (no guarantees for this browser) https://wiki.multitheftauto.com/wiki/Resource_Web_Access !important
-
local playerTable = {} local player = playerTable[math.random(#playerTable)] https://stackoverflow.com/questions/2988246/choose-a-random-item-from-a-table As extend of N3xT his comment.
-
Just to be clear: Offset position = a world position (which is calculated by an offset value) Offset = a distance value (not a position) To calculate offset from two positions: Position:1 [435, 6577, 3457] position:2 [325, 7657, 5686] (Position:1 [435, 6577, 3457]) - (position:2 [325, 7657, 5686]) = offset:1 (position:2 [325, 7657, 5686]) - (Position:1 [435, 6577, 3457]) = offset:2 The main issue is of course if getElementPosition doesn't work on attached elements.(which I would consider as a MTA bug, but afaik they fixed this...) < If this function doesn't work correctly and the rotation in attachElements is used, it will be indeed a bit complex and getPositionFromElementOffset will not be helpful.
-
With the matrix of course: (the offset can be received with the function in @MrTasty his replied) function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end https://wiki.multitheftauto.com/wiki/GetElementMatrix or https://wiki.multitheftauto.com/wiki/Matrix
