Jump to content

Simple0x47

Members
  • Posts

    1,518
  • Joined

  • Last visited

  • Days Won

    8

Simple0x47 last won the day on January 12 2020

Simple0x47 had the most liked content!

About Simple0x47

  • Birthday 21/02/2001

Details

  • Gang
    I'm not a gangster
  • Location
    Spain
  • Occupation
    None
  • Interests
    IT

Recent Profile Visitors

14,434 profile views

Simple0x47's Achievements

Loc

Loc (38/54)

307

Reputation

  1. Such an awesome community! I have to thank the developers of MTA for creating such an amazing opportunity for people to get hooked on programming through Lua scripting. So, thank you very much for everything MTA Team & Community!
  2. I didn't say servers shutting down are only because of the gamemode they use. The take here was whether or not the open source will help to increase the lifespan of a previously leaked gamemode based server, or decrease it, as low as it may be compared with all the management related decisions and tasks.
  3. That's overloading, mate. No such thing here on Lua, mate. But you could simulate that behavior as @Patrickputs it, and then proceed to redirect the arguments to a specific range of functions. local function OutputText(text) -- code end local function OutputTextToPlayer(text, player) -- code end local function OutputTextToPlayerWithColor(text, player, r, g, b) -- code end -- Patrick's suggestion. function Output(...) -- "magic parameter" for all local args = {...} -- put them into a table local length = #args if length == 1 then -- 1 parameter passed to function local text = args[1] OutputText(text) elseif length == 2 then -- 2 parameter passed to function local text, player = args[1], args[2] OutputTextToPlayer(text, player) elseif length == 5 then -- 5 parameter passed to function local text, player, colorR, colorG, colorB = unpack(args) -- or you can use unpack instead of indexing table one by one OutputTextToPlayerWithColor(text, player, colorR, colorG, colorB) end end
  4. Since the leak of the first versions of OWL, clone RP servers were opened to be closed within a week or two. Now that OWL is open source, will these servers last longer, due to the *now legal scripting support here on MTA Forums*, or will they drop at record speeds? Only time will tell... What are your takes on this?
  5. I'd rather see Python or C# implemented, as alternative scripting, before JS.
  6. No, I've asked you if your building has a LOD texture.
  7. Does your building have any kind of LOD texture? Because if not, just forget about the LOD of the island too.
  8. MTA allows you to customize your chatbox from the settings, but if you want all your players to have certain setting you should proceed by creating your own chat system.
  9. This server still goes strong after all these years! @Einheit-101 epic server!
  10. Well... You've got a variable _nowY which holds: sy - 305 - (47 * 1) But, you use that value hardcoded into the assignment of the pos variable: pos = {interpolateBetween(20 - 80, sy - 305 - (47 * 1), 0, 20, sy - 305 - (47 * 1)... pos = {interpolateBetween(20, sy - 305 - (47 * 1), 0, 20, sy - 305 - (47 * 1)... That's not all! At the end you update the variable nowY, which is not being used anywhere. I'd say you get a grasp of the basics of variables. All that being said, what you must do is make usage of the variable nowY, which must be defined before the start of the for loop, so you have an assigned value for the first notification which will be shown, but for that you must make usage of the variable nowY within those interpolateBetween, so pos may hold an Y value which changes depending on the number of the notification. All that being translated into code results into this: --client function drawnBoxes() _sx, _sy = sx, sy nowY = sy - 305 - (47 * 1) local now = getTickCount() for k,v in ipairs(cache) do local msg = v["msg"] local length = v["length"] local startTime = v["now"] local endTime = v["end"] local state = v["state"] local type = v["type"] local tick = v["tick"] local showtime = v["showtime"] or 8000 local customProg = v["customProg"] local boxSize = 25 local pos, alpha -- = v["pos"], v["alpha"] local r,g,b = unpack(types[type][2]) if not r or not g or not b then getColors(true) end local icon = types[type][1] local timeLine = false local timeLineProg if state == "fadeIn" then local elapsedTime = now - startTime local duration = endTime - startTime local progress = elapsedTime / duration if progress < 1 then pos = {interpolateBetween(20 - 80, nowY, 0, 20, nowY, 0, progress, 'OutQuad')} alpha = {interpolateBetween(0,0,0, 220,255,0, progress, 'OutQuad')} else alpha = {220, 255, 0} pos = {20, nowY, 0} cache[k]["now"] = getTickCount() cache[k]["end"] = getTickCount() + showtime cache[k]["state"] = "timeLineStart" end elseif state == "timeLineStart" then alpha = {220, 255, 0} pos = {20, nowY, 0} local elapsedTime = now - startTime local duration = endTime - startTime local progress = elapsedTime / duration if customProg and customProg[1] and customProg[2] then progress = customProg[2] / customProg[1] -- now / max end timeLine = true timeLineProg = progress if progress >= 1 then cache[k]["now"] = getTickCount() cache[k]["end"] = getTickCount() + 1600 cache[k]["state"] = "fadeOut" end elseif state == "fadeOut" then timeLine = true local now = getTickCount() local elapsedTime = now - startTime local duration = endTime - startTime local progress = elapsedTime / duration pos = {interpolateBetween(20, nowY, 0, 20, nowY, 0, progress, 'OutQuad')} alpha = {interpolateBetween(220, 255,0, 0,0,0, progress, 'OutQuad')} if progress >= 0.95 then table.remove(cache, k) if #cache <= 0 then if renderState then renderState = false --removeEventHandler("onClientRender", root, drawnBoxes) destroyRender("drawnBoxes") end end end end local boxWidth = length + 70 dxDrawRectangle(pos[1], pos[2], boxWidth, 50, tocolor(22, 22, 22, alpha[1]),true) dxDrawText(msg, pos[1] + 55 + 10, pos[2] + 26, 0, 0, tocolor(156, 156, 156, alpha[2]), 0.75, notificationFont, 'left', 'top',false,false,true,true,false) dxDrawText(details[type][1], pos[1] + 55 + 10, pos[2] + 10, 0, 0, tocolor(255, 255, 255, alpha[2]), 0.75, notificationFontBold, 'left', 'top',false,false,true,false,false) dxDrawImage(pos[1] + 10, pos[2] + 10, 30, 30, 'files/notificationIcons/'..details[type][2]..'.png', 0,0,0, tocolor(r, g, b, alpha[2]),true) if timeLine then timeLineSize = interpolateBetween(boxWidth, 0,0, 0, 0,0, timeLineProg or 1, customProg and "Linear" or 'OutQuad') else timeLineSize = boxWidth end dxDrawRectangle(pos[1], pos[2] + 48, timeLineSize, 2, tocolor(r, g, b, alpha[2]),true) nowY = nowY + 35 end end This code will make notifications get out of the screen after certain number of notifications, so you should create certain notification's queue in order to make the excess appear after the first ones are gone.
  11. About why it is faster, pairs tries to get all the keys of one table (which means it doesn't look only for numbers as index). Meanwhile, making usage of a limited number of possible index values leaves you with faster results. Try tables with at least 1000 values in order to see some difference.
  12. Well since your code uses the same logic, here's a more efficient way to do it: local playerElements = getElementsByType( "player" ) local players = {} for i = 1, #playerElements do local player = playerElements[ i ] players[ i ] = { name = getPlayerName(player), alive = getElementData(player,"state") == "alive", points = tonumber( getElementData(player,"ThePoints")) or 0 } end table.sort( players, function( a, b ) return a.points > b.points end )
  13. Interesting. Recently started and already on version 6.01 ?... I suppose another fork of OWL but I hope you guys get your server to the top!
  14. a) Loops indexed by numbers, synchronize element's data as little as possible, think twice before creating a global variable. b) If your shader is correctly implemented it shouldn't suppose a problem for a PC which can run GTA San Andreas.
×
×
  • Create New...