-
Posts
6,045 -
Joined
-
Last visited
-
Days Won
207
IIYAMA last won the day on October 31
IIYAMA had the most liked content!
About IIYAMA
- Birthday 01/01/2016
Member Title
- Global Moderator
Details
-
Gang
[HB]
-
Location
Netherlands
-
Occupation
I have never been to the streets of SA... so who knows?
-
Interests
Design, scripting, UX/UI
Recent Profile Visitors
39,403 profile views
IIYAMA's Achievements
Gangsta (45/54)
1.5k
Reputation
-
If this code is ran clientside, it will create a lot of lag (because of setElementData). If ran serverside, it will have impact but consistent. (If the problem is purely located here and not created somewhere else) For now I consider this code to be ran serverside, because that would be the most logic place for this code to be used. The following components can be considered an impact multiplier on clientside: https://wiki.multitheftauto.com/wiki/AddDebugHook https://wiki.multitheftauto.com/wiki/OnClientElementDataChange Does the pass have to be refreshed every 1 second? Can't it be refreshed every 10sec/1 min? A small improvement, make the value of NewPass an integer. Which helps with the transfer speed.
-
No worries take your time, just checking if you may have mist it. Serverside (as well as shared~serverside) are limited by the ACL, clientside is not. That is possible. You can double verify if the resource has access to loadstring using: https://wiki.multitheftauto.com/wiki/HasObjectPermissionTo addEventHandler("onResourceStart", resourceRoot, function (startedResource) if not hasObjectPermissionTo ( startedResource, "function.loadstring", true ) then local cancelReason = "Missing permission function.loadstring" outputDebugString(cancelReason, 2) cancelEvent(true, cancelReason) -- Something is wrong, stop startup end end, false) You could also make a copy of your current ACL and use the default one: https://github.com/multitheftauto/mtasa-blue/blob/master/Server/mods/deathmatch/acl.xml
-
In most cases it works by default. But in some cases you need to restart the server. I ran in to that issue myself, restarting did resolve the problem for me. For the following info, I used the resource runcode as example. Step 1A, check if the request is applied: aclrequest list runcode all Step 1B, if not, run: aclrequest allow runcode all Step 2A Test if the error is gone. Step 2B, not working? Restart the server Step 2C Still not working? Give the resource temporary admin rights and resolve it later. btw. not to go offtopic, but a reminder that I replied on your other topic with `PointOfInterest`.
-
That is why you can capture those by surrounding the fromJSON with a table: local result = {fromJSON(data)} Although this solution might be more optimised: local result = fromJSON("[" .. data .. "]") It changes your data string to: [[ { "id": 49, "username": "framef318", "email": "[email protected]" }, { "id": 50, "username": "framef3188", "email": "[email protected]" } ]] Which helps returning everything inside of 1 variable, instead of multiple.
-
And if you do: local result = {fromJSON(data)} ? { "id": 49, "username": "framef318", "email": "[email protected]" }, This is one return value. local a, b = fromJSON(data) { "id": 50, "username": "framef3188", "email": "[email protected]" } And this is one return value. local a, b = fromJSON(data) Other way (untested): local result = fromJSON("[" .. data .. "]")
-
It is just an integer, 213821 nothing in terms of memory. No matter how long the number is, it will not use more memory than if it was a string. 10000000000 consumes less memory than "10000000000". If you do not believe me, ask Chat GPT... Also, I asked Chat GPT the following: How many times can fit 10000000000 in 8gb of memory table.remove is only useful when you want to use a table as an array. It is very useful if order matters, but in your case there is no need for maintaining an order. It might save some memory, but the look up speed will consumes (incremental) a lot more CPU(you need to loop) which is a big trade off. local temp = {1, 2, 3, 7, 10, 100} -- id's inside For example the table pointOfInterestCollection. do local id = 0 ---@return integer function generateId () id = id + 1 return id end end ---@type {[integer]: table|nil} local pointOfInterestCollection = {} ---@param poi table function savePointOfInterest (poi) local id = generateId () poi.id = id pointOfInterestCollection[id] = poi end ---@param id integer ---@return table|nil function loadPointOfInterest(id) return pointOfInterestCollection[id] end ---@param id integer ---@return boolean function removePointOfInterest(id) if not pointOfInterestCollection[id] then return false end pointOfInterestCollection[id] = nil return true end
-
When are using the following: bindKey timers trigger(server/client)Event (set/get)ElementData etc... The data that you pass through these functions is being cloned. The reason behind that is: the data is leaving it's current Lua environment. With as goal to maintain the data, else it is lost. Unfortunately metatables and functions can't be cloned, which is why you did encounter data loss. Fortunately, because they can't be cloned you know that something is wrong. If they were be able to get cloned, you would have ended up with multiple clones of the same entity that do not share data. Which becomes really hard to debug. To resolve this issue, do not pass the element but use a self made id(integer). And make it look up able by using another table.
-
Have you used debug lines to debug/verify every part of the call chain?
-
IIYAMA started following I don't know, how shared.lua file works? and Function doesn't get saved as a table variable
-
I tested the following code with this compiler and it works. https://onecompiler.com/lua/42wdewngs Are you sure you are not synchronizing the data or exporting it(call/export)? Because in that case interactionFunction becomes nil. PointOfInterest = {} PointOfInterest.__index = PointOfInterest function PointOfInterest:create(x, y, z, interactionRadius, interactionFunction, visibleDistance, interior, dimension, renderOffsetX, renderOffsetY, renderOffsetZ, onFootOnly) if type(x) ~= "number" or type(y) ~= "number" or type(z) ~= "number" then error("Bad argument @ PointOfInterest:create [Expected number at argument 1, 2, 3, got "..type(x)..", "..type(y)..", "..type(z).."]", 2) end if type(interactionFunction) ~= "function" then error("Bad argument @ PointOfInterest:create [Expected function at argument 5, got "..type(interactionFunction).."]", 2) end local poi = {} setmetatable(poi, PointOfInterest) poi.x = x poi.y = y poi.z = z poi.interactionRadius = type(interactionRadius) == "number" and interactionRadius or 1 -- [temp disabled] poi.collision = createColSphere(x, y, z, poi.interactionRadius) -- [temp disabled] poi.collision:setID("poi") -- Set the ID to "poi" to identify it as a point of interest poi.interactionFunction = interactionFunction -- [simplified] poi.visibleDistance = type(visibleDistance) == "number" and visibleDistance or 10 poi.interior = type(interior) == "number" and interior or 0 poi.dimension = type(dimension) == "number" and dimension or 0 poi.renderOffsetX = type(renderOffsetX) == "number" and renderOffsetX or 0 poi.renderOffsetY = type(renderOffsetY) == "number" and renderOffsetY or 0 poi.renderOffsetZ = type(renderOffsetZ) == "number" and renderOffsetZ or 0 poi.onFootOnly = (type(onFootOnly) == "boolean" and onFootOnly) or false -- [temp disabled] TBL_POIS[poi.collision] = poi return poi end function testfunc() print('You are near the point of interest!') return true end local test = PointOfInterest:create(195.00665283203, -141.83079528809, 1.5858917236328, 1, testfunc, 10, 0, 0, 0, 0, 1, true) print(test.interactionFunction()) Output: You are near the point of interest! true
-
That should be fine. You can make a bug report here. As a temporary solution you can stop the rendering process: https://wiki.multitheftauto.com/wiki/SetBrowserRenderingPaused (Note: This does not free up the memory.)
-
How do you close the browser? (as in code)
-
Correct! Please mind that the primary language of this section is English. It is fine to add additional translations for clarification.
-
And what does this output? console.log("Parsed leaderboard data:", leaderboardStats, typeof(leaderboardStats));
-
And if you do not modify the JSON? (and use backticks) local testJSON = toJSON(leaderboardData) if isElement(initBrowser) then local script = string.format("populateLeaderboard(`%s`);", testJSON) outputChatBox("SCRIPT : " ..script) executeBrowserJavascript(theBrowser, script) end const leaderboardStats = JSON.parse(leaderboardDataJSON); console.log("Parsed leaderboard data:", leaderboardStats);
-
Additional context: Serverside is code executed on the server. The application all players are connected to. Clientside is code executed on each client/player his game. There are as many clientsides as there are players in the server. They all run a copy of all clientside scripts. Each player downloads the clientside code from the server. When a player joins the server, in most cases the copy of the code will only run until the download is finished. (with an exception if priority is given to a specific resource) Shared is code executed On the server And a copy of the code is executed on each client / player his game Nothing is shared between them, except for running the same copy of the code.