Jump to content

ds1-e

Scripting Moderators
  • Posts

    636
  • Joined

  • Days Won

    8

Everything posted by ds1-e

  1. Hey @IIYAMA Each day, with small steps am getting closer to that. But before i am going to start optimizing bone_attach, i want to be sure that i've optimized my other scripts correctly. This refers to Lua functions and MTA functions which are in _G table? So for example math. functions, tostring, tonumber, and shared functions which are available in client and server side aswell (getElementsByType, getElementPosition) ? I'm just asking because after testing localized things it gives me a different result (less or more ticks)
  2. Should work, untested. function putPlayers() guiGridListClear(players_grid) -- i've deleted conditions which didn't make any sense... local players = getElementsByType("player") -- get all players for i = 1, #players do -- use int loop, no need for ipairs unless you need sorting, it's better for performance. local player = players[i] -- get player if player and player ~= getLocalPlayer() then -- remove player ~= getLocalPlayer() if you want to count yourself local x, y, z = getElementPosition(getLocalPlayer()) -- get position of local player local posX, posY, posZ = getElementPosition(player) -- get position of another player local distance = getDistanceBetweenPoints3D(x, y, z, posX, posY, posZ) if distance <= 30 then -- range local player_name = getPlayerName(player) local row = guiGridListAddRow(players_grid) guiGridListSetItemText(players_grid, row, 1, player_name, false, false) end end end end
  3. Okey. I will try to help you a bit with it. First of all, this is function called only on client or it's function from event handler? I'm wondering because you used source. Provide me more information so i could help you.
  4. That's why i noticed you about that: Adjust it to your code You should do it by yourself, if something will not work let me know.
  5. local players = getElementsByType("player") -- get all players for i = 1, #players do -- use int loop, no need for ipairs unless you need sorting, it's better for performance. local player = players[i] -- get player if player then local player_name = getPlayerName(player) local row = guiGridListAddRow(players_grid) guiGridListSetItemText(players_grid, row, 1, player_name, false, false) end end Adjust it to your code, i doubt that you've checked debugscript 3 for errors/warnings.
  6. FROM VERSION 1.5.6 r16715 ONWARDS The minimum accepted interval is 0ms now. https://wiki.multitheftauto.com/wiki/SetTimer
  7. Can you guys tell me how this is supposed to work? Using server-side functions at client-side. What you should do is collect them in table, and send with trigger to client.
  8. https://wiki.multitheftauto.com/wiki/GuiGridListSetItemText bool guiGridListSetItemText ( element gridList, int rowIndex, int columnIndex, string text, bool section, bool number ) You're looking for that (if we're talking about GUI) section: Determines if the item is a section
  9. ds1-e

    Simple question

    #weapons It will return table size, nothing more. To check if any weapon exists in table you need to index: weapon -- of course it can be any other variable, but in this case it should be number. between brackets: weapons[ ] So it will look like: weapons[weapon] -- you get what i mean?
  10. ds1-e

    Simple question

    It's up to you how you will call them. weapon is parameter declared in function arguments. And weapons -- or bodypartss are global tables which could be accessed from every scope of file and other script files declared on same side.
  11. ds1-e

    Simple question

    What you try to achieve? #weapons -- will return `weapons` table size If you want to do something when body part is headshot and weapon is in table, then you would need to change a bit a table structure (and condition too), to not loop necessary. weapons = { [22] = true, [23] = true, [24] = true, [26] = true, [27] = true, [28] = true, [29] = true, [30] = true, [31] = true, [32] = true, } And condition from: elseif bodypart == 9 and #weapons then to: elseif bodypart == 9 and weapons[weapon] then So, this way you check if weapon id exists in table, and it's not false and not nil. If you would change true -> false for a weapon, then this weapon wouldn't count as the one which fulfills the condition - because it would be false.
  12. ds1-e

    Trigger/tables

    Matter of time, and next questions coming Next question i have is about sending data after receiving trigger from client. local string, string_2 = incoming_data[1], incoming_data[2] -- incoming data from client if string and string_2 then -- ~= nil/boolean if my_table and #my_table > 0 then -- continue only if table size > 0 for i = 1, #my_table do local existing_string = my_table[i][1] if existing_string == string then -- replace data my_table[i] = {string_2, string_2} triggerLatentClientEvent("sendDataToClient", resourceRoot, player, {my_table}) -- send whole actual table with data break end end end end Take a look at example code, which is related to mine. What i want to say it's good habit to send whole table with updated data instead of sending only certain indexes? Just in case of questions - table size will have <= 50 indexes.
  13. If you don't use standard health, and you mean that to damage player when he is underwater and without oxygen. Then use onClientPlayerDamage with condition: if weapon == 53 then -- damage player end https://wiki.multitheftauto.com/wiki/Damage_Types
  14. What did you wrong is that i left comment to complete your code in it. But it would be easier for you using what @DNL291 suggested.
  15. ds1-e

    Trigger/tables

    Yes, thank you so much
  16. ds1-e

    Trigger/tables

    Thanks. Did you read my earlier post? Because I cover all my hopes in that system. What you would say about that?
  17. ds1-e

    Trigger/tables

    Besides, i need to ask you about another thing. Once, you told me and show the way for checking incoming data (for example if it is actually a number). - Should i use: type or tonumber() Or both ways are correct? At the moment it looks like this: local c_buffer, s_buffer, c_latent, s_latent = c_data[1], c_data[2], c_data[3], c_data[4] if c_buffer and tonumber(c_buffer) and tonumber(c_buffer) >= 0 and s_buffer and tonumber(s_buffer) and tonumber(s_buffer) >= 0 then -- end
  18. Condition which check if attacker is not equal to victim? if attacker ~= source then -- end
  19. From my own experience i want to say i had something similar with elementData. I don't say that element data is that bad, but it can cause problem like yours if not used correctly. That's why i moved everything on data system which use triggers and tables.
  20. ds1-e

    Trigger/tables

    Hey once again I don't wanna create new topic for this, and question is related to trigger/tables somehow. So once again stricte related to `network buffer`. I've read some explanation of one of the server owners, which probably use such a thing for reduce bandwith usage and so (custom data system for sure, not element data). I believe that helps a lot, and i saw much difference in server performance, when using tables + buffer. And now i'm gonna introduce it for everything else aka player health, player weapon etc. Furthermore, i created a utility which allows me to adjust delay or latent event directly in game (to have smooth gameplay). And here comes the question, let's say i have synced players weapons for everyone, so i directly know what damage weapon have. Should i `fake HUD information` when we're talking about player health level? I remember you adviced me to do so, in case above. It was explained that way: - After taking damage, health is decreased on client-side (probably to avoid instant death due to latency, and inform player to heal - this isn't the real value all the time, server hold real and current health value?) - Later client send trigger to server about incoming damage. As we shouldn't trust client, server do same step but on his own (calculate health - damage), change health value and send back to client.
  21. To be more clear - only player messages on chat, and some logs from my custom admin panel script. About slots i mean that if more players on server, then more messages can appear at the one moment. So as i said above, 1.5 sec delay between message per player, and `buffer` for 5-10 messages, if table reach that limit, log them to file. Should be alright?
  22. ds1-e

    Chat Radius

    You might use int loop version of it, if you're considered about performance. local players = getElementsByType("player") for i = 1, #players do local playerr = players[i] local x, y, z = getElementPosition(playerr) local x2, y2, z2 = getElementPosition(player) -- player represents the player who triggered the chat command. local distance = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if (distance <= 10) then outputChatBox("YOUR MESSAGE", playerr) end end
  23. You mean `buffer` like in case of sending triggers? I guess a solution will be saving this in table, and later writing to file. I am going to log some more than just logs from player messages on chat, but this will be one and only thing which was i worried about due to the frequency of sending them. I have 4GB RAM, about memory leak i'm familiar with it if we're talking about tables (https://wiki.multitheftauto.com/wiki/Debugging) - correct me if i am misunderstooding definitions.
  24. Hi. I was about to create a log system for myself, instead of using default outputServerLog. And here's my question, how much delay between logging i should use, since file functions are slow and i am worried about server performance. I have 40 slots server, 1.5 second should be enough?
  25. Hey You told me to remind you about that, and here I am.
×
×
  • Create New...