Jump to content

Search the Community

Showing results for tags 'onclientrender'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 8 results

  1. Ola tudo bem? eu estava programando e veio a ideia de usar o setTimer ao invez do onClientRender porque notei diferença no ipb quando eu usava onClientRender o ipb dava x, ao usar setTimer o ipb dava metade do x so queria saber se existe algum problema fazer deste modo
  2. Render events enhancement Having a lot of render events in your resource? Easier attach and remove? Or do you want to pass arguments in to a function which is attached to a render event? Then this might be something for you. Syntax: addRenderEvent bool addRenderEvent(function functionVar [, string eventName, arguments ...]) Arguments: The function you want to attach/target. The event you want to use. ( "onClientRender", "onClientPreRender", "onClientHUDRender") If you do not fill in one of these three, it will automatic fallback to "onClientRender". Fool proof. Arguments you can pass to the target function. (which isn't possible with the default addEventHandler + onClientRender function) Returns: true when added, and false otherwise. Syntax: removeRenderEvent bool removeRenderEvent(function functionVar [, string eventName]) Arguments: The function you want to attach/target. The event you want to use. ( "onClientRender", "onClientPreRender", "onClientHUDRender") If you do not fill in one of these three, it will automatic fallback to "onClientRender". Fool proof. Returns: true if found + removed, and false otherwise. (Not recommended to execute this function every frame > performance) onClientPreRender + timeslice If you use "onClientPreRender", just like the default event, it will pass the timeSlice to the attached/targetted function. https://wiki.multitheftauto.com/wiki/OnClientPreRender I am not sure if attached is the right word for this example, because it isn't really attached to the event. It is saved in a table which gets looped every frame. Performance Is this code bad for performance? The answer to that is NO. I ran a test for it, and it seems that addRenderEvent used less CPU AFTER adding the events. (addRenderEvent: 31% CPU, addEventHandler 99/100% CPU) Adding the event will probably use more CPU, but that is only one execution. Feel free to re-test this example, I am interested how it would perform on your pc's. Performance test code (Not the source code ) Source code:
  3. local isWindowShowing = false --عشان نعرف الزر ظاهر او لا false متغير بالقيمة local screenW, screenH = guiGetScreenSize() --ذي عشان تجيب احدثيات شاشتك function renderDx() dxDrawRectangle(screenW * 0.2844, screenH * 0.4644, screenW * 0.0919, screenH * 0.0378, tocolor(0, 0, 0, 100), false) --مربع علي شكل زر dxDrawText("تجربة", screenW * 0.2844, screenH * 0.4644, screenW * 0.3762, screenH * 0.5022, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false) --داخل المربع كلام end --نقفل الفنكشن function onKey() if isWindowShowing == false then --بمعنى الزر حالياً مخفي false لو المتغير قيمته showCursor(true) --اظهار الماوس isWindowShowing = true --بمعنى الزر ظاهر حالياً true نعطي المتغير قيمه addEventHandler("onClientRender", getRootElement(), renderDx) --نظهر الزر الآن elseif isWindowShowing == true then --بمعنى الزر ظاهر حالياً true لو المتغير قيمته showCursor(false) --نخفى الماوس isWindowShowing = false --بمعنى الزر انحذف الآن false نعطى المتغير قيمه removeEventHandler("onClientRender", getRootElement(), renderDx) --نحذف الزر الآن end --نقفل التحقق end --نقفل الفنكشن bindKey("F9", "down", onKey) --ذا ايفنت من اللعبة انه لما يضغط اف 9 يحصل شئ --// لما يضغط على المربع (الزر) function onClick(theButton, theState) --بين القوسين أحدثيات الرستنقل (المربع) وليس التيكست (الكلام اللى جوا المربع) isMouseInPosition ملاحظه: بتحط تحت فالكود if theButton == "left" and theState == "down" and isWindowShowing == true and isMouseInPosition(screenW * 0.2844, screenH * 0.4644, screenW * 0.0919, screenH * 0.0378) then --لو ضغط كلك يسار فى الماوس واللوحة ظاهره حالياً (بنعرف عن طريق المتغير) والماوس على المربع اللي هو الزر (بنعرف عن طريق احدثيات الشاشة) outputChatBox("تجربة") --نظهر فى الشات تجربة end --نقفل التحقق end --نقفل الفنكشن addEventHandler("onClientClick", getRootElement(), onClick) --ذا ايفنت من اللعبة ان لما الاعب يضغط بالماوس علي الشاشة --// ذا كود جاهز يتحقق من احدثيات الشاشة عشان لما نضغط على المربع (الزر) function isMouseInPosition(x, y, width, height) if not isCursorShowing() then return false end local sx, sy = guiGetScreenSize() local cx, cy = getCursorPosition() local cx, cy = cx * sx, cy * sy if (cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then return true else return false end end اتمنى الشرح واضح وبسيط للناس الجدد فى برمجة اللغة، يمكنك ايضاً تغيير اظهار فى الشات تجربة إلى اشياء اخرى كثيرة https://wiki.multitheftauto.com/wiki/Main_Page :يمكنك الاطلاع على جميع الفنكشنات حق اللعبة من هنا
  4. Estou usando onClientRender para aparecer um dxDrawText em meu painel , pois ele mostra um valor do server-side. Com isto , ao abrir o painel , esse texto não para de piscar(trazendo o valor varias vezes), mas se eu usar addCommandHandler ele aparece apenas um vez. Gostaria de manter o texto em meu painel , apenas removendo ele ao utilizar removeEventHandler para fechar o painel.
  5. Eae pessoal. Estou com uma dúvida rápida aqui. Estou fazendo um sistema de level, nesse sistema existe um verificador server-side que verifica todos os jogadores a cada 1 segundo procurando por players AFK para pausar o Up do level. Até então sem problemas, mas estou querendo colocar o tempo do up de cada jogador aparecer na tela deles, qual procedimento a seguir é MAIS LEVE para fazer isso? cria uma variável, salva o tempo nela e triggerClientEvent a cada 1 segundo, para enviar essa variável atualizada ao cliente. setElementData no jogador a cada 1 segundo, então o client irá sempre mostrar essa data na tela dele. setAccountData no jogador a cada 1 segundo. [Já vi que é inviável fazer assim, até porque não há como receber esse valor client-side] fazer o próprio client calcular o tempo de up? A propósito, o timer em si é este: (server-side) No script client, deverá ter um onClientRender que deverá mostrar o playerLapsed ao jogador. (só que no client, irá formatar os milisegundos em minutos/segundos.)
  6. Galera, fiz esse script para resolver um problema solicitado por um usuário aqui do fórum. O objetivo é fazer com que os jogadores e veículos que estiverem dentro de uma zona de colisão fiquem no "modo ghost" (sem colisão) para que os veículos e jogadores que estiverem dentro da zona não colidam entre si e voltem ao normal quando saírem da zona. O esquema é simples de se fazer usando setElementCollidableWith e onClientColShapeHit. O problema é que os veículos criados dentro da zona não eram afetados, pois ainda não existiam quando o jogador entrou na zona, sendo necessário o jogador sair da zona e entrar de novo nela para que este novo veículo fosse afetado também. Para contornar esse problema fiz tudo usando onClientRender, porém não sei se essa é a melhor maneira, levando em conta que consome maior processamento e existem muitos verificadores dentro dele. O script ficou assim: (client-side) Alguém tem alguma ideia de fazer esse script "mais leve"? Ou esse jeito é o único possível para evitar o problema?
  7. The text appears succesfully but i cant make it disappear:/ Pls help! [lua] function fadeDX() startTick = getTickCount() addEventHandler("onClientRender",root,text) end function text() local currentTick = getTickCount() local progress = (currentTick-startTick)/duration local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad") dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3) setTimer ( function() startTick = nil,nil removeEventHandler("onClientRender",root,text) local currentTick = getTickCount() local progress = (currentTick+startTick)/duration local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad") dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3) end, 8000, 1 ) end [/lua]
  8. Hi there. I interesting the one of important question. When I want to get getPedVehicleOccupied, what' will be more better with a performance side? To check every frame with onClientRender event if player are in a vehicle (getPedVehicleOccupied)? Or set events like a onClientVehicleEnter/Exit, onClientResourceStart etc. and check getPedVehicleOccupied only in those events?
×
×
  • Create New...