Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. @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.
  2. 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.
  3. 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)
  4. playerSource does not exist. Use localPlayer instead.
  5. 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.
  6. 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.
  7. 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
  8. 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.
  9. 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)
  10. Are you 100000% sure that `menteshez`contains a table?
  11. The input has to be a table: reformatToArray(menteshez) Not something else.
  12. You also have to apply my feedback from before that: (don't forget to modify the key) And after that it is variable debugging time. ---- + And you might also need to encode the account name, so that all special characters are escaped: https://wiki.multitheftauto.com/wiki/Base64Encode
  13. You didn't apply my previous feedback, that is why you got that error:
  14. The double dots might be the problem: xml:xmlLoadData("save:" .. accname, true) Try to replace them with something else.
  15. Maybe it didn't not ran, did you check that?
  16. Are you sure it is not located at a different location? If there is no data, there is nothing to load. So everything beyond this point should not be executed. local menteshez = xml:xmlLoadData("save:" .. accname, true) if not menteshez then xml:xmlSaveData("save:" .. accname, {}, false, true) return -- stop the function. end
  17. This line is at-least incorrect. You have to pick one of these methods: You can't do neither. You will have to check if this is working correctly: if not getCustomData(thePlayer, "menteshez", true) then setCustomData(thePlayer, "menteshez", {}, true) end
  18. First add the code from the tutorial. And then use these lines at the place were you access menteshez. Which should be a new table for each player. if not getCustomData(player, "menteshez", true) then setCustomData(player, "menteshez", {}, true) end Load: local menteshez = getCustomData(player, "menteshez", true) Save: setCustomData(player, "menteshez", menteshez, true) Each player has an unique table, so that modification is no necessary. See, how it is saved in xml with the accountName: local menteshez = getCustomData(player, "menteshez", true) local account = getPlayerAccount(player) local accountName = getAccountName(account) xml:xmlSaveData("save:" .. accountName, menteshez, false, true) You can also directly save and write, maybe that is easier: local account = getPlayerAccount(player) local accountName = getAccountName(account) local menteshez = xml:xmlLoadData("save:" .. accountName, true) xml:xmlSaveData("save:" .. accountName, menteshez, false, true) ------------------- -- Account initialization local account = getPlayerAccount(player) local accountName = getAccountName(account) local menteshez = xml:xmlLoadData("save:" .. accountName, true) if not menteshez then xml:xmlSaveData("save:" .. accountName, {}, false, true) end
  19. By saving and loading data for each player, there are already solutions out there that do just that. For example this one (an alternative for element data, but without deep-copy): setCustomData(player, "menteshez", menteshez, true) -- localized local menteshez = getCustomData(player, "menteshez", true) -- localized
  20. You got that error, because you can't save `elements` in xml. { [element] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz}, } That is why I gave you a function for reformatting: xml:xmlSaveData("save", reformatToArray(menteshez), false, true) Or use the second option, then you do not have to reformat: menteshez = {} -- reset for k, v in ipairs(object) do if getElementData(v,"owner") == thePlayer then --[[ ... ]] table.insert(menteshez, {x,y,z,id,int,dim,Rx,Ry,Rz}) end end
  21. That is because the top one creates a format like this: table.insert(menteshez,{x,y,z,id,owner,int,dim,Rx,Ry,Rz}) = { [1] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz}, [2] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz}, [3] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz} } And the bottom one requires a format like this: { [element] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz}, [element] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz}, [element] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz} } Which is achieved by doing this: menteshez[v] = {x,y,z,id,owner,int,dim,Rx,Ry,Rz}
  22. You can reformat the table with an array structure: function reformatToArray (theTable) local array = {} for k, data in pairs(theTable) do table.insert(array, data) end return array end
  23. You could link them together like this: for k, v in ipairs(object) do if getElementData(v,"owner") == thePlayer then --[[ ... ]] menteshez[v] = {x,y,z,id,int,dim,Rx,Ry,Rz} --insert/overwrite end end -- clean up for element, data in pairs(menteshez) do if not isElement(element) then menteshez[element] = nil end end -------- -- or -- -------- menteshez = {} -- reset for k, v in ipairs(object) do if getElementData(v,"owner") == thePlayer then --[[ ... ]] table.insert(menteshez, {x,y,z,id,int,dim,Rx,Ry,Rz}) end end Both formats have their own benefits.
  24. [20-11-29 15:34:19] WARNING: [vultaic]/v_dm/training_server.lua:5: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Validation statement is missing [20-11-29 15:34:19] ERROR: [vultaic]/v_dm/arena_event.lua:4: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] Validation statement is missing [20-11-29 15:34:19] Server minclientversion is now 1.5.8-9.20698.3 [20-11-29 15:34:19] WARNING: [vultaic]/v_os/training_server.lua:5: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Validation statement is missing [20-11-29 15:34:19] ERROR: [vultaic]/v_fdd/arena_event.lua:3: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] Validation statement is missing [20-11-29 15:34:19] WARNING: [vultaic]/v_race/respawn_server.lua:6: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Validation statement is missing [20-11-29 15:34:19] WARNING: [vultaic]/v_race/respawn_server.lua:7: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Validation statement is missing [20-11-29 15:34:19] SCRIPT ERROR: [vultaic]/v_hunter/arena_server.lua:1: '=' expected near 'settings' [20-11-29 15:34:19] ERROR: Loading script failed: [vultaic]/v_hunter/arena_server.lua:1: '=' expected near 'settings' Script is broken [20-11-29 15:34:19] WARNING: v_body <min_mta_version> section in the meta.xml is incorrect or missing (expected at least client 1.5.6-9.16404 because of 'onClientElementModelChange') [20-11-29 15:34:19] WARNING: v_body requires upgrade as <min_mta_version> section in the meta.xml is incorrect or missing (expected at least client 1.5.6-9.16404 because of 'onClientElementModelChange') [20-11-29 15:34:19] Use the 'upgrade' command to perform a basic upgrade of resources. [20-11-29 15:34:20] SCRIPT ERROR: [vultaic]/v_garage/garage_server.lua:10: '(' expected near 'registerArena' [20-11-29 15:34:20] ERROR: Loading script failed: [vultaic]/v_garage/garage_server.lua:10: '(' expected near 'registerArena' Script is broken [20-11-29 15:34:20] ERROR: Unable to start resource mapmanager; Couldn't find file model/nitro.dff for resource mapmanager File is missing [20-11-29 15:34:20] ERROR: Unable to start resource v_avatars; Couldn't find file img/default-avatar.png for resource v_avatars File is missing [20-11-29 15:34:20] ERROR: Couldn't find resource donatorship. Check it exists. Resource missing? [20-11-29 15:34:20] WARNING: [vultaic]/v_hdm/training_server.lua:5: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Validation statement is missing [20-11-29 15:34:20] ERROR: [vultaic]/v_hdm/arena_event.lua:3: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] Validation statement is missing [20-11-29 15:34:20] [vultaic]/core/core_server.lua:51: Registered arena [Hunter: No Limit - hunter nolimit - 1 - 32 false nil] [20-11-29 15:34:20] [vultaic]/v_hunter_nolimit/arena_server.lua:711: State >> waitingForPlayers [20-11-29 15:34:20] [vultaic]/v_hunter_nolimit/arena_server.lua:711: hunter nolimit >> Refreshed maps [Total: 0] [20-11-29 15:34:20] [vultaic]/v_hunter_nolimit/arena_server.lua:711: No map found to start If you can't fix it, throw it in the trash can...
  25. Make sure that the resource 'core' is running.
×
×
  • Create New...