Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 14/02/21 in all areas

  1. It's working, thank you so much
    1 point
  2. I prefer this useful function for such stuff: function getPlayerFromNamePart(name) if (name) then for _, player in ipairs (getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(tostring(name):lower(), 1, true) then return player end end end end Then it will be like this: getPlayerFromNamePart(guiGridListGetItemText(gridOpenSenior, guiGridListGetSelectedItem(gridOpenSenior), 1)) PS: This function is used when you need to find a player by a part of his nick (i.e. in a command for something).
    1 point
  3. so basically like this? local lowspawn = {}; local lowspawnrates = { locations } function lowspawnzones() for i, z in ipairs(lowspawnrates) do lowspawn[#lowspawn + 1] = createColRectangle(z[1], z[2], z[3], z[4]); end end addEventHandler("onResourceStart", resourceRoot, lowspawnzones) EDIT: it worked, thank you verymuch, understand what u mean now, got it, thanks again!
    1 point
  4. For that structure you need to slightly modify your table - first, to loop through each group, and secondly, to prevent duplicate entries (I believe the freeroam skins XML can have the same skin under different groups) local tabla = {} function XmlToTable() local added = {} -- table to keep track of which skins were added to prevent duplicates local xml = xmlLoadFile("skins.xml") -- load the xml local groups = xmlNodeGetChildren(xml) -- the the xml root's children nodes if groups then for i, group in ipairs(groups) do -- loop the xml root's children nodes local skins = xmlNodeGetChildren(group) -- the the group's children nodes if skins then for j, skin in ipairs(skins) do -- loop the group's children nodes local id = tonumber(xmlNodeGetAttribute(skin, "id")) -- ensure you convert the string to a number, if impossible, a nil is returned - this is caught by the next if statement if id and not added[id] then -- if tonumber didn't fail and the id wasn't yet added table.insert(tabla, id) -- add it added[id] = true -- and prevent it from being added again end end end end end xmlUnloadFile(xml) -- unload now that we're done with this end addEventHandler("onClientResourceStart", resourceRoot, XmlToTable) -- if this script is clientside addEventHandler("onResourceStart", resourceRoot, XmlToTable) -- if this script is serverside function teszt() for k, v in ipairs(tabla) do outputChatBox(v) end end addCommandHandler("asd",teszt) I've also noticed that "expected string at argument 1, got table" error is caused by storing tables within tabla instead of skin IDs - this originates from a typo in your code where you've written xmlNodeGetAttributes instead of xmlNodeGetAttribute.
    1 point
  5. local lowspawn = {}; local lowspawnradar = {}; lowspawn[#lowspawn + 1] = createColRectangle(z[1], z[2], z[3], z[4]); lowspawnradar[#lowspawnradar + 1] = createRadarArea(z[1], z[2], z[3], z[4], 200, 150, 0, 200); addEventHandler("onColShapeHit", resourceRoot, function(hitElement) for i = 1, #lowspawn do if source == lowspawn[i] then if getElementType( hitElement ) == "player" then setElementData(hitElement, "threat", "low"); end end end); Try to understand the code if you have any problems leave a reply!
    1 point
  6. Por favor, use a ferramenta de código: Insira o seu código no campo especificado e marque a linguagem Lua.
    1 point
  7. Some benchmark: Javascript ( with some debug informations ), two times slower than c++ Lua ( requires debughook to do not get terminated due infinity loop protection ) Js is faster in this case because "add" function was called simillar each time, calling same function with different arguments ( mostly different types ) may cause performance to degradate ( Jitted functions get deoptimized )
    1 point
  8. afaik v8 (MTA JS implementation that CrosRoad95 working on) isn't working as Slipe (NanoBob's C# "translator") - Slipe: C# (csharp.lua) > Lua > C++ - V8: JS > C++
    1 point
  9. Experimente usar setGameSpeed em um script client-side.
    1 point
×
×
  • Create New...