Jump to content

Arsilex

Members
  • Posts

    1,410
  • Joined

  • Last visited

Everything posted by Arsilex

  1. function createPosition(player) local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local interior, dimension = getElementInterior(player), getElementDimension(player) local position = "posX = " .. x .. ", posY = " .. y .. ", posZ = ".. z .. ", rotX = ".. rx .. ", rotY = ".. ry .. ", rotZ = " .. rz .. ", Interior = " .. interior .. ", Dimension = ".. dimension .. "\n" if fileExists ( "positions.txt" ) then local file = fileOpen("positions.txt") fileSetPos ( file, fileGetSize ( file ) ) fileWrite(file, position) fileClose(file) else local file = fileCreate("positions.txt") fileWrite(file, position) fileClose(file) end end Solo tienes que hacer algo tal que asi createPosition(jugador) No lo he probado pero debería de funcionar!
  2. addEvent( "check", true ) addEventHandler( "check", root, function () if isElement(source) and getElementType(source) == "player" then if getPedOccupiedVehicle ( source ) then local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox ("* Panel abierto correctamente", thePlayer, 0, 255, 0) else outputChatBox ( "* No tienes acceso", thePlayer, 255, 0, 0) end else outputChatBox ( "* Debes estar en un vehiculo", thePlayer, 255, 0, 0) end else outputChatBox ( "* Argumento source no esta definido como jugador", client, 255, 0, 0) end end )
  3. Yo sinceramente no uso ese método me ya que lo que haces es agrandar o hacer mas pequeño el rectángulo lo que hace que en resoluciones altas o muy bajas se ve muy mal gráficamente. Te sugiero hacerlo en tamaño real al que lo creaste solo usando el método para los posicionamientos. Otra cosa que te sugiero es hacer como unos parent imaginarios es decir poner un cuadrado mas o menos en tu pantalla y de allí ir añadiendo o quitando pixeles es decir en vez de usar toda la pantalla usas solo un pequeño trozo de ella donde irán tus cálculos es decir una cosa asi: local sX, sY = guiGetScreenSize local x = sX/2 - 400 local y = sY/2 - 300 local w = 800 local h = 600 De esa manera solo tendrás que hacer en plan dxDrawRectangle(x, y, w, h, tocolor(255, 0, 0, 255)) dxDrawRectangle(x, y, w, 32, tocolor(0, 0, 0, 255) Es decir estas haciendo un solo calculo para el posicionamiento de tu panel lo que ahora bastantes cuentas a la hora de ejecutar el código dentro de un render ( El código de arriba mejor ponerlo fuera y cambiar desde el script si es necesario cambiando su variable) También esta la manera mas sencilla que es un usando un render y dibujando tu panel en la resolución que tu quieras pero eso suele ser un poco mal gráficamente ya que cuando dibujas algo renderizado lo que hace es pixelizarlo un poco. Espero que te sirva de ayuda. Edito: no te sugiero usar el guieditor si no que crear los paneles paso por paso manualmente te sale mucho mas rápido y mejor posicionado. También te sugiero no usar una resolución fija para eso, es decir como haces que es sourceX = 1366... yo prefiero crear los paneles usando pixeles que yo necesito mas o menos haciendo cuentas un ejemplo podría ser para lineas o cuadrados uso pixeles como 16, 32, 48, 64, 128, 256, 512.... Esto ultimo es solo una manera de hacerlo. NO es obligatorio ni nada de eso hacer esto que yo he dicho pero son unos trucos que yo pienso que vienen bien
  4. Arsilex

    Quote string

    He visto otras maneras de hacer esto sin tener que cerrar los corchetes. Que es la que quiero saber.
  5. Arsilex

    Quote string

    Buenos días, tengo una pregunta que a lo mejor es bastante simple pero no se me ocurre de como funciona he buscado por google y no sale nada logico al respecto Como puedo usar una variable dentro de un quote string es decir: [[ Esto es una linea Bla bla bla mi nombre es: AQUI PONER UNA VARIABLE bla bla bla ]]
  6. Explícate como que se me copiaron? Te refieres a Samake? Si es así no se copio ya que el hizo una versión bastante mas extendida y mejorada con shaders y varias cosas mas según yo se
  7. Pero, cuando tu necesitas ordenar una tabla para que luego puedas ya sea controlarla o hacerle cualquier cosa este método es bastante lento por lo que estoy viendo. A lo mejor en otros lenguajes como C++ este método de sort es mucho mas rápido pero en LUA parece que no.
  8. Acabo de probarlo y eh recibido valores bastante inferiores 100 Milisegundos mas rápido. Ahora si que no comprendo por que dices que ese método es mas rápido?
  9. Hmmm, me interesado por el tema este.. acabo de mirar el vídeo pero no me quedo del toco claro por que de esta manera es mucho mas eficiente que otras? es decir lo que hace básicamente es si un numero es mayor o menor del otro lo pone en una parte o otra pero sinceramente no me quedo muy claro porque? Edito: Estuve haciendo unas pruebas con esto y bien, puede que sea bastante rápido el sort. El codigo con el que he probado es: function swap(items, firstIndex, secondIndex) local temp = items[firstIndex] items[firstIndex] = items[secondIndex] items[secondIndex] = temp end function partition(items, left, right) local pivot = items[math.floor((right + left) / 2)]; local i = left; local j = right; while (i <= j) do while (items[i] < pivot) do i = i + 1; end while (items[j] > pivot) do j = j - 1; end if (i <= j) then swap(items, i, j); i = i + 1; j = j - 1; end end return i; end function quickSort(items, left, right) local index; if (#items > 1) then local left = type(left) ~= "number" and 1 or left; local right = type(right) ~= "number" and #items or right; index = partition(items, left, right); if (left < index - 1) then quickSort(items, left, index - 1); end if (index < right) then quickSort(items, index, right); end end return items; end Que es básicamente el quicksort y he obtenido una velocidad 135 Milisegundos ordenando una tabla de 50.000 números entre el 0 y el 200000000000000 La cosa esta en que este método es solo útil para organizar arrays de números al igual que el ejemplo que has puesto tu de Binary Tree si no me equivoco, si se puede me gustaría saber como?
  10. Wow, me sorprende gratamente poder leer unas palabras así de Alexs_Steel y Tomas gracias a los dos jeje
  11. Exactamente como dijo Gabriel, use trigonométrica básica.
  12. Bueno estaba aburrido asi que hice esto: local handl = nil local sX, sY = guiGetScreenSize() local colors = { tocolor(255,0,0),tocolor(0,255,0) } local state = 1 local size = 200 local tick = 0 function clientRenderFunc() if(handl) then local posX = sX/2 local posY = sY/2 if state == 1 then local bt = getSoundFFTData ( handl, 16384, 1921 ) if(not bt) then return end for i = 1, 1920 do local x = (i) local y = 853*bt[i - 1] local x2 = (i+1) local y2 = 853*bt[i] dxDrawLine(x, sY - 200 - y, x2, sY - 200 - y2, tocolor(255, 255, 255, 255) ) dxDrawLine(x, sY - 200 - y, x2, sY, tocolor(0, 0, 0, 100) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 2 then local bt = getSoundFFTData ( handl, 16384, 257 ) if(not bt) then return end for i = 1, 256 do local x = (i)*7.5 local y = 853*bt[i - 1] local x2 = (i+1)*7.5 local y2 = 853*bt[i] dxDrawLine(x, sY - 200 - y, x2, sY - 200 - y2, tocolor(255, 255, 255, 255) ) dxDrawLine(x, sY - 200 - y, x2, sY, tocolor(0, 0, 0, 100) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 3 then local bt = getSoundFFTData ( handl, 16384, 513 ) if(not bt) then return end for i = 1, 512 do local x = (i)*3.75 local y = 853*bt[i - 1] local x2 = (i+1)*3.75 local y2 = 853*bt[i] dxDrawLine(x, sY - 200 - y, x2, sY - 200 - y2, tocolor(255, 255, 255, 255) ) dxDrawLine(x, sY - 200 - y, x2, sY, tocolor(0, 0, 0, 100) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 4 then local bt = getSoundWaveData ( handl, 16384, 3610) if(not bt) then return end local posX = sX/2 local posY = sY/2 local sample = 270 for i = 90, 270 do local ID = 2*(sample-i)+1 local ID2 = 2*(sample-i) local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) local x2 = math.cos(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) local y2 = math.sin(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) local x3 = math.cos(i*(3.14159265359/180)) * size local y3 = math.sin(i*(3.14159265359/180)) * size dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) end for i = 270, 450 do local ID = (2*i)-270 local ID2 = (i == 360 and 0 or (2*i)-269) local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.max((bt[ID]*128), 0)) local x2 = math.cos(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) local y2 = math.sin(i*(3.14159265359/180)) * (size + math.max((bt[ID2]*128), 0)) local x3 = math.cos(i*(3.14159265359/180)) * size local y3 = math.sin(i*(3.14159265359/180)) * size dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 5 then local bt = getSoundFFTData ( handl, 16384, 1920 ) if(not bt) then return end local posX = sX/2 local posY = sY/2 for i = 1, 360 do local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[(i == 360 and 0 or i)]*853)) local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[(i == 360 and 0 or i)]*853)) dxDrawLine(posX + x2, posY + y2, posX + x, posY + y, tocolor(0, 0, 0, 255) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 6 then local bt = getSoundFFTData ( handl, 16384, 1920 ) if(not bt) then return end local posX = sX/2 local posY = sY/2 for i = 1, 360 do local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[i-1]*853)) local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[i]*853)) local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[i]*853)) local x3 = math.cos(i*(3.14159265359/180)) * size local y3 = math.sin(i*(3.14159265359/180)) * size dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 7 then local bt = getSoundFFTData ( handl, 16384, 3610) if(not bt) then return end local posX = sX/2 local posY = sY/2 local sample = 270 for i = 90, 270 do local ID = sample-i+1 local ID2 = sample-i local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) dxDrawLine(posX + x2, posY + y2, posX + x, posY + y, tocolor(0, 0, 0, 255) ) end for i = 270, 450 do local ID = i-270 local ID2 = (i == 360 and 0 or i-269) local x = math.cos((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + (bt[ID]*853)) local x2 = math.cos(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) local y2 = math.sin(i*(3.14159265359/180)) * (size + (bt[ID2]*853)) dxDrawLine(posX + x2, posY + y2, posX + x, posY + y, tocolor(0, 0, 0, 255) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") elseif state == 8 then local bt = getSoundFFTData ( handl, 16384, 3610) if(not bt) then return end local posX = sX/2 local posY = sY/2 local sample = 270 for i = 90, 270 do local ID = sample-i+1 local ID2 = sample-i local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) local x2 = math.cos(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) local y2 = math.sin(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) local x3 = math.cos(i*(3.14159265359/180)) * size local y3 = math.sin(i*(3.14159265359/180)) * size dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) end for i = 270, 450 do local ID = i-270 local ID2 = (i == 360 and 0 or i-269) local x = math.cos((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) local y = math.sin((i-1)*(3.14159265359/180)) * (size + math.min((bt[ID]*1000), 500)) local x2 = math.cos(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) local y2 = math.sin(i*(3.14159265359/180)) * (size + math.min((bt[ID2]*1000), 500)) local x3 = math.cos(i*(3.14159265359/180)) * size local y3 = math.sin(i*(3.14159265359/180)) * size dxDrawLine(posX + x3, posY + y3 , posX + x, posY + y, tocolor(0, 0, 0, 255) ) end dxDrawImage(posX - size, posY-size, size*2, size*2, "logohd.png") end end if getKeyState("num_8") then size = size + 5 elseif getKeyState("num_2") then size = size - 5 end end function changeMode(cmd, st) state = state + 1 end addCommandHandler("changeMode", changeMode) function clientSoundStopFunc(_) if(source == handl) then removeEventHandler("onClientRender",root,clientRenderFunc) removeEventHandler("onClientSoundStopped",root,clientSoundStopFunc) handl = nil end end function musicStartFunc() if(not handl) then handl = playSound('music.mp3') setSoundSpeed ( handl, 1 ) setSoundPosition ( handl, 47 ) addEventHandler("onClientRender",root,clientRenderFunc) addEventHandler("onClientSoundStopped",root,clientSoundStopFunc) end end function musicStopFunc() if(handl) then stopSound(handl) handl = nil removeEventHandler("onClientRender",root,clientRenderFunc) removeEventHandler("onClientSoundStopped",root,clientSoundStopFunc) end end bindKey("9","down",musicStartFunc) bindKey("0","down",musicStopFunc) Si, no es para nada eficiente ni adaptado a todas las resoluciones, no hice esto para algo en concreto solo para pasar el tiempo. Ya que vi un vídeo en youtube que usaba una cosa como esta estas pero con After Effect que queda mucho mejor y dije por que no...
  13. Arsilex

    Pruebas

    Estoy haciendo unas pruebas de cuanto consume el renderizado de imágenes en mta y mi test me da se usa 14% de CPU y el script se ejecuta en una media de 2 ms, mi pregunta es esta bien eso teniendo en cuenta que estoy haciendo un test con 10.000 dxImage a toda pantalla es decir 1920x1080
  14. rankingboard es donde esta ubicado el deathlist si, los muertos se añades desde /modes/destructionderby.lua linea 62 y 72
  15. No entiendo, sigue dándome la misma cantidad. Ups sorry se hice mal la array: local tt = {"hello", text = "hello", "bb", text2 = "bb"}
  16. ._. tt = {{"a"},{"b"},{"c"},{"d"},{"e"},{"f"}} function table.size( t ) if type( t ) ~= 'table' then return false end local n = 0 for _ in pairs( t ) do n = n + 1 end return n end outputChatBox("metodo 1: "..table.size( tt ), 255, 255, 0) outputChatBox("metodo 2: "..#tt, 255, 0, 0) es que a simple vista se ve como se va contando 'n' estando dentro del ciclo y retornas al valor final de n. así que no entiendo pruebalo con esta array: local tt = {"hello", text = hello, "bb", text2 = bb}
  17. Pero eso sería lo mismo que hacer #table. Si estas tan seguro de ello, haz un test por ti mismo No se puede usar table.insert para hacer data1 data2 así que no entiendo lo que necesitas exactamente.
  18. function table.size( t ) if type( t ) ~= 'table' then return false end local n = 0 for _ in pairs( t ) do n = n + 1 end return n end Creditos al sub-foro russo: https://forum.multitheftauto.com/viewtopic.php?f=141&t=33091
  19. Usa este metodo: https://www.dropbox.com/s/t7d4bfjxrb8ep ... T.zip?dl=0
  20. https://community.multitheftauto.com/in ... s&id=11836 Autor: Ren_712
  21. Are you sure that all the ports are opened?
  22. You can see that in the video, AFAIK the IP's are same I once had tried to connect to STORM:RPG by IP din't work but by searching and then clicking on it it worked STROM's server IP is: mtasa://5.196.208.53:22003 as fine i can see in the browser. Edit: I just tried to connect to that IP and everything is working i mean STROM's IP
  23. This is working perfectly, and btw i improved a little bit your script. local counter = 0 local starttick local currenttick addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(localPlayer,"FPS",counter) counter = 0 starttick = false end end) function drawStates () addEventHandler ( "onClientRender", root, pingFpsCiz ) end addEventHandler ( "onClientResourceStart", resourceRoot, drawStates ) myFont4 = dxCreateFont("fps.ttf", 12 ) function pingFpsCiz() local x, y = guiGetScreenSize() local ping = getPlayerPing(localPlayer) dxDrawText("Ping", 1115/1366*x, 0/768*y, 590/1366*x, 26/768*y, tocolor(255, 255, 255, 255), 0.95, myFont4, "left", "center", false, false, false, true, false) dxDrawText("Fps", 1035/1366*x, 0/768*y, 590/1366*x, 26/768*y, tocolor(255, 255, 255, 255), 0.95, myFont4, "left", "center", false, false, false, true, false) if ping then local pingColor = ping <= 25 and "#00ff00" or (((ping >= 26) and (ping <= 40)) and "#5dff00" or (((ping >= 41) and (ping <= 60)) and "#a6f900" or (((ping >= 61) and (ping <= 80)) and "#defc00" or (((ping >= 81) and (ping <= 100)) and "#ffee00" or (((ping >= 101) and (ping <= 110)) and "#fcb400" or (ping >= 111 and "#fc3f00")))))) dxDrawText(pingColor..ping, 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false) end local fps = getElementData(localPlayer, "FPS") if fps then local fpsColor = fps <= 34 and "#fcb400" or (((fps <= 39) and (fps >= 35)) and "#fcb400" or (((fps <= 44) and (fps >= 40)) and "#defc00" or (((fps <= 44) and (fps >= 40)) and "#5dff00" or (fps >= 41 and "#00ff00")))) dxDrawText(fpsColor..fps, 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false) end end
  24. Are you sure that your server is using this IP: 149.56.148.54 make sure that you dont have another IP like failover IP on your server. The easier way to get the IP is search your server in the browser click on it and copy the ip from the browser header.
×
×
  • Create New...