Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. yes, this is how it should be done. for which function? triggerServer/ClientEvent, addEventHandler or getElementsByType?
  2. The browser is a very different interface, but is facing the exact same issues. Checkbox, radio buttons = last incoming message wins After every change, you should use an increased int value to make sure that very old messages are not valid. This can also be done with timestamp. Luckily tcp is used, else it will be a really mess with the messages order. Text / label = claiming the focus right. The first player can edit. The other players do have disabled inputs and even get kicked out of the field (which is reset to the last known server value). And yes blocking messages from players that have no focus rights. An enchantment on to text/labels is: - Updating the text while typing. - Showing who is editing.
  3. @majqq The basic The most safest way is like php does it. Sending an instruction to serverside. Serverside updates the list and send it back. During the proces the browser is refreshing the page, which is more or less freezing the interface. This instruction is not the whole list of items. But it contains the identifiers of the items that are going to change + how they are going to change. Enchantments It is not idealistic to freeze the interface. In case of multiple users editing the same data. If your players have good internet, then you might not even need an enchantment. But be warned, enchantments on top of sync items between server and multiple clients is complex. You can update the clientside data first. Instruction: Item with id 253. Move to index 30. Clientside Do the instruction Send the instruction to serverside Serverside Do the instruction IF successful sync instruction (other clients) ELSE If different outcome (A different client updated something before you did) Resend list to clientside (you) sync instruction (other clients) ELSE Resend list to clientside (you) or undo instruction in case of not making any other changes.
  4. IIYAMA

    Scaling

    @majqq Scaling over the X axis? We do not play MTA on a smartphone you know? (Yes, we want to) For position? Sure! Scaling? No! The only thing that matters is comparing the same thing with the same thing. Square! That is something we can work with. Out of every MTA screen format we can make the exact same square from the y axis with a different amount of pixels. This is something we can scale up and down! If we are doing that with the X axis, then we are missing some pixels which we can't take in to account and it will look bad. The only things that are going to be different per computer: How sharp things are looking. So it might be handy to scale text down to a limit of 80%. The pixel size of your monitor. (which not even your computer knows)
  5. Did you also try the example on wiki?
  6. The same position + offset. X + 1, Y, Z Or X, Y + 1, Z
  7. @Samking See example on this page: https://wiki.multitheftauto.com/wiki/GetScreenFromWorldPosition
  8. @KeksKing Better to start over. https://github.com/multitheftauto/mtasa-blue/blob/master/Server/mods/deathmatch/acl.xml And just copy the things that you think that are useful in it.
  9. 1. You do not have to do anything. Putting them to nil, will indeed clean them, but there is so much RAM to eat. In case of a large dataset, sure nil it. http://lua-users.org/wiki/GarbageCollectionTutorial 2. Everything together. Ai is something heavy in general, so there is nothing to be surprised about. - Functions calls. - Lot of events. - Calculations - Collision detection 3. Yes, serverside only. Easiest method: local API's Don't even think about integrations.
  10. @JKiller55 Take a step back from your calculation. If you want to go complex, sure why not? But first ... Start with something you can work with. local multiplier = hp / 100 -- 0 hp = 0x; 100 hp = 1x local red = 255 * (1 - multiplier) local green = 255 * multiplier
  11. @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
  12. 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
  13. 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
  14. 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)
  15. 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!
  16. 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
  17. clientside variable. You must have already send it before you login.
  18. 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.
  19. 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.
  20. getCharName is a different event than login.success. Use getCharName on line 10, instead of login.success.
  21. 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" )
  22. You mean protection from stealers? Or access to files from different resources?
  23. IIYAMA

    Multi Language

    @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.
  24. IIYAMA

    Synch question

    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.
  25. 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.
×
×
  • Create New...