-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
@Dziugasc Indeed, that is not going to work. local skins = {7,124,69} local skinIndex = 1 function getSelectedSkin() local selectedSkin = skins[skinIndex] return selectedSkin end function updateToNextSkin () skinIndex = skinIndex + 1 if skinIndex > #skins then skinIndex = 1 end return getSelectedSkin() end function updateToPreviousSkin () skinIndex = skinIndex - 1 if skinIndex < 1 then skinIndex = #skins end return getSelectedSkin() end
- 1 reply
-
- 1
-
It looks like the database column `pos` isn't correctly set-up. A tool you can use, to view this information, make sure the resource isn't running when you use it: https://github.com/sqlitebrowser/sqlitebrowser
-
Can you show me the complete JSON string? Because this one looks incomplete. This looks fine: [ <-- MTA wrapper [ [ <-- first array (table) [ [ [ <-- sub array (table) This looks like it is cut off, after getting it from the database (on the end of the string) ], [" Not sure if there is a character limit for the console. A quick validation: debugJSON_A = stringA -- JSON from clientside -- get the string from the database: debugJSON_B = stringB if debugJSON_A != debugJSON_B then outputChatBox("database column `hud` is not correct set-up") end
-
Because the client hasn't loaded yet. Because the addEventHandler hasn't the right event. Should be "showCharacters" The base Element is incorrect. You sending the parent = root from serverside element to a handler with the child = localPlayer at clientside. root (container) > localPlayer (child) < NOT WORKING localPlayer (child) > root (container) < WORKING (You are sending a triggerClientEvent, without target, so sending it to every player in game.) In case of sending it directly after loading the resource: (best practice) CLIENT addEventHandler("onClientResourceStart", resourceRoot, function () triggerServerEvent("onThisClientResourceStart", resourceRoot) end, false) SERVER local characterName = 'John Doe' addEvent("onThisClientResourceStart", true) addEventHandler("onThisClientResourceStart", resourceRoot, function () -- client is the target (the player that executed the event: onThisClientResourceStart) triggerClientEvent(client, 'showCharacters', resourceRoot, characterName) end, false) CLIENT function showCharacters(characterName) outputChatBox(characterName) -- localPlayer < this is running on the client/player his pc. No need to define the receiver, as only this player can receive the message end addEvent('showCharacters', true) addEventHandler('showCharacters', resourceRoot, showCharacters, false)
-
A Is the whole table a nil value B or is it a value after indexing the table? In case of A, it is very much possible to get those issues. JavaScript (Object Notation) does not support the data type tables after all. Use iprint to figure out which type of JavaScript objects MTA has assigned for your table format. [ "test"] = array {0:"test" } = object In case of B. First of all, it is better to send over tables instead of JSON. This makes the packet size much smaller and it might also solve your problem for some unknown reason. (Strings much bigger data type than numbers.) Did you set up your database correct that the column supports enough characters? (this can break JSON of course) Debug JSON, show me your JSON!
-
triggerServerEvent cannot send that data back like that. We are talking about two different systems that have a connection delay in between. (also known as PING) If you want that name clientside and clientside is the one that is requesting it. A clientside (request) > B serverside (getting the name) > clientside (receive) A triggerServerEvent > B triggerClientEvent
-
clientside variable. You must have already send it before you login.
-
You cannot change two tasks in to one task, that is not logic, even for humans. Task 1. Send over the name. (Save in to a variable) Task 2. Open the GUI and use the variable.
-
math.randomseed(getTickCount() * getTickCount()) Be × random as much as you want, play with the input of this function. But do not call it too much, it is a heavy operation.
- 1 reply
-
- 1
-
getCharName is a different event than login.success. Use getCharName on line 10, instead of login.success.
-
There is a way without reading/writing files and it is not that hard to master. But the downside of that method is that it will be loaded already in your ram as a string, even if you do not use it. -- the script should be between those [[ ]], which is a multiline string. local file = [[ local variable = 1 function example () iprint(variable) end example() ]] function getFile (securityKey) if securityKey == "4GDT^*#46345" then -- < An important layer of security. Compiled scripts might be not be viewed, but that doesn't mean they can't be loaded. return file end end <export function="getFile" type="client"/> call ( getResourceFromName ( "resourceName" ), "getFile", "4GDT^*#46345" )
-
You mean protection from stealers? Or access to files from different resources?
-
@holuzs As long as you do not use a database, it will be hardly noticeable. This whole table + it's sub-tables are located in the ram and will be available without much delay. And exporting will use a bit more CPU than a normal function call, but it will save RAM because you only have 1 location for the data.
-
As @Zorgman said. A way you can bring serverside and clientside elements closer to each other. server local weapon = createElement("weaponS") client local weapons_s = getElementsByType("weaponS", resourceRoot) for i = 1, #weapons_s do local weapon_s = weapons_s[i] local weapon_c = createWeapon(...) setElementParent(weapon_c, weapon_s) end ElementData can be used to transfer the properties and weapon states. Etc. Ect. Ect. This is a method you have to master, can't be learned with one tutorial.
-
Not really, pcall is already running the code. After that you are calling it without pcall again. pcall(loaded) -- call 1 loaded() -- call 2 Note: pcall executions do hide most of the debug information. So even if you did debug it, you wouldn't have noticed it. It is recommended to develop without pcall and when you are finish use it. I also saw you use triggerEvent on the resourceRoot. It is better if you do NOT use that at first. It is very important to understand that you can't just use the same element for all the resources. It will go bad... If you really want to use that. Top: local resourceRoot = createElement("resourceRootFaked") Bottom: triggerEvent("onClientResourceStart", resourceRoot, getResourceFromName("scriptLoaderResource")) And try to use the setfenv function as I have recommended before. In your current code all the global variables are exposed.
-
More or less the same way scriptDataString .. "\n do \n" .. loopData .. "\n end \n"
-
@Overkillz For each script you run, you are destroying the previous environment by overwriting the 'enviroment' variable. That does not go well. To be honest I haven't worked much with environments. But you will need to use setfenv function for cutting off the environment. Here a tutorial about the way to go, on the very BOTTOM of this page: http://lua-users.org/wiki/EnvironmentsTutorial A recommendation, based on just things that might be handy. Merge all the strings/scripts together and wrap each of them with: do --script end This will make sure that all local variables stay in their scope. An IIFE will do as well: (in case of an overflow of 200+ local variables in total) (function () -- script end)()
-
This function can be used to repeat the same image, it might be possible that they use the rotation/rotationCenterOffsetX/rotationCenterOffsetY property for each new repeated image as offset. But I have never seen anybody do that. So that is UNKNOWN territory for me.
-
Hmm, you could try to generate it with a browser. > browser https://wiki.multitheftauto.com/wiki/CreateBrowser > html + css <section style="width:300px;height:100;background-color:white;border-radius: 25px;"></section> > get https://wiki.multitheftauto.com/wiki/DxGetTexturePixels https://wiki.multitheftauto.com/wiki/DxGetPixelsSize > set https://wiki.multitheftauto.com/wiki/DxCreateTexture https://wiki.multitheftauto.com/wiki/DxSetTexturePixels (or just generate the corners, color = white = #fff is recommended)
-
See example on this page: https://wiki.multitheftauto.com/wiki/DxDrawCircle (not sure if it works as you want it)
-
Yes those will work just fine. But keep in mind that other resources might also add other children. So it's better to be a little bit more specific. local colshapes = getElementChildren ( vehicle, "colshape" ) local colshape = colshapes[1] -- is the colshape not a direct child? Use: local colshapes = getElementsByType ( "colshape", vehicle ) local colshape = colshapes[1]