-
Posts
121 -
Joined
-
Last visited
-
Days Won
3
Skully last won the day on October 18
Skully had the most liked content!
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Skully's Achievements
Sucka (13/54)
39
Reputation
-
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.
- 81 replies
-
- awesomeness
- multi theft auto
- (and 6 more)
-
Skully started following save variable , [HELP] tonumber result not working , [HELP] Disable automatic trailer attach and 6 others
-
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)
-
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)
-
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.
-
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.
-
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.
-
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.
-
Make a client side function visible to Others
Skully replied to Heshan_Shalinda_eUnlock's topic in Scripting
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) -
You can use SetPedWalkingStyle to achieve this.
-
Make a client side function visible to Others
Skully replied to Heshan_Shalinda_eUnlock's topic in Scripting
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. -
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!
-
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)
-
Can you show your meta.xml file and how you are importing these?
-
Not sure if it still works with the latest version of MTA but Stage was also a good resource to create entire complex cutscenes.
-
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.