Jump to content

Leaderboard

Popular Content

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

  1. The more entities it finds, the more performance it cost. (!!!especially if you loop over them) 1. A way to improve performance could be done by only get the streamed in players. getElementsByType("player", root, true) For example if you are drawing name-tags on players, you want to draw them only on players close by. By pre narrowing down the segment of players, this will reduce the amount of loops you are going to preform. for key, player in ipairs(getElementsByType("player", root, true)) do 2. And switching to a more basic loop could also help a lot with the performance. for i=1, #table do end 3. If the element type isn't a player, scoping the function to the resource which creates a specific element, could also help with performance. getElementsByType("vehicle", resourceRoot, true)
    3 points
  2. If you can avoid looping all elements of a certain type on the server up to 70 times per second (that's what render event is), you should do so by all means for performance reasons. Using something like getElementsWithinRange or thinking of alternative solutions like putting the elements you need into a table for use (avoiding constant getting) is much better. I would also advise using that function before the solution of looping for streamedIn from the post above (for any scenario when it's like getting players nearby for rendering things like nametags), as it's even a little more optimized. @Killbean The real culprit is setElementData, as long you keep the amount of getElementData's in render event below 4, you should be fine. The same applies to most other things you do in onClientRender: special care needs to be taken, try to keep the function as simple as possible and add as many checks and conditions as you can to stop costly unnecesary execution in an early stage. Better yet, avoid the render event entirely when you can (it's performance killer number 1, at least in the hands of most scripters on MTA these days) and think of other ways like static drawing your images and other stuff, and getting data you need at a high interval (hence using render) with a short timer..
    1 point
  3. SOLVED!!! THX SO MUCH MAN @SpecT
    1 point
  4. if ( getElementModel (thePlayer) == ) then A sua condição está errada, thePlayer não é um elemento. Os parâmetros desse evento são o modelo antigo e o novo modelo, não um player como vc passou pra sua função, já o source é o elemento que está sendo modificado. E também faltou o 200 depois do == para verificar. O que você poderia fazer, semelhante ao que você fez mas de uma forma correta, é: if getElementModel(source) == 200 then ... Mas por questão de desempenho é melhor pegar o newModel (que é o atual model/skin do elemento) e verificar se é 200, em vez de chamar a função getElementModel pra isso... function onPlayerModelChange (oldModel, newModel ) --Os parâmetros são a antiga e a nova skin if ( newModel == 200 ) then -- Verifica se a nova skin é a de ID 200 toggleControl ( source, "sprint", false ) --Se for: else toggleControl ( source, "sprint", true ) --Se não for: end end addEventHandler ( "onElementModelChange", root, onPlayerModelChange ) -- Aqui também tinha faltado o elemento a qual o evento vai ser anexado, no caso o root. Eu nunca usei esse evento e nem testei aqui, veja se funciona pra você e qualquer coisa posta aí no fórum
    1 point
  5. I just tested it and it works fine. Player gets respawned after 10 seconds at the place of death. If it keeps spawning ONLY at the LS hospital then you probably have a script running which does that.
    1 point
  6. It might just be a missing vertex color export feature with Kam's script. You would have to use Goldfish's scripts or The Hero's plugin for exporting lighting correctly
    1 point
  7. Bom vamos lá! @BlackinSCR Gostei do nick haha' function adminchat4 ( thePlayer, _, ... ) local message = table.concat ( { ... }, " " ) if ( isPlayerOnGroup ( thePlayer ) ) then for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( isPlayerOnGroup ( player ) ) then if getElementData (thePlayer, "ChatGlobal:Delay1", true) then outputChatBox ( MensagemFalandoRapidoDemaisGlobal, thePlayer, 255, 255, 255, true ) return end local conta = getAccountName(getPlayerAccount(player)) -- Aqui voce deve verificar para quem irá aparcer a mensagem (player definido no for) if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Staff" ) ) then outputChatBox("* #bfbfbfDeep Web - #ffffff"..getPlayerName(thePlayer).. " ("..getPlayerID(thePlayer)..") #bfbfbf- "..message, player, 255, 255, 255, true) elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Everyone" ) ) then outputChatBox("* #bfbfbfDeep Web - "..message, player, 255, 255, 255, true) end end end end setElementData ( thePlayer, "ChatGlobal:Delay2",true ) setTimer ( setElementData, 100, 1, thePlayer, "ChatGlobal:Delay2", false ) end addCommandHandler ( ComandoDoChatGlobal4, adminchat4 )
    1 point
×
×
  • Create New...