Jump to content

Forums

  1. Multi Theft Auto: San Andreas 1.x

    1. Support for MTA:SA 1.x

      HELP! HELP! Need help? Post here.

      54.9k
      posts
    2. User Guides

      These guides are a good place to start learning how to achieve certain things within MTA in an efficient and well mannered way.

      11
      posts
    3. Open Source Contributors

      This space is for contributors to discuss the development of MTA. No user suggestions/support.

      1.3k
      posts
    4. Suggestions

      Suggestions and requests go here. Please note that actual feature requests must be filed on our GitHub.

      7.7k
      posts
    5. Ban appeals

      Use this forum to appeal your GLOBAL MTA:SA bans. Permanent bans only - appeals for timed ones (eg. 24 hours) will be refused.

      Do not use it for appealing server-specific bans as we do not have power over these specific servers.

      4.6k
      posts
  2. General MTA

    1. News

      News and updates on Multi Theft Auto.

      9.8k
      posts
    2. Media

      User-made screens and movies go here.

      4.5k
      posts
    3. Site/Forum/Discord/Mantis/Wiki related

      Share your comments & concerns about our services.

      5.6k
      posts
    4. MTA Chat

      MTA related chat that is NOT support related!

      2.1k
      posts
    5. 330.3k
      posts
  3. MTA Community

    1. Scripting

      All Lua scripting topics related to Multi Theft Auto.

      261.2k
      posts
    2. Maps

      Discussions for maps on various gamemodes.

      13.4k
      posts
    3. Resources

      Everything else about resources.

      28.5k
      posts
    4. Other Creations & GTA modding

      This section includes things such as GUI themes, forum userbars, user-created MTA logos, etc. Also contains topics which cover general GTA modding areas that can be used in MTA, such as modelling.

      2.5k
      posts
    5. Competitive gameplay

      Discussions about various MTA-related competitive gameplay events. Also gang (clan) forums.

      26.7k
      posts
    6. Servers

      Looking for a server to play on? Looking for someone to host your server? Looking for a place to discuss with other server owners? Here's where to look.

      15.6k
      posts
  4. Other

    1. General

      Non-MTA discussions. Anything you want.

      38.1k
      posts
    2. Multi Theft Auto 0.5r2

      Discussion regarding Multi Theft Auto 0.5r2 for GTAIII and Vice City.

      672
      posts
    3. Third party GTA mods

      Showcase for single player mods and requests.

      812
      posts
  5. Archive

    1. 144k
      posts
    2. Trash

      These posts have broken forum rules. They are stored here temporarily so offending users can see what they have done wrong.

      2.6k
      posts
  • Posts

    • For multiplayer you have to store data for each player. And one of the ways to do that is using tables.   Here some basic functions you could use. Init the storage first: initPlayerData (onPlayerJoin) And after that you can set and get data from the table, for each player: getPlayerData, setPlayerData When a player disconnects: deletePlayerData (onPlayerQuit)   ---@type {[userdata]: {[string]: unknown}|nil} local playerDataCollection = {} ---@param player userdata ---@param key string ---@return unknown|nil function getPlayerData(player, key) local playerData = playerDataCollection[player] if not playerData then return end return playerData[key] end ---@param player userdata ---@param key string ---@param value any function setPlayerData(player, key, value) local playerData = playerDataCollection[player] if not playerData then return end playerData[key] = value end --- Create a storage table for data of a specific player ---@param player userdata function initPlayerData(player) if playerDataCollection[player] then return end playerDataCollection[player] = {} end --- Remove all player data and remove it's storage table ---@param player userdata function deletePlayerData(player) if not playerDataCollection[player] then return end playerDataCollection[player] = nil end        
    • Thank you, sorry to bother, but what recommendations do you have to work better in multiplayer, i was hoping every player could do the stage and they're time would be outputed to chat so everyone can see.
    • Well friends, it's been a few years, someone must have been able to find a reliable source for GTA V to find
    • https://imgur.com/a/IQIVCBo4 and 6 files are encrypted and i dont know why it isnt working
    • Your initial code looked fine except for a duplicated message when you are in the marker: Stage time: Stage finished! Time:   Here you have an alternative version + debug lines so that you can validate what is wrong. View in debug console: /debugscript 3   Also keep in mind that this code will not work very good in multiplayer, as startTime, startMarker and finishMarker are shared between all players.   You can ignore the ---@ annotations, those are helping me to automatic validate your code. (and perhaps help you to improve readability)   ---------- -- Add to top of script (local's making sure other scripts can't modify these values by accident) ---@type integer local startTime = 0 ---@type userdata|nil local startMarker ---@type userdata|nil local finishMarker --------- -- ... -- --------- ---@param player userdata function checkStageProgress(player) iprint("Validate player", player, isElement(player) and getElementType(player)) if not isElement(startMarker) or not isElement(finishMarker) then iprint("Not startMarker:", isElement(startMarker) and "It exist" or "does not exist", "or not finishMarker:", isElement(finishMarker) and "It exist" or "does not exist") return end if not raceInProgress then iprint("Race is not in progress") local startX, startY, startZ = getElementPosition(startMarker) local playerX, playerY, playerZ = getElementPosition(player) local distanceToStart = getDistanceBetweenPoints2D(startX, startY, playerX, playerY) if distanceToStart <= 3 then raceInProgress = true startTime = getTickCount() -- Start counting time outputChatBox("Stage started!", player) end return end ------------------------- -- Race is in progress -- local elapsedTime = math.floor((getTickCount() - startTime) / 1000) if isElementWithinMarker(player, finishMarker) then outputChatBox("Stage finished! Time: " .. elapsedTime .. " seconds.", player) raceInProgress = false return end ----------------------------- -- Player is not in marker -- outputChatBox("Stage time: " .. elapsedTime .. " seconds.", player) end    
×
×
  • Create New...