Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 15/07/21 in all areas

  1. MTASA Typescript I am developing utility packages for transpiling TypeScript into an MTASA-compatible Lua code. I would like to share that project to receive some suggestions and, I believe, to help someone in resource writing. Why Lua is not so good Classes. Lua does not support classes (syntax) from scratch. If you want to write OOP code with your own classes, you have to use metatables to implement class objects behavior. That's make the source code more complicated, than it could be. Hints (from your IDE). Lua is dynamic typed language, therefore, it's hard to determine, what the variable is and, hence, IDE cannot hint you function declarations, object methods and etc. MTASA Lua is still 5.1 (it is not developing). Lua, like any programming language, is developing, however MTASA core strongly linked to Lua 5.1. Why TypeScript There is TypeScriptToLua project. My project is based on TypeScriptToLua (I use it as a dependency). General purpose of TypeScriptToLua: convert (transpile) typescript code into Lua code. Thus, you can use TypeScript without modifying MTASA core. You are available to not use types in some parts of code (you are not restricted to use types everywhere). The TypeScript is being developed by Microsoft and, I believe, that TypeScript will be alive for several years. When to not use TypeScript (where to use Lua instead of TypeScript) 1. If you are not familiar with Lua or with scripting in general. 2. if you are writing simple script. Introduction Video I have made the video, where I describe Lua disadvantages, explain, why I have chosen TypeScript (and language transpiling) and write an example. Few word about mtasa-lua-types I have created this package to provide MTASA declarations in TypeScript. If you would like to create a resource, you haven't to install it manually, just use the boilerplate. Quick Start I have provided the tutorial here: https://github.com/mtasa-typescript/resource-boilerplate. So, you have to install NodeJS and download my boilerplate. And,... you are ready to code. If you have any ideas, issues or suggestions -- post them below, or in youtube comments, or in github issues ? Example code (from youtube video) import { Player } from 'mtasa-lua-types/types/mtasa/server/oop/Player'; import { mtasa } from 'mtasa-lua-types/types/mtasa/server'; interface GithubCommitApiResponse { commit: { message: string; } } mtasa.addCommandHandler('getcommit', function(player: Player, cmd: string) { mtasa.fetchRemote( 'https://api.github.com/repos/mtasa-typescript/mtasa-lua-types/commits?per_page=1', (data: string) => { const json = mtasa.fromJSON(data) as GithubCommitApiResponse mtasa.outputConsole(`The last commit message: ${json.commit.message}`) } ) }) Future plans - Github bot, that will crawl mtasa wiki and update mtasa-lua-types continuously - Add better hinting for `addEventHandler` function Links WebSite: https://mtasa-typescript.github.io/ GitHub MTASA TypeScript Projects: https://github.com/mtasa-typescript Resource Boilerplate: https://github.com/mtasa-typescript/resource-boilerplate Resource Example: https://github.com/mtasa-typescript/resource-example
    1 point
  2. PORT FORWARDING GUIDE In order to host your own MTA Server, you'll need to forward ports for others to be able to see your server, and join it. If ports are not forwarded properly, other players cannot connect, and your server will feel empty. Additionally, the output of "openports" command in server console would be: Testing ports... Port 22126 UDP is closed. Players can not browse! Port 22003 UDP is closed. Players can not join! Port 22005 TCP is closed. Players can not download! Instructions Locate your network's router or modem physically and look on the back to read its model number/type, then search on Google: as there will always be an official manual and tailored guides to forward ports. You'll have to forward (and possibly port-trigger) MTA server ports as they are defined in mtaserver.conf (ex. C:\Program Files (x86)\MTA San Andreas 1.5\server\mods\deathmatch > mtaserver.conf), if said file is unmodified then these are the default ports to forward: 22003 UDP (main server port) 22126 UDP (because the server browser port is value from <serverport> + 123, it can differ based on main server port which is 22003 by default) 22005 TCP (internal HTTP resource download port) If you can't find your router's make and model, you can try a generic method of forwarding (of which details can deviate), follow these instructions: 1) open cmd (commandprompt) from start > type 'cmd' in search or start > run > cmd, make sure to run "as Administrator" Type this in cmd: ipconfig /all It will output a table of addresses; locate and copy "Default gateway" and "DHCP server" addresses into a text file. 2) open your web browser, and paste & navigate to both addresses like you would if that IP address was a website. Examples: http://192.168.2.1, http://192.168.2.254 (also, both are very common) You will most likely end up on the configuration interface (or login screen) of your router. If you need to login, look if they are on back of your router (sticker placed on it) and if they're not, search this on Google: If there's no known login credentials for your router, try (a combination) of these, both as username (account) and password: username: admin password: admin username: blank (don't enter) password: admin username: blank (don't enter) password: blank (don't enter) * press login without entering anything, it may ask you to set a new password immediately username: provider/ISP name (abbrevation) password: provider/ISP name or blank, or your local translation of the word 'wireless' or 'internet' for the places where username 'admin' is mentioned, you should also try the variant 'Administrator' and 'administrator' (with and without capital letter) As those are the most common login credentials, trying them all has a success rate of 80%. If none of them work, call your ISP, or do a more extensive web search, it should definately be documented (or figured out by someone else on the web) how to log in to your router's configuration panel. Also try searching in your own language. 3) If you successfully logged in, you'll see the configuration interface. It has plenty of tabs for various settings, you should focus on finding the ones relevant for port-forwarding. Now we're going to actually forward the ports: - Click each category (for example: Network, advanced, security/firewall, administration) until it folds out and shows something like "Port forwarding" or "Applications". It doesn't hurt to be scrolling the categories, even in places you don't expect the forwarding page to be, until you found it. It should be there. If you found it, then create a new rule/port number entry and link the correct protocol (or if you don't get it, "both" UDP and TCP") as the corresponding type is listed earlier in my post, up here. Reminder/TLDR: by default, they are 22003 UDP, 22126 UDP, and 22005 TCP. If it asks for port ranges, do it like this: 22003-22003, 22126-22126, 22005-22005. If you don't see a list or form that fits this description, but rather have an "Applications" tab, then go there and create a new entry. Name it "MTA Server" and enter in the correct ports, most often as ranges. Fill out everything that it requires to save, and save & apply. Note: Make sure to reboot your router after setting up the forwarding (or after each troubleshooting step later in this tutorial). 4) Major pitfall (cause of problems): If the forwarding entries table has a field that refers to the client (PC you're going to use for hosting MTA server) by MAC address or local IP address (192.168.x.x), then add it so it will link the forward, as the ports will only be forwarded on said PC If it allows you to select and link a device from a list (most often appearing as computer names), then do so. Otherwise, use the MAC address given in the earlier ipconfig /all command output, or if it asks for local IP address only, then take it from the same place, but directly afterwards you should take steps to ensure said local IP will be static to your host PC, because otherwise it will work only once or randomly (when your PC happens to "lease" said IP, getting it assigned). To set the static lease, find a category relevant to "DHCP server" or gateway settings, in your router configuration panel tabs. Enter the current local IP address (which you entered in the forwarded ports table too) and your network card's MAC address from the previously mentioned command output. Apply & save. Now, your forwarded ports should (keep) working on said PC which will be used to host MTA server. Restart your router. Test if MTA Server has its ports forwarded by starting it up and writing "openports" into the server console, or alternatively with https://nightly.multitheftauto.com/ports TROUBLESHOOTING If it doesn't work, go back into your router configuration and try these workarounds: 1) Locate the internal router firewall settings and lower its level (like, set it to Low so it's less aggressive) or disable it. 2) Make sure MTA server isn't being limited or having its traffic blocked by the firewall on your host PC. If you have a third-party firewall (or complete security product with both anti-virus and firewall or 'internet security'), open it and whitelist MTA Server.exe in a new or existing rule, set it to allow all traffic and activities from it. If this doesn't make it work, completely and temporarily disable the security software to try again and see if the issue was related. If MTA server now works, scrutinize your PC firewall's settings again or use another. If you don't use such security software, or you do but the last steps didn't work, then also check Windows Firewall (it can even run together with your security software firewall which means you gotta whitelist on both). Go to start menu > type "Windows Firewall" or "Windows Defender Firewall" or alternatively Control Panel > Windows Firewall ("with Advanced Security") and then go to its advanced settings. Now, whitelist the MTA Server.exe process like previously explained, in Windows Firewall (both inbound and outbound connection categories) If none of the above options work, you will have 3 last resort steps to take, in sequence: - See if something called "port triggering" is in your router's configuration panel. If it is, then it possibly relies on it for forwarding. "Trigger" the same ports that you "forwarded" earlier, but also keep the forwarding entries. - Add the host PC to DMZ zone. Find the relevant setting in the router configuration interface, most often it's under the "Firewall" or security categories. Now add your local IP or MAC address to make it a DMZ host. *Note: enabling DMZ basically opens all ports, exposing your host PC to the internet and therefore presenting a security risk. This step is most suitable to probe where the problem is; if it suddenly works, then you most likely did something wrong in the process of forwarding. It's not advised to settle for it and keep DMZ enabled on your device. If even DMZ doesn't make it work (given that your forwarding & DMZ device is properly pointing to the host PC, as explained in the DHCP lease/static local IP chapter up in this topic), then the problem is more likely to be with your PC and its network configuration, or otherwise the network infrastructure: it's possible that the router you're configuring (forwarding in) isn't the only device between your PC and the network line that goes to your house. If there's a second router, network (edge) switch, or modem-like router that is between the internet signal and the main wireless (WiFi) router, like is sometimes the case, then you may need to forward ports on both of them and eventually trigger ports to the second router after forwarding them on the directly connected modem. For more information on that scenario, open below spoiler: If you don't have a second router/modem, DMZ doesn't make it work, and neither did any of the forwarding & port triggering instructions listed in this topic (so basically you forwarded and also tried all the listed workaround and troubleshooting methods, including reviewing your firewall settings), then there's a good chance you're still doing something wrong. Consult with someone you know is experienced with networks or technical matters (IT) in general, and ask for help or advise. The ultimate last resort, also in the case you're not doing anything wrong, is calling your ISP (internet provider) and describing the problem and steps taken. You could also ask for a new router, the latest model issued to new customers. However, as I indicated, the chance it's on your and not on their end, is higher. I hope this guide helped. I still advise to stick to the router model-specific forwarding instructions that can be found on the web/internet provider's documentation, rather than using my generic methods for the steps from logging in to actually forwarding the ports. I cannot guarantee you'll succeed with the generic guide for the millions of router devices that exist, it's simply a culmination of personal knownledge.
    1 point
  3. Hello Currently you can use the resource `object_preview`. Wiki page: <https://wiki.multitheftauto.com/wiki/Resource:Object_preview> Community page: <https://community.multitheftauto.com/index.php?p=resources&s=details&id=11836>
    1 point
  4. Opa, foi mal a demora @Boechat. Você precisa instalar o Node.js na sua máquina (ou seja lá onde você irá hospedar).
    1 point
  5. Olá, tudo bem? A partir do momento que ele iniciar a patrulha use: setElementData Logo após faça uma verificação usando if, se ele estiver com a data caso ele estiver utilize o: setTimer criando uma função dentro dele aonde utiliza o: getPlayerMoney entregando o dinheiro desejado. Crie outra função aonde verifica se o jogador quitou ou caiu do servidor utilizando: onPlayerQuit e cancelando o evento utilizando: cancelEvent e retirando a data que a função setou nele. Bom acho que é isso, Tenha uma Boa sorte!
    1 point
  6. i've encountered many, many, many people who complain about the current toplist system People cluttering it is indeed an issue and something needs to be done urgently imo.
    1 point
×
×
  • Create New...