-
Posts
1,048 -
Joined
-
Last visited
-
Days Won
6
Addlibs last won the day on October 25 2022
Addlibs had the most liked content!
Details
-
Location
United Kingdom
-
Occupation
Scripting Guru
Recent Profile Visitors
4,677 profile views
Addlibs's Achievements

[email protected] (35/54)
168
Reputation
-
These errors mean you're attempting to compare incomparable values, for example, a bool with a number. Is true > 1, < 1? It doesn't make sense. getElementData returns a 'false' value when there is no data stored under the given key -- all you have to do is prevent the comparison from happening if the returned value is not a number: local returnedValue = getElementData(someElement, "someKey") -- options: if (returnedValue) then if (returnedValue > 5) then -- valid end end if (returnedValue and returnedValue > 5) then -- valid end -- the following two will also work if the returned value is a string that contains arabic numbers in base-10, e.g. ("1000" (string) => 1000 (number)) if (tonumber(returnedValue) and tonumber(returnedValue) > 5) then -- valid end local returnedValue = tonumber(getElementData(someElement, "someKey")) if (returnedValue and returnedValue > 5) then -- valid end
-
Addlibs started following [HELP!] I can't synchronize scroll with select... , sqlite.db "erro ao carregar dados eu acho" , [HelpQuickly] How To Fix Error Error @BadArgument? and 6 others
-
Please use the Portuguese section if you need help in Portuguese. Por favor utilize a secção portuguesa se precisar de ajuda em português. This post, translated with DeepL: sqlite.db "error loading data I think". <code> theoretically when entering the marker it should display the amount of fuel available in the station but it is displaying ( Could not get the amount of gasoline for the set ) any idea how to make it work correctly
-
First issue: Lua is parsed and executed from top to bottom; by the time of the setTimer call, timerJail has not been declared or defined. You need to move the setTimer call after the timerJail function definition. Second issue: addEventHandler requires an element to bind onto (2nd argument) -- this means which element (and its children if propagation is enabled, which it is by default) should the event fire for -- and in your code it is an nil-value variable source, hence the error. source is defined within an event handler function, so getElementData(source, "jailLoc") is fine, source is the player that spawned. source outside that function, such as in the arguments passed to addEventHandler, it is undefined/nil. Change this to something like root (this is a pre-defined synonym for the value returned by getRootElement()).
-
You can use Telegram's Bot API. First, if you haven't already, create a bot (by messaging BotFather on Telegram) and use callRemote or fetchRemote (only do this on the server side, for security reasons -- never send the bot's token to a client) to utilize the API. Bots cannot initiate conversations, but you can prompt users to start a conversation by displaying a URL (or preferably a QR code) that a user can scan and open the conversations. You can also use a parameter in the QR code that would allow the bot to correlate the Telegram user with the MTA player if you need that. You can also create a group chat or a channel and invite the bot into it, and use it to let users read and write to the ingame chat out-of-game.
-
The commands you listed are incredibly easy to implement yourself (beginner level stuff, may be difficult if you have absolutely not idea what you're doing but once you learn the basics it should be easy), have you even tried? If so, show us your progress/attempts and what your specific issue is. We're not here to script for you.
-
The callback function for bindKey callback function does not receive a player element. The client-side bindKey's player can only ever be the localPlayer, so you need to change this function signature: function burnoutTheTires(player,key) -- into this function burnoutTheTires(key) and likewise for unpressedTheKeys, function unpressedTheKeys(player) -- into this function unpressedTheKeys() You could have discovered this yourself with a very simply debug methodology: debug outputs. See outputDebugString and iprint, (and less frequently used for this purpose but still usable: outputChatBox, outputConsole). And get rid of the burnoutTimer table, it is unnecessary, since it only ever stores one value, always under the key equivalent to the localPlayer element. Simply declare a local value (tip: local values, aka upvalues are faster in write and read speed over globals which are actually entries in the _G table and table lookups aren't as fast as upvalues) local burnoutTimer --- ... elsewhere in the code burnoutTimer = setTimer(...) -- ... in another place if isTimer(burnoutTimer) then killTimer(burnoutTimer) end -- etc. You may choose to search-and-replace all occurrences of "player" with "localPlayer" since that's pre-defined, but it's fine to leave as since it's just a local value pointing to the localPlayer element. The following part seems to be remnant of a time when this script was supposed to be serverside? for i,v in ipairs(getElementsByType("player")) do --bindKey("accelerate","down",burnoutTheTires) --bindKey("brake_reverse","down",burnoutTheTires) bindKey("accelerate","up",unpressedTheKeys) bindKey("brake_reverse","up",unpressedTheKeys) end Anyway, completely unnecessary -- onClientResourceStart is triggered for a running client (at the time of resource start on the server) as well as a joining client (aka resource start on the client at time of join), so this results in duplicated bind calls.
-
Do you possess the server-side for the given script? Or are you attempting to use someone else's client-side script files? This event name seems suspicious, like the author intended it to not work without the server-side files, even if they might not be required.
-
I'd point out @Shady1's solution does not scale well as the whitelist gets bigger. It would be more ideal to, on start-up, and then periodically (or on command like refreshwhitelist) download the list, store it in a Lua table in a [serial] = bool structure and look-up that table onPlayerConnect, and cancelEvent(true) if serial not present (which also benefits the server process as a good part of player join sequence is aborted earlier, including the construction of a player element). This way you don't download the whole list every time a player joins, parse it every time a player joins, and iterate thought it every time a player joins. Lua table look-ups benefit from hashing, leading to much faster lookup speeds than iterating thought the list, provided the list is large enough (could be as little as 5 entries for benefits to show up but I haven't tested it) (otherwise hashing could be more expensive).
-
if capacete1 then This checks whether a value is assigned to capacete1 (this value could be anything -- a string, number, userdata, coroutine, element, etc.), not whether it is a valid value for the purposes of your script. If the warning message you get says "expected element", it means you've passed it something that isn't an element (for instance, it could be a userdata reference to an element that's been destroyed by another script). A solution that gets rid of the warning is if isElement(capacete1) then
-
[HELP!] I can't synchronize scroll with select...
Addlibs replied to Murilo_apa's topic in Scripting
Pretty sure the most important part is slots[i] = {screenW * x, screenH * (y - scroll), screenW * 0.0483, screenH * 0.0872} replacing table.insert(slots, {screenW * x, screenH * (y - scroll), screenW * 0.0483, screenH * 0.0872}) The table.insert version was continuously adding new entries into the table rather than updating existing values as you scroll. -
Marcel Assink started following Addlibs
-
First of all, admin/staff_manager is not part of the default set of resources for MTA, so next time, tell us exactly what sort of resource you're using, where you got it from, a link to the documentation/user guide if you read it yourself beforehand) Also, please tell us what you've already tried doing to resolve your issue. So far, the error message suggests there's an issue with the resource 'integration' -- is it started? Does it have any errors when it starts? Have you tried restarting it?
-
Edit: I've misread the question; the following is an answer to how to create an API that lists the players on your server. There are a number of ways to do this: Query the ASE port (123 above the server port, e.g. 22126 for a server running on 22003) for the information (I'm not sure how the ASE protocol works, you'd have to research it), or Query the server via its HTTP port (here you would need to create a HTTP web access resource which responds with the list of players in an encoding the API client expects, e.g. JSON) (can trigger anti-flood/anti-spam countermeasures on MTA server side if IP is not whitelisted in mtaserver.conf, as it would try to request a fresh list every time anyone loads a page; ideas for cached storage of fetched data below) this requires allowing guest HTTP access to the server (can expose admin functionality to everyone if not careful, so limit admin/webadmin resource access to authenticated users only), or setting up a dedicated user and logging in with it (password is sent via HTTP authenticate headers in plaintext, unencrypted; can expose admin functionality to eavesdropper on network between API client and MTA server; so limit this users ACL/RPC to read only access) or Have the server regularly send updates to a web server and the web server keep a copy of the latest list of players, or Have the server track players on it and update a MySQL database that the webserver connects to. The answer to your question is generally no, unless you plan to run surveillance on the MTA global server masterlist, query every server's player list and create a comprehensive database of who plays on what servers, and then query such a database.
-
It's a syntax issue -- you're not supposed to use a colon to separate the key from the value in a table. The correct character is an equals sign: local messages = { message1 = " Some message", message2 = " Some message2", } I believe "<name> expected" is referencing OOP style calls like SomeObject:someMethod(), (the only use of the colon in Lua that I can recall of the top of my head), as if you wrote :someMethod() without any object name in front, but Lua expects a object name there.
-
Can you provide a screenshot/video of what your code currently produces, and an annotated screenshot of what you want to achieve? I tried running the code you provided to get an idea of what you're trying to do but the code is incomplete, lacks the definition of the render target (i.e. its size is missing), uses non-standard drawing functions, etc. I don't understand the use of string.len(core) here. String length = number of characters, which suggests horizontal scrolling but the positions scrolled indicate vertical scrolling. I also don't understand the variables used (please, name your variables, it makes helping so much easier): what are x2, y2, z1, z2?
-
Because the code uses get, credentials should be in the meta.xml like so: <settings> <setting name="hostname" value="" /> <setting name="username" value="" /> <setting name="password" value="" /> <setting name="database" value="" /> <setting name="port" value="" /> </settings> Now onto the code problem: mysql_connect is not a built-in MTA function, but rather a server module which you need to install to be able to use that function. Most modules today are quite deprecated because most of their functionality can be found built-in into MTA, for example, mysql_connect can be replaced with dbConnect. Indeed, all of the mysql_* functions in the code you provide can be replaced with appropriate db* functions. If you choose not to rewrite the code, you can try to install the module, https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL, but be aware, it was last updated in 2012. It is really old and may not even work anymore with the latest versions of MTA.