-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
The input has to be a table: reformatToArray(menteshez) Not something else.
-
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
-
You didn't apply my previous feedback, that is why you got that error:
-
The double dots might be the problem: xml:xmlLoadData("save:" .. accname, true) Try to replace them with something else.
-
Maybe it didn't not ran, did you check that?
-
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
-
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
-
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
-
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
-
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
-
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}
-
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
-
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.
-
[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...
-
Make sure that the resource 'core' is running.
-
Hey DiGiTal Summary: Y axis: Y axis position & compute pixel density(scale) X axis: X axis position drawText("$123456789", 140*sx, 648*sy, 0*sx, 0*sy, tocolor(0,0,0,255), 0.8*sy,"bankgothic") drawText("$123456789", <start position>, <start position>, <end position>, <end position>, tocolor(0,0,0,255), <scale>,"bankgothic") Take a look at your code. There are 3 types of arguments. start position (boundingbox) x y end position (boundingbox) x y scale (text) And an `invisible` one, which is the boundingbox size: boundingbox width = (end position x) - (start position x) boundingbox height = (end position y) - (start position y) You are currently not using the boundingbox. But that is something you could scale as well. When scaling and positioning, there is 1 important thing to keep in mind and that is to look at both of them differently. Because for some cases you want to scale position over the X and Y axis at the same time. X axis is used for the raw position. Y axis is used for the offset. local scaleValueY = sy_/900 local startPositionX = x_ -- right side of the screen local offsetX = scaleValueY * 30 -- calculate an scaled offset value local positionX = startPositionX - offsetX Your code drawText("$123456789", 140*sx, 648*sy, 0*sx, 0*sy, tocolor(0,0,0,255), 0.8*sy,"bankgothic") = drawText("$123456789", <10.2%>, <72%>, <0%>, <0%>, tocolor(0,0,0,255), <80% * 100%>,"bankgothic") I assume this is text placed above the radar. Now how to figure out the difference in methods? The only way is actually to see it for yourself. I made the following changes to reproduce your situation: Argument 2: Scaling the left offset over the Y axis. Argument 3: Starting from bottom to top, to improves `value` readability. (but doesn't change the outcome) Changed the text color to red. local scaleValueY = sy_/900 drawText("$123456789", scaleValueY * 140, sy_ - (scaleValueY * 252), 0, 0, tocolor(255,0,0,255), 0.8 * scaleValueY,"bankgothic") Your development resolution is: 1440 x 900 Check if both of them are aligned properly. If yes, then: Run both of examples at the same time with different resolutions and ratio aspects. Check the X position of both methods and see how those behave. Make some screenshots, which we can discus here.
-
@Bekao Nice first attempt. You are currently skipping: screen-ratio It might something to take a look at, since your UI will be stretched(in all directions) when other players have a different ratio. In some cases that is fine, but when you do that with an image, it will not look very nice. You are also skipping: "How to create a User Interface" An image is not a User Interface, but it can be come one with the right methods (which are not explained). Either edit the title or add the missing information.
- 1 reply
-
- 1
-
@Tekken Not sure if you already have discovered it, but there is the DxTex tool that can be used to build texture files and compress them with the format you need. https://wiki.multitheftauto.com/wiki/DxCreateTexture Download link
-
I don't see this function guiGridListSetItemData (not Get), belonging to the following warning/error: In the code you just showed.
-
Both lines were already inside of your code, at the correct location (before I replied). You only had to change the column id. I have no idea how you managed to get that error.
-
Try to pass the data on column 0, instead of 1. Maybe that solves the problem. ? -- IN guiGridListSetItemData(transportGUI.locationgrid, row, 0, Data) -- -- OUT local DestinationData = guiGridListGetItemData(transportGUI.locationgrid, selected, 0)
-
You can check the variable value type. if type(DestinationData) == "table" then if (getPlayerMoney() >= DestinationData[5]) then --ERROR --[[ ... ]] end end
-
@[N]inja Moved your topic again to here https://forum.multitheftauto.com/forum/127-programação-em-lua/