-
Posts
2,947 -
Joined
-
Last visited
Everything posted by JR10
-
https://community.multitheftauto.com/index.php?p= ... ls&id=8835 Stolen. Original: https://community.multitheftauto.com/index.php?p= ... ls&id=2847 DONE
-
When a timer is done it destroys itself, so killTimer ends spitting out errors. isTimer checks if a timer is still valid.
-
Rename arrester parameter in onPlayerArrested function so it doesn't override the global one. Also, remove it from cuffed.
-
OOP coordinates functions do not return 3 values, it returns a Vector3 object that contains the coords: function f4_get_pos( button, press ) if button == "F4" and (press) then --local x, y, z = getElementPosition(localPlayer) <--This way it works, but no oop local pos = localPlayer.position <-- throws the error outputChatBox(pos.x) outputChatBox(pos.y) outputChatBox(pos.z) end end addEventHandler("onClientKey", getRootElement(), f4_get_pos) Make sure OOP is enabled in meta.xml.
-
You can easily sort players with something like this: table.sort(tab, function(a, b) return getCountry(a) < getCountry(b) end)
-
You didn't specify the player to bind the key for. Perhaps loop through the players and bind it for him? Although the logic is kinda weird, why would you bind a key to change the handling of all the vehicles. function setHandling() for index, player in pairs(getElementsByType('player')) do bindKey(player, "k", function() for i, veh in ipairs(getElementsByType("vehicle")) do if getElementModel(veh) == 451 then setVehicleHandling(veh, "mass", 1600) setVehicleHandling(veh, "turnMass", 3921.3) setVehicleHandling(veh, "dragCoeff", 1.8 ) setVehicleHandling(veh, "centerOfMass", { 0, -0.4, 0 } ) setVehicleHandling(veh, "percentSubmerged", 75) setVehicleHandling(veh, "tractionMultiplier", 0.75) setVehicleHandling(veh, "tractionLoss", 0.85) setVehicleHandling(veh, "tractionBias", 0.52) setVehicleHandling(veh, "numberOfGears", 5) setVehicleHandling(veh, "maxVelocity", 200) setVehicleHandling(veh, "engineAcceleration", 8.8 ) setVehicleHandling(veh, "engineInertia", 10) setVehicleHandling(veh, "driveType", "rwd") setVehicleHandling(veh, "engineType", "petrol") setVehicleHandling(veh, "brakeDeceleration", 10) setVehicleHandling(veh, "brakeBias", 0.53) setVehicleHandling(veh, "ABS", 0) setVehicleHandling(veh, "steeringLock", 35) setVehicleHandling(veh, "suspensionForceLevel", 1.3) setVehicleHandling(veh, "suspensionDamping", 0.12) setVehicleHandling(veh, "suspensionHighSpeedDamping", 0) setVehicleHandling(veh, "suspensionUpperLimit", 0.28 ) setVehicleHandling(veh, "suspensionLowerLimit", -0.12) setVehicleHandling(veh, "suspensionFrontRearBias", 0.38 ) setVehicleHandling(veh, "suspensionAntiDiveMultiplier", 0) setVehicleHandling(veh, "seatOffsetDistance", 0.2) setVehicleHandling(veh, "collisionDamageMultiplier", 0.24) setVehicleHandling(veh, "monetary", 25000) setVehicleHandling(veh, "modelFlags", 0x40000000) setVehicleHandling(veh, "handlingFlags", 0x10200008 ) setVehicleHandling(veh, "headLight", 0) setVehicleHandling(veh, "tailLight", 1) setVehicleHandling(veh, "animGroup", 0) end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), setHandling) Now make one onPlayerJoin as well.
-
And what is the problem? You just need to store what the player buys in a table (client-side would work) and when he buys, loop through the table and give him the weapons taking money away (make sure to check if he can afford the weapons, since we're using client-side).
-
With the things you want, you should be using a dx library. Anyway, you could create an image with the width of the window, and then create the elements on top of it.
-
Not really useless, it can be useful in some cases. It's widely used in admin.
-
This is all very hacky and unnecessary. You shouldn't be trying to resume a coroutine without knowing its status, or how many times it can be called.
-
First of all, you don't need to check if file is nil, it will either load or create. It's getting duplicated because, if found, you're destroying the xml file's node, which won't work, you need to destroy the child node. This is not needed as you can just update the node if it is found. But you keep finding the same child over and over again, destroy it and then recreate it. You can do something like this: addEventHandler ( "onClientResourceStop", resourceRoot, function ( ) local file = xmlCreateFile('@Chat.xml', 'Chats') if not file then return end for i, v in pairs ( Chats ) do local child = xmlCreateChild(file, 'chat') xmlNodeSetAttribute(child, 'name', v) xmlNodeSetAttribute(child, 'enabled', tostring(isset(eTable[v]))) end xmlSaveFile(file) xmlUnloadFile(file) end )
-
You're right. Yes, if you have 2 coroutine.yield, it will stop twice and will continue from that very respective yield. The idea is actually very simple, a call to coroutine.yield will pause and wait for a return, which only happens through coroutine.resume, much like using executeSQLQuery or dbPoll with -1, it pauses everything and wait for the result and then continues with the rest of the code.
-
Check if weapon is equal to 37, which is the death reason for being burnt. https://wiki.multitheftauto.com/wiki/Death_Reasons
-
Good work! I hope that this tutorial will help players and other life forms install MTA correctly. I know that the setup executable's size (a staggering space of 21.2 MB as you eloquently put it) can be a bit discouraging, but it's really worth it.
-
I guess it's Lua (MTA:SA) or something similar, make sure to follow the instructions to the letter. Try restarting sublime after installing the package.
-
dbPoll with -1 is strongly discouraged. Use callbacks instead.
-
The language is MTA-Lua, not just Lua. You then have to change the color scheme as well.
-
string.find(string, "#%x%x%x%x%x%x", 1) The last parameter shouldn't be true, this will treat the text as plain, which is not what he wants here.
-
Probably won't happen. He already mentioned that he dropped its development, and is using sublime instead.
-
There is an object removal tool in the map editor. It's at the bottom left.
-
Did you take a look at this one? viewtopic.php?f=91&t=30077
-
This might explain what CrystalMV meant: local db_coroutine = coroutine.create(function() dbQuery(callback, database, "SELECT * FROM table"); local queryHandle = coroutine.yield(); local result = dbPoll(queryHandle, 0); -- more code end); coroutine.resume(db_coroutine); function callback(queryHandle) coroutine.resume(db_coroutine, queryHandle); end This is what happens: you first create your coroutine by passing it its main function, we then start the coroutine by running coroutine.resume, our function gets executed, the first line (dbQuery) gets called and then the coroutine yields (waits until another call to coroutine.resume is ran). In our callback, we run coroutine.resume once more passing it our queryHandle, which will be sent to coroutine.yield and the rest of the function will get called. It's more than okay if you don't understand any of that, coroutine and multithreading are not exactly simple. Remember that all you really need is to just use callbacks. More links for coroutines tutorials: http://www.lua.org/pil/9.html http://lua-users.org/wiki/CoroutinesTutorial