Jump to content

Skully

Members
  • Posts

    121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Skully

  1. Thank you to every open source developer who has contributed to this project since its initial release and made the last two decades of MTA possible.
  2. You are converting a string to a number, the value of code_descriptions is a string value and when a string is passed as a parameter to tonumber() it will attempt to convert it to a numerical value, for instance turning the string "2.1" into an integer. When a string cannot be converted, you get nil. If you want to show the description, you do not need to run tonumber() on result["table"]["code_descriptions"]. fetchRemote("[...]", function(data) local result = fromJSON(data) local code = tonumber(result["table"]["code_one"]) local descriptions = result["table"]["code_descriptions"] print(code) -- Outputs 113 print(descriptions) -- Should output "hello world" end, nil, true)
  3. You can use the onTrailerAttach event and detach the trailer as soon as this event is triggered. The only downside is you cannot simply cancel the event or detach the trailer immediately, instead you must use a timer that triggers after 50ms for it to be effective. function detachTrailer(theVehicle) local theTrailer = source setTimer(function() if isElement(theVehicle) and isElement(theTrailer) then detachTrailerFromVehicle(theVehicle, theTrailer) end end, 50, 1) end addEventHandler("onTrailerAttach", root, detachTrailer)
  4. There is no MTA debugging tool for VSC, to test your code you should run a local server and set your development mode to informational and errors with the debugscript command, this allows you to see all errors in-game, or refer to your server console.
  5. Skully

    [HELP] Fps

    Leave it at the default value, or you can implement a setting that can be toggled for players to reduce it just a little below the default (400). If I'm not mistaken, this setting takes into consideration what the player's client has set their draw distance too in MTA settings as well, so you shouldn't rely on this for the sole purpose of increasing FPS; if a player wants to increase framerate by draw distance, they can reduce it in their own MTA settings.
  6. This is not possible with just simple webhooks. You will have to create a Discord Bot and integrate it into MTA, you can use Discord.js to create the bot (or use an existing one) and implement the functionality to fetch the total number of members in a guild, with this you can connect your server to the bot or create an API endpoint to retrieve the total members.
  7. Skully

    [HELP] Fps

    If you are asking whether it impacts framerate - yes; you are increasing the maximum distance of area to be rendered in. As such, reducing the distance will increase framerate.
  8. The code I provided was a rough example on how to handle client-server sync. If you want to use the code for handling opening and closing a vehicle trunk, you can simply adjust the code below to be called from your GUI rather than from a /trunk command, additionally use getVehicleDoorOpenRatio/setVehicleDoorOpenRatio instead and execute it on the server so it automatically syncs it to every client. Client addCommandHandler("trunk", function() local theVehicle = getPedOccupiedVehicle(localPlayer) if not theVehicle then -- If the player is not in a vehicle. outputChatBox("You must be in a vehicle to toggle the trunk!", 255, 0, 0) return end local newState = (getVehicleDoorOpenRatio(theVehicle, 1) == 0) and 1 or 0 -- If the trunk ratio is 0, it is closed so we need to open it (value of 1), otherwise we need to close it (value of 0) triggerServerEvent("syncVehicleTrunkChange", theVehicle, newState) -- Notify the server to set the new door ratio. end) Server function handleVehicleDoorSync(newState) setVehicleDoorOpenRatio(source, 1, newState) end addEvent("syncVehicleTrunkChange", true) addEventHandler("syncVehicleTrunkChange", root, handleVehicleDoorSync)
  9. You can use SetPedWalkingStyle to achieve this.
  10. What you are requesting is known as synchronization, when a client executes a client-side function and you want to share that state across every other player, you must notify the server of the action so that it can tell all players of the change too. This can be achieved with events using triggerServerEvent and triggerClientEvent. For instance, the example below displays how a client executing /trunk will run the function setVehicleDoorState and then share it across to to the server which in turn makes it visible for all other players. Client addCommandHandler("trunk", function() local theVehicle = getPedOccupiedVehicle(localPlayer) if not theVehicle then -- If the player is not in a vehicle. outputChatBox("You must be in a vehicle to toggle the trunk!", 255, 0, 0) return end local newState = (getVehicleDoorState(theVehicle, 1) == 0) and 1 or 0 -- If the trunk is closed, set it to 1 (open) otherwise it must be open, so close it. (state 1) setVehicleDoorState(theVehicle, 1, newState) -- Set the trunk state for this client. triggerServerEvent("syncVehicleTrunkChange", theVehicle, newState) -- Notify the server to set the newState for every player. end) -- This function is called whenever another player toggles a vehicle trunk, it executes the function on this client to update the trunk state -- to the same as what the source player set it to. function updateDoorStateFromOtherPlayer(newState) setVehicleDoorState(source, 1, newState) end addEvent("updateVehicleDoorState", true) addEventHandler("updateVehicleDoorState", root, updateDoorStateFromOtherPlayer) Server function handleVehicleDoorSync(newState) for i, thePlayer in ipairs(getElementsByType("player") do -- For every online player. triggerClientEvent(thePlayer, "updateVehicleDoorState", thePlayer, source, newState) -- Trigger the event to set the vehicle door state to the newState provided. end end addEvent("syncVehicleTrunkChange", true) addEventHandler("syncVehicleTrunkChange", root, handleVehicleDoorSync) Alternatively to save yourself this hassle, if the function is shared as such is the case with setVehicleDoorState, then you can just execute it on the server-side in which case it will automatically be synced to every client.
  11. Hi there! This is a brief showcase of an advanced medical system I created as a part of my personal project roleplay gamemode; after completing this resource I took a short break and wanted to work on a small video project, I took that opportunity to create a showcase of the system and its functionalities. Feedback or any questions are always appreciated, thanks for checking it out!
  12. You can use the event onResourceStop to capture the moment a resource script is stopped, and onResourceStart for when it is started. As for saving your variable data into an XML file, there are a variety of XML functions you can use to create a XML file structure with nodes and save your data there, see the following example taken from the xmlSaveFile page: -- Creates a file named "new.xml" with root node "newroot" and childnode "newchild". function createFileHandler() local RootNode = xmlCreateFile("new.xml"," newroot") local NewNode = xmlCreateChild(RootNode, "newchild") xmlSaveFile(RootNode) xmlUnloadFile(RootNode) end addCommandHandler("createfile", createFileHandler)
  13. Can you show your meta.xml file and how you are importing these?
  14. Not sure if it still works with the latest version of MTA but Stage was also a good resource to create entire complex cutscenes.
  15. Why are you trying to run a .html file through Lua? To do this correctly, you need to have two seperate files; one for the web page and your client side Lua code which loads the web page itself, from your error it looks like everything is in one file as you have displayed it? You cannot run HTML code and Lua within the same file.
  16. Hey there, This is just a small showcase of how ATMs function as a part of the economy system, and some highlights of the primary features in the police system; these were created for my roleplay gamemode. I hope you enjoy! ATM System There are two types of ATMs that can be created: ones that support deposits and ones that don't - typically the ATMs that support depositing money are placed near banks. In the video below, you can see an example of withdrawing cash from an ATM, the process of depositing is the same except the animation just plays in reverse. There are also multiple ATM card types with different maximum withdrawal values for how much can be withdrawn from an ATM within the period of 24 hours. The ATM also features security such as automatically intaking the card if there are too many unsuccessful PIN attempts. The 'buttons' on the ATM are actually just dxDrawRectangle's created by the UI system and an event listener is triggered every time one of them is triggered, each button has its own element data so we can determine what key is being pressed. The animation for the money flowing in/out of the ATM is done by having seperate images for the cash flap and the money(the money image is actually always behind the flap out of view ready to come out!) so when we want to play the animation, the position of the flap image is raised using an easing function, and the same with the image of the cash moving down; then we simply listen for a click on the cash image to take it out and close the flap. ELS (Emergency Light System) There are multiple light patterns which exist for different vehicles, ranging from all emergency vehicles and also including others such as the Sultan, FBI Rancher, FBI Truck, etc. All strobe elements can be dynamically placed on vehicles in-game through a strobe editor. ALPR (Automatic License Plate Reader) This has the functionality to automatically search the plates of any vehicle that collides with the scanner hitbox, it automatically takes the vehicle's plates (if the vehicle has plates) and looks it up in the database for any existing flags, warrants, etc. and displays them on the vehicle information prompt, this lookup continues for every vehicle that passes and if a flag is found, the information is locked and retained on the display with an audio cue. There are two radars in the vehicle: one in the front and one in the rear, both can be customized to point to either the opposite lane that the vehicle is travelling on or the same lane. It also functions as a speedometer, any vehicle that drives past has its speed checked, and if the speed of the vehicle passing by is higher than what the 'Fast Limit' is as set by the player, then the violating vehicle's information is also locked and the ALPR operator is notified of the speed the vehicle was in excess of along with the direction they were heading - whilst all of this isn't demonstrated in the video, I might record and display this if there is interest for it. MDC System (Mobile Data Computer) The MDC is a fully responsive web application created with the intention of primarily being used on a web browser, though with Bootstrap it sizes quite nicely after being resized into a browser element placed into a small tablet on the screen, the small tablet version exists to allow quick navigation and usage though there is also a mobile data computer item in-game which can be used to open up a larger functional computer-style view for easier navigation. The web application itself is highly dynamic and created using PHP and Javascipt, most AJAX requests are made on the same page to prevent redirection such that the user can stay on the same page for each section (Civilian, Vehicle, Firearm, Property lookups) and also features a large amount of pop-up modals with a refreshing take on responsiveness.
  17. You could created a dummy ped and use GetPedAnimation on it after you shoot it with a sniper to fetch the animation that plays, it should give you both the block and animation. From the wiki: addEventHandler("onClientPreRender", root, function() local block, animation = getPedAnimation(localPlayer) dxDrawText ("CURRENT ANIMATION INFO...", 100, 300) if not block then block = "N/A" end if not animation then animation = "N/A" end dxDrawText("Block = "..block.." Animation = "..animation, 100, 315) end)
  18. Nametag visibility overhead is specific to each server if that is what you're referring to, this is a question you'll have to ask the server owner as it isn't related to the MTA client itself.
  19. Skully

    Help here

    onMarkerHit is a server-sided event, use OnClientMarkerHit client side, you can then use this to trigger an event on the server end to do what you need to. Keep in mind that you cannot use OnClientMarkerHit for markers created by the server.
  20. Skully

    [HELP]

    Look through the code and search for instances of the event handler onPlayerJoin for player's joining the server, and onClientResourceStart for whenever the resource starts.
  21. Use string.find to check what characters are in a string.
  22. Use this section to find developers and staff. https://forum.multitheftauto.com/forum/149-looking-for-staff/
  23. You should consult the creator of the resource or show some code/errors that you're getting.
  24. See my previous response: If you don't see it that way I do, then I respect your perspective - this topic is to catch the eye of those who are looking to get their hands on a new project - there is no harm or fault in trying.
×
×
  • Create New...