-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
You need to index one more time with .languages, before you index with the actually language you want. 1. So: switchData.languages[language] 2. Same goes for the other lines that make use of that table. switchData.langauges[defaultLanguage] select(2, next(switchData.languages))
-
It is the moment of switching languages. It should at least be executed after creating the button. Now it is executed before that. Try to run this line with a command handler or with onClientResourceStart. (that is if you know if the value is set before that)
-
{Spanish = "policía", English = "Police"} You could swap es with Spanish, does that help? guiSetLanguageSwitch (getElementData(localPlayer, "Language")) -- call the function local defaultLanguage = "Spanish"
-
You could try this, not tested. But it is a start. local languageSwitch = {} local defaultLanguage = "nl" function guiSetLangaugeSupport (element, languages) languageSwitch[#languageSwitch + 1] = {element = element, languages = languages} guiSetText(element, languages[defaultLanguage] or guiGetText(element)) return element end function guiSetLanguageSwitch (language) for i=1, #languageSwitch do local switchData = languageSwitch[i] guiSetText(switchData.element, switchData[language] or switchData[defaultLanguage] or select(2, next(switchData)) or guiGetText(switchData.element)) end end switchData[language] or -- The option you want switchData[defaultLanguage] or -- default language select(2, next(switchData)) or -- First possible item guiGetText(switchData.element) -- previous text ;O local button = guiSetLangaugeSupport(guiCreateButton(0, 0, 0, 0, "", false, panel), {en = "Police", nl = "Politie"})
-
You can create a ` web page` in MTA, which helps you access resource data and that access can be scoped by the rights of the resource. This eliminates the 'log in' requirement. https://wiki.multitheftauto.com/wiki/Resource_Web_Access https://wiki.multitheftauto.com/wiki/HttpWrite * In there you can find the querystring variable. <* querystring *> Might be worth looking in to.
-
btw. How are you going to login without password? ? For each request you need to provide the username and password. Fields: "user", "password" (mta account) Also make sure that the function can be accessed (in the meta.xml), you probably already did that.
-
I don't think component rotations are based on player input. They are probably based on values that are set by setVehicleComponentRotation. setVehicleComponentRotation > changes the value of: getVehicleComponentRotation If the value is set by setVehicleComponentRotation that changes the rotation, then yes it might be a scripting issue. But also in that case, the wheel will be locked in that position and there is no need to set the same value. If not, then this will maybe help you to get the correct value: https://wiki.multitheftauto.com/wiki/GetPedAnalogControlState If the value is correct: setVehicleComponentRotation( defaultRot + maxRotationOffset * constrolState) --[[ When entering the vehicle ]] -- reset this to default -- and set the analalogControlState again. These are my recommendations, keep in mind that there is no guaranty that those will work, since I haven't build this myself yet.
-
Use a different command. /start is reserved for starting resources.
-
Function names are variables. local variables are only available within their block. local variables are faster in speed. (performance) Blocks: Local functions can't be called from another file. Local functions can't be called outside of: (other) Function if statement Loop etc. -- file 1 local function test () end -- -- file 2 iprint(test) -- nil -- if true then local function test () end end iprint(test) -- nil function something () local function test () end end iprint(test) -- nil Depending on how the function variable is defined: local function test () iprint(test) -- function... end local test = function () iprint(test) -- nil (The function is created, before the variable is available.) end iprint(test) -- Function... local test test = function () iprint(test) -- function... end
-
isPeadDead Typo
-
-- Vector3 only: function tableToVector (theTable) return Vector3(theTable.x, theTable.y, theTable.z) end function vectorToTable(theVector) return {x = theVector.x, y = theVector.y, z = theVector.z} end theVehicle:setData("lastPos", vectorToTable(theVehicle:getPosition())) ------ local vec = veh:getData("lastPos") if vec then vec = tableToVector(vec) end Elementdata will always make a (deep)copy of the data, but vectors can't be (deep)copied. You also can't send vectors with triggerServer/ClientEvent, because there is (deep)copy also applied. Turning vectors in to tables, will solve the issue. But it might be even better to remove the elementData when the resource stops.
-
This happens at the moment/distance that the lowLOD will swap with the default object. I set the opacity of the lowLOD to 0 and it was visible for a single frame during the swap, so I guess some of it's properties are re-applied at that moment. But it can also be something entirely different, except for the `moment` it occurs.
-
The base64 format can be used to neutralize characters that would break the code otherwise. Therefore it can be used inside of other languages, with as result the possibility of having `images` inside HTML or CSS. Just upload an image on that website and you will see.
-
We do not support leaked resources.
-
You can read xml from a string. So you got your xml tree scoped by your own script. https://wiki.multitheftauto.com/wiki/XmlLoadString But keep in mind that there is no MTA function yet to convert it back to a string. (unless you make one yourself)
-
Without library, you have to use triggerClientEvent to send a message back. You can't use the return keyword to send data back. "onClientGUIClick" > triggerServerEvent > isObjectInACLGroup... > triggerClientEvent > guiSetVisible...
- 1 reply
-
- 1
-
I haven't done/tested this before, but you can change the vehicle engine type. Not sure if that affects the audio as well. setVehicleHandling ( theVehicle, "engineType", "electric")
-
Maybe you could get the model from the database instead, since you already fetched the vehicle data. But that only works correctly if the database is up to date. It could become de-synced if: the vehicle model can be changed for the same ID AND the database does not receive an update after every elementdata change.
-
Just some format examples, the right format depends on how you work with them: itemProperties = { ["water"] = { ["friendlyName"] = "Water" }, ["sandwitch"] = { ["friendlyName"] = "Sandwitch" } } items = { ["water"] = {-- Item 1 ["amount"] = 2 }, ["sandwitch"] = {-- Item 2 ["amount"] = 1 }, } -- or items = { {-- Item 1 ["amount"] = 2, ["id"] = "water" }, {-- Item 2 ["amount"] = 1, ["id"] = "sandwitch" }, } combine_list = { { ["ingredients"] = { ["water"] = 2, -- 2x water ["sandwitch"] = 1, -- 1x sandwitch }, ["newItem"] = "water sandwitch" }--[[, { -- next combination ["ingredients"] = { ["water"] = 2, -- 2x water ["sandwitch"] = 1, -- 1x sandwitch }, ["newItem"] = "water sandwitch" }]] }
-
The checkPassiveTimer from the wiki page: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer do local passiveTimerGroups = {} local cleanUpInterval = 240000 local nextCleanUpCycle = getTickCount() + cleanUpInterval local onElementDestroyEventName = triggerServerEvent and "onClientElementDestroy" or "onElementDestroy" local function isEventHandlerAdded( eventName, elementAttachedTo, func ) -- https://wiki.multitheftauto.com/wiki/GetEventHandlers local attachedFunctions = getEventHandlers( eventName, elementAttachedTo ) if #attachedFunctions > 0 then for i=1, #attachedFunctions do if attachedFunctions[i] == func then return true end end end return false end --[[ Remove passive timers of elements that are destroyed ]] local function removeDeletedElementTimer () for timerName, passiveTimers in pairs(passiveTimerGroups) do if passiveTimers[this] then passiveTimers[this] = nil if not next(passiveTimers) then passiveTimerGroups[timerName] = nil end end end removeEventHandler(onElementDestroyEventName, this, removeDeletedElementTimer) end --[[ Make a clean up cycle to prevent a memory leak ]] local function checkCleanUpCycle (timeNow) if timeNow > nextCleanUpCycle then nextCleanUpCycle = timeNow + cleanUpInterval local maxExecutionTime = timeNow + 3 for timerName, passiveTimers in pairs(passiveTimerGroups) do for key, executionTime in pairs(passiveTimers) do if timeNow > executionTime then if isElement(key) and isEventHandlerAdded(onElementDestroyEventName, key, removeDeletedElementTimer) then removeEventHandler(onElementDestroyEventName, key, removeDeletedElementTimer) end passiveTimers[key] = nil end end if not next(passiveTimers) then passiveTimerGroups[timerName] = nil end --[[ Just making sure that during the clean-up cycle no lag spike occur. ]] if getTickCount() >= maxExecutionTime then break end end end end function checkPassiveTimer (timerName, key, timeInterval) if type(timerName) ~= "string" then error("bad argument @ 'checkPassiveTimer' [Expected string at argument 1, got " .. type(timerName) .. "]", 2) elseif key == nil then error("bad argument @ 'checkPassiveTimer' [Expected anything except for nil at argument 2, got nil]", 2) end local intervalType = type(timeInterval) if intervalType == "string" then timeInterval = tonumber(timeInterval) if not timeInterval then error("bad argument @ 'checkPassiveTimer' [Expected a convertible string at argument 3]", 2) end elseif intervalType ~= "number" then error("bad argument @ 'checkPassiveTimer' [Expected number at argument 3, got " .. type(timeInterval) .. "]", 2) end --[[ Set-up the timer ]] local passiveTimers = passiveTimerGroups[timerName] if not passiveTimers then passiveTimers = {} passiveTimerGroups[timerName] = passiveTimers end local timeNow = getTickCount() local executionTime = passiveTimers[key] if executionTime then if timeNow > executionTime then passiveTimers[key] = timeNow + timeInterval checkCleanUpCycle(timeNow) return true, 0 end checkCleanUpCycle(timeNow) return false, executionTime - timeNow end if isElement(key) and not isEventHandlerAdded(onElementDestroyEventName, key, removeDeletedElementTimer) then addEventHandler(onElementDestroyEventName, key, removeDeletedElementTimer, false, "high") end passiveTimers[key] = timeNow + timeInterval checkCleanUpCycle(timeNow) return true, 0 end end
-
The variable checkPassiveTimer? You have to add the function first before you can use it.
-
I recommend to check/remove the following: setTimer ( function(localPlayer) Overwriting the localPlayer with a nil value should cause problems. You could use the following useful function for blocking: elseif itemData["id"] == 34 then if checkPassiveTimer ( "limit-item-id-34", true, 10000 ) then -- this code can only run every 10 seconds end Get the function from here: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer
-
The syntax is incorrect, this code shouldn't be able to run. Missing: = Set the model serverside, else other players will not be able to see it.
-
I assume you filled in the last part? (where my comment is) Please show me what you cooked from it.
-
We can only see that you create infinity timers, which is even a much bigger problem since Lua can't put that to an hold.