Jump to content

Zango

Discord Moderators
  • Posts

    681
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zango

  1. My guess is that you could use exports.mapmanager:getMapsCompatibleWithGamemode again - and retrieve the compatible maps for a deathmatch gamemode. Example: exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName('deathmatch')) You would need to decrement this list as well (you might want to create a function for it instead). From the snippet you posted, you can't change how the client renders the data in "poll". Example: function processCompatibleMapsList(t_Maps) if (not t_Maps) or (type(t_Maps) ~= 'table') then return false end math.randomseed(getTickCount()) if (#t_Maps > 9) then repeat table.remove(t_Maps, math.random(1, #t_Maps)) until (#t_Maps == 9) elseif (#t_Maps < 2) then return false, errorCode.onlyOneCompatibleMap end return t_Maps end function shuffleMapsList(t_Maps) for i, map in ipairs (t_Maps) do local int_swapWith = math.random(1, #t_Maps) local map_curMap = map t_Maps[i] = t_Maps[int_swapWith] t_Maps[int_swapWith] = map_curMap end return t_Maps end function startNextMapVote() exports.votemanager:stopPoll() if maybeApplyForcedNextMap() then return end local race_compatibleMaps, e = processCompatibleMapsList(exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())) if (not race_compatibleMaps) then return false, e end local dm_compatibleMaps, e = processCompatibleMapsList(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName('deathmatch'))) if (not dm_compatibleMaps) then return false, e end race_compatibleMaps = shuffleMapsList(race_compatibleMaps) dm_compatibleMaps = shuffleMapsList(dm_compatibleMaps) -- move both lists into one local mapsList = {} for _, map in ipairs (race_compatibleMaps) do table.insert (mapsList, map) end; race_compatibleMaps = nil for _, map in ipairs (dm_compatibleMaps) do table.insert (mapsList, map) end; dm_compatibleMaps = nil local poll = { title="Choose the next map:", visibleTo=getRootElement(), percentage=51, timeout=15, allowchange=true; } for index, map in ipairs(mapsList) do local mapName = getResourceInfo(map, "name") or getResourceName(map) table.insert(poll, {mapName, 'nextMapVoteResult', getRootElement(), map}) end local currentMap = exports.mapmanager:getRunningGamemodeMap() if currentMap then table.insert(poll, {"Play again", 'nextMapVoteResult', getRootElement(), currentMap}) end
  2. Zango

    NPC Paths

    Considering MTA's current architecture I doubt it. The server has no physical understanding of the world. It only distributes data from remote clients. If you map out the train tracks you can calculate how far the train was supposed to go. Using interpolation (interpolateBetween) you can get an approximate location from your calculated value with little math.
  3. From the snippet you posted, I can't tell you why your table "map" is nil. In the beginning of your function, you check to see whether "map" is 'false'. 'false' and 'nil' are different. Depending on your code (context this is used in), you could simply extend the check: function(map,rt,w,res,files,size,pos) if (not map) then waiting = true; return; else
  4. Please post the contents of the meta.xml file, your directory (what files are there?) and upload Pigface.dff.
  5. You can use a function such as string.gsub to search for "f/" and replace it with "ft. ". function formatTrackTitle (strTitle) return strTitle:gsub ('f/', 'ft. ') end
  6. The data returned has nothing to do with MTA. If you open the stream yourself, you'll find that it looks like that as well. It's how they chose to broadcast the songs on their radio.
  7. You might as well retrieve a player skin serverside. You only need to do this if you create a ped clientside. (and for whatever reason need it's model serverside)
  8. The place where you add your event and handle it, is the "listener". Triggering the event transfers the data to the function. Serverside: addEvent ('server_GetSkinData', true) addEventHandler ('server_GetSkinData', root, function (skinID) -- source refers to the player element who invoked this event -- update SQL end ) Clientside: function sendPedSkinToServer (ped) local int_skin = getElementModel (ped) if not int_skin then return end triggerServerEvent ('server_GetSkinData', localPlayer, int_skin) end Any arguments parsed to triggerServerEvent, after the first two, go as arguments to the handler function. What are you using the ped model for, on the server?
  9. When MTA loads a script, Lua checks for syntax errors and declares all variables and functions. If you place something outside a function, it's called in this process. But this stuff takes place before onClientResourceStart - which is the point where everything is ready. You need to move it into the function startMusic, at the bottom.
  10. Events can also be used to transfer data between the server and the client. Read on addEvent (allowRemoteTrigger) It's better practice to use getElementModel versus getPedSkin. In the future most of those functions won't exist and will be replaced by more generic ones.
  11. You are trying to bind onClientSoundChangedMeta to "song" which isn't initialised yet. Move the addEventHandler below song = playSound
  12. onClientSoundChangedMeta function onClientSoundChangedMeta (streamTitle) if streamTitle then outputChatBox (streamTitle) end return true end addEventHandler ('onClientSoundChangedMeta', sound_Radio, onClientSoundChangedMeta)
  13. local sound_Radio = playSound ('http://www.181.fm/winamp.pls?station=181-power&style=&description=Power%20181%20(Top%2040') function outputSoundMeta (sound) local tTags = getSoundMetaTags (sound_Radio) if tTags then for tag, value in pairs (tTags) do outputChatBox (string.format('Artist: %s | Title: %s', tag, value)) end return true end return false end addCommandHandler ("soundinfo", outputSoundMeta) This code will reveal that audio streams take use of stream_name as radio station title and stream_title as the currently playing data, which you want. Assuming this radio has formatted their songs consistently, you could use " - " to identify the track artist and title, respectively.
  14. Ensure that Pigface.dff exists among your other models, and that you added it to meta.xml If the issue persists, perhaps the model is corrupted. Find out by using DFF viewer.
  15. https://wiki.multitheftauto.com/wiki/GetSoundMetaTags
  16. Peds created clientside - the referring element and all associated data such as skin are only available clientside. You would have to call getElementModel on the clientside and transfer the value to the server. Players aren't "client" or "server" -side. Players and related metadata is available to remote clients and server.
  17. PHP provides the session functions for storing, identifying and accessing data related to a user, across pages. Using HTTP, you tell the requested server who you are, and what you want. The server will respond with data based on your request, but from that point on, and to your next query, the server doesn't know whether you left the website. Sessions is a technique where you "build a bridge" between these two or more visits from the same client to the server. The server stores the related variables in a file or database, and reinitialises them each time the client is identified. In MTA, the client and server communicates all the time. That's why the server is able to determine when the client left the server. In which case all references to the player are nulled and the event onPlayerQuit is fired. Global variables, or local variables initialised in a global context, exist in memory from the resource start to the resource stop. Each resource is run as it's own "instance", within it's own Lua virtual machine. There are numerous ways to share data across resources, for example element data, resource exports or events. Creating and triggering an event triggers it across all resources. What you would do is, in your skin system, create and attach your functions to an event, "onPlayerRegistered" In your registration, once completed, trigger the event "onPlayerRegistered"
  18. Zango

    animations

    There is nothing wrong with your code. Your player isn't in the team "criminal" or this team doesn't exist.
  19. I don't see any problem with the syntax when skimming your config. Is the correct permissions set for the configuration file? If the user running mta-server doesn't have sufficient rights it can't open the file. Set the owner of the file to the user you're running mta as, or make the configuration file executable by all users. If this doesn't fix it, there's a problem with your files contents. You could try using the default bundled in MTA then.
  20. Looks like you're lacking the readline library. Which OS and architecture are you running?
  21. There's a problem parsing mtaserver.conf. Probably due to incorrect syntax, please post the contents of the mentioned file in tags.
  22. Zango

    ACL Group

    Look at the function names you supply to addEventHandler, setSWAT and createAdminTeamOnStart does not exist. function createSWATTeamOnStart () SWAT = createTeam ( "SWAT", 0, 255, 0 ) end addEventHandler("onResourceStart", resourceRoot, createSWATTeamOnStart) function setAdminTeam() if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("SWAT")) then setPlayerTeam(source, SWAT) end end addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam)
  23. Zango

    Nametags

    How about nametags.lua
  24. onClientPlayerJoin wiki page: use onClientResourceStart attached to resourceRoot also, for crun (client variation of run) to work, you need to start the resource `runcode`
  25. There is no such function, however you can use sinus/cosine to calculate it based on the third rotation value, or you can use getElementMatrix. The wiki example already contains a function to get the point 5 meters ahead, perhaps inverse those values? function getPositionInBackOfElement(element) local matrix = getElementMatrix ( element ) local offX = 0 * matrix[1][1] + -5 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1] local offY = 0 * matrix[1][2] + -5 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2] local offZ = 0 * matrix[1][3] + -5 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3] return offX, offY, offZ end
×
×
  • Create New...