-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
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.
-
@SoManyTears Is your problem resolved?
-
You could apply the effect only when the elements are streamed in, that would be an enormous improved in terms of performance. -- already streamed in elements for i,peds in ipairs (getElementsByType ("ped", root, true)) do for i,players in ipairs (getElementsByType ("player", root, true)) do setElementCollidableWith (peds,players,false) end for i,vehicles in ipairs (getElementsByType ("vehicle", root, true)) do setElementCollidableWith (peds,vehicles,false) end for i,objects in ipairs (getElementsByType ("object", root, true)) do setElementCollidableWith (peds,objects,false) end end -- -- new streamed in elements local acceptedElementTypes = {player = true, vehicle = true, object = true} addEventHandler( "onClientElementStreamIn", root, function ( ) local elementType = getElementType( source ) if acceptedElementTypes[elementType] then local peds = getElementsByType ("ped", root, true) for i=1, #peds do local ped = peds[i] setElementCollidableWith (ped,source,false) end elseif elementType == "ped" then -- what if it is a new ped? You can program this step yourself. end end )
-
Use the browser In combination with D3. https://d3js.org/ And pick for example this chart: https://observablehq.com/@d3/area-chart Or any of these: https://observablehq.com/@d3/gallery That is what I would do, if I do not want to spend too many hours in building a visualisation.
-
That is correct, because you can't do anything with resources that are not initialized. Except maybe for the name. (for new resources: onClientResourceStart) If you only need the resourceNames: You could save elementdata on the resourceRoot containing all resourceNames. Or (more secure/controllable) triggerServerEvent > triggerClientEvent to send over all the resourceNames. But think twice about which resourceNames you send over. Since it might be a little privacy sensitive for you...
-
That is probably because the following function is serverside only: https://wiki.multitheftauto.com/wiki/GetResources See here a workaround for clientside: local resourceRoots = getElementsByType("resource") for i=1, #resourceRoots do local thisResourceRoot = resourceRoots[i] local resourceName = getElementID ( thisResourceRoot ) if resourceName then local res = getResourceFromName(resourceName) if res and res ~= resource and getResourceState(res) == "running" then end end end Source resource: draw-distance https://gitlab.com/IIYAMA12/draw-distance/-/blob/master/scripts/main_c.lua#L248
-
How is that even possible, when you can't script and never ask pure scripting related questions nor showing a bit of interest? Doesn't that mean that the only thing the helper can do, is doing it for you? Think about it. Read it again, since you clearly mist something. You can request here for fixing resources, which is in your case the right match, don't you think?
-
You are correct in general, but not this time since the following unwillingness applies to Pedro001 for all scripting posts that I have seen until this far: Therefore it is considered as a scripting request. Please prove me otherwise if I made the wrong decision. Feel free to help him with his request, it is not as if the topic is locked.
-
Scripting/resource requests should be posted in resources. You should know that by now...
-
A database would use more CPU than just a plain file. When using a timeout (as Addlibs said), you can separate the database thread from the MTA thread. When having multiple CPU cores in your VPS server. Your CPU can automatic assign both threads to different cores, which leads to a very low impact on the performance. As for the file, MTA doesn't write directly to the hard drive, there is a buffer in between. Read more about flushing the buffer here. (Note: You shouldn't flush log files without reason) There is no big penalty here either. Very simple writing to a log file: local hFile = fileOpen("test.txt") -- attempt to open the file (read and write mode) if hFile then -- check if it was successfully opened fileSetPos( hFile, fileGetSize( hFile ) ) -- move position to the end of the file fileWrite(hFile, "hello" ) -- append data fileFlush(hFile) -- Flush the appended data into the file. fileClose(hFile) -- close the file once we're done with it else outputConsole("Unable to open test.txt") end -- https://wiki.multitheftauto.com/wiki/FileOpen And the downside of plain file has explained Addlibs already: Accessibility. XML? That is not a good idea for infinity data. XML uses a node system, each node representing a data-location in the XML tree, when you load the file, you load also all the nodes in to the memory. Loading the file should take longer based on the amount of nodes.
-
You can for example create an object (server), use projectile model: https://wiki.multitheftauto.com/wiki/CreateObject Move the object (server): https://wiki.multitheftauto.com/wiki/MoveObject And when it hits something (client), checking with this function every frame: https://wiki.multitheftauto.com/wiki/IsLineOfSightClear https://wiki.multitheftauto.com/wiki/OnClientRender Than you trigger to serverside and make an explosion: https://wiki.multitheftauto.com/wiki/CreateExplosion And yes it is not easy. If not an overwrite: The player that creates the projectile: projectile createProjectile ( element creator, int weaponType [, float posX, float posY, float posZ, float force = 1.0, element target = nil, float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] ) https://wiki.multitheftauto.com/wiki/CreateProjectile If the vehicle creates it, the owner should be either the vehicle controller or the syncer.
-
@nameforthisforum The following code is used for the command: local restricted = false -- set to true if you want to control this based on acl addCommandHandler("fpk", function (player, playerName, ...) local reason = table.concat(arg or {...}) -- arg or {...} depending on the Lua version -- element player, string playerName, string reason end, restricted, false) <right name="command.fpk" access="false"></right> <right name="command.fpk" access="true"></right> For storing data, you could use this resource: https://wiki.multitheftauto.com/wiki/XmlData But you have to take the first steps before I am going to help you with that.
-
Projectiles with an owner have their orientation pre-set based on the camera rotation. Setting the orientation after the projectile creation, will only work when all clients are applying the same adjustments. AFAIK only a full overwrite of the behaviour and synchronization will solve that problem.
-
no, If you only want to see your objects, I recommend to set all objects to another dimension than the players. And for every object you create: triggerClientEvent > Clientside: setElementDimension (to your own dimension)
-
playerSource does not exist. Use localPlayer instead.
-
Your code does this: Loop send over 1 object (network) delete all objects create 1 object send over 1 object (network) delete all objects (included the one you just created) create 1 object send over 1 object (network) delete all objects create 1 object etc. etc. etc. Just send over the whole menteshez table > loop, else you will also kill your network.
-
By keeping a function alive within the testLoad function, until the message is send back. And how do you do that? Well, you can look at the source code of my library and see if you could replicate a part of it. Or just use the library. Or you can also not do it and return it in to a different function, that would be the easiest way without library.
-
There is no `easy` in doing that. For the example code, I will be using my library, so that I do not have to write so much code. Feel free to replace them with trigger events. Note: I did not test this, but it will at least give you an idea how it could be done. Server local xml = exports.xmldata function teszt(thePlayer) local object=getElementsByType("object") local theAcc = getPlayerAccount(thePlayer) local accname = getAccountName(theAcc) local menteshez = {} -- reset and fill up again for k, v in ipairs(object) do if getElementData(v,"owner") == accname then local x,y,z = getElementPosition(v) local id = getElementModel(v) local owner = getElementData(v,"owner") or accname local int = getElementInterior(v) local dim = getElementDimension(v) local Rx,Ry,Rz = getElementRotation ( v ) menteshez[#menteshez + 1] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz} end end callClientAwait(thePlayer, "saveMapData", "save" .. base64Encode(accname), menteshez, function (successState) outputChatBox(client, "Map data has been saved.") end) end addCommandHandler("save",teszt) function testLoad (thePlayer) local theAcc = getPlayerAccount(thePlayer) local accname = getAccountName(theAcc) callClientAwait(thePlayer, "loadMapData", "save" .. base64Encode(accname), menteshez, function (data) outputChatBox(client, "Map data is here available, if it has been saved before") end) end addCommandHandler("load",testLoad) Client local xml = exports.xmldata function saveMapData (fileName, data) return xml:xmlSaveData(fileName, data, true, false, true) end function loadMapData (fileName) return xml:xmlLoadData ( fileName, true, true) end
-
That can become an issue, here is a list that current method is lacking: - Not able to use a-sync + queueing - Not able to saving/loading data by using a different thread. - XML uses more filespace - There is no cleaner for older account data / There is no archive system that moves account data that isn't used for a while to a separated environment. You can also decide to backup the data on to the clients their pc's. That way you can freely clean data on the server when accounts aren't used for more than a year. The client has a copy of the data and can upload it back to the server when the server has deleted it. (but more sure that it can't be abused, by encrypting the file) Clientside only datastorage would be a better a better solution to be honest, but then again if the client crashes... auto save might be recommended.
-
Nope it did not. Let me simplify it a bit, remove all tools that you are currently not using, since we get no-were otherwise. local xml = exports.xmldata function teszt(thePlayer) local object=getElementsByType("object") local theAcc = getPlayerAccount(thePlayer) local accname = getAccountName(theAcc) local menteshez = {} -- reset and fill up again for k, v in ipairs(object) do if getElementData(v,"owner") == accname then local x,y,z = getElementPosition(v) local id = getElementModel(v) local owner = getElementData(v,"owner") or accname local int = getElementInterior(v) local dim = getElementDimension(v) local Rx,Ry,Rz = getElementRotation ( v ) menteshez[#menteshez + 1] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz} end end xml:xmlSaveData("save" .. base64Encode(accname), menteshez, false, true) end addCommandHandler("save",teszt)
-
Are you 100000% sure that `menteshez`contains a table?