-
Posts
1,518 -
Joined
-
Last visited
-
Days Won
8
Posts posted by Simple0x47
-
-
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!
- 1
-
33 minutes ago, UndR said:
servers shutting down wasn't because of using a leaked gamemode or an open source, It just depends how you manage your server, and I can confirm that English Playerbase is dropped since like 2018-2019, so most of the owners couldn't keep up, but right now SARP is open since a long time and still hits some numbers.
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.
- 1
-
16 hours ago, VortDyn said:
Is it possible to create two (or more) functions with the same name, but different number of arguments? Personally, it didn't work for me, maybe there are some hidden stones (Perhaps this is due to the fact that I did this for exports)?
Something like this:
functionOutput (text)
end
function Output (text, player)
end
function Output (text, player, colorR, colorG, colorB)
endThat'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
- 1
-
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?
- 1
-
I'd rather see Python or C# implemented, as alternative scripting, before JS.
- 3
-
No, I've asked you if your building has a LOD texture.
-
Does your building have any kind of LOD texture? Because if not, just forget about the LOD of the island too.
-
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.
-
This server still goes strong after all these years! @Einheit-101 epic server!
- 2
-
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.
- 1
-
- 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.
- 1
-
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 )
- 1
-
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!
-
23 hours ago, Mature said:
Hi guys, I have a server and would like you to give me some important tips for good performance and the shortest possible time on server and client, and one question, I created a Shaders system where CJ leaves White, which can result in frame drops? as all players would use this modification!
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.
-
Since you are talking about 'top value', I suppose you've got a table, whose indexes are numerical, which contains the players. If you draw the text within a loop, which goes through all the elements of the previously mentioned table, you can easily edit the order of the players by assigning them to a different index within the table.
In the case you don't have a loop whose indexes are numerical, try to implement one to keep it easy.
- 1
-
Well. You could try with this start: https://www.Lua.org/pil/contents.html
- 1
-
Try looking harder because there are several full roleplay gamemodes released.
-
-
-
I don't get why people get so upset, although the code is open-source. It'd be a different story if you would sell it for money...
-
-
It seems there's certain conflict between MTA:SA and Nahimic 2+ Audio Driver. [Lag only appears when the mentioned program is on]
- 1
-
On 29/09/2019 at 14:06, Adventure said:
The project will be postponed for a little while. I will be experimenting more and releasing public scripts to help me vision a clear structure of what approach I would like to take with this resource. I believe by making smaller resources and publishing them will help me with the correct approach for this project. If you have any further questions, do not hesitate to ask!
F?
-
Hello everyone!
As the title says, Multi Theft Auto get's laggy (<10 fps) after the introduction screen. Tried to make usage of a nightly build, but the problem persisted.
MTADiag: https://pastebin.mtasa.com/195050556
[SELL] Gamemode - RolePlay
in Resources
Posted
I offer you 1$.