Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/03/22 in all areas

  1. It is unwanted network information. > > > setElementData. (getElementData doesn't use network) Every layer of information, means that you have less data to spare for future resources that also use the network. The servertimesync resource uses getTickCount(which Mkl explains) to synchronize time between the client and the server. Now all you have to do is send future time to the client, which will sets it's counter to the right time. Untested example, feel free to optimise it even more. Server -- set when a new round starts (NOT every second) local timeNow = exports.servertimesync:getServerTime() if timeNow then setElementData(resourceRoot,"lobbyEndTime", timeNow + 60000) end Client local timeNow = exports.servertimesync:getServerTime() if timeNow then local lobbyEndTime = getElementData(resourceRoot,"lobbyEndTime") if lobbyEndTime then local remainingTime = (lobbyEndTime - timeNow) / 1000 if remainingTime < 0 then remainingTime = 0 end dxDrawText("Time : " ..math.floor(remainingTime), 300, 300 ) end end
    1 point
  2. Hi, I'm not sure to understand. Do you want, when a player starts a "lobby", a timeleft which stops the game when it reaches 0? If yes, why don't you use setTimer ? To display the time, I would have use getTickCount() instead of using getElementData everyframe. Check the second example of https://wiki.multitheftauto.com/wiki/GetTickCount that counts time, same logic can be used to create a timeleft to diplay.
    1 point
  3. Vá na pasta onde seu MTA está instalado (pasta do MTA)\MTA San Andreas 1.5\MTA\config e acesse o arquivo coreconfig.xml Nesse arquivo, procure o parâmetro <show_unsafe_resolutions> e mude de 0 para 1. Salve o arquivo e inicie o MTA.
    1 point
  4. 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
×
×
  • Create New...