-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
In my opinion it is far more (beginner) user friendly. If you were to use a database as basis: - Everybody has to learn how to work with table relations. - Everybody needs a database edit tool before anybody in the server can be admin. I understand that you want more, but the [end user] is...
-
@Sorata_Kanda Example on line 3 shouldn't be working. You need the unpack function for that. (Which unpacks the table) local x, y, z = unpack(fromJSON(json) ) The last example should be working. Hmmm strange. Well this is why I use iprint: iprint(fromJSON(json)) I love to know with what I am dealing with.
-
Nope, a vector isn't a table. I am not exactly sure if they build this data type in C++ or it might be a meta-table. Not that it really matters. As long as you can work with them. Untested converter do local keys = {"x", "y", "z", "w"} function vectorToTable (vector) local newTable = {} for i=1, #keys do local key = keys[i] local value = vector[key] if value then newTable[key] = value else break end end return newTable end end iprint(toJSON(vectorToTable(Vector2(234,2434))), "\n\n" , toJSON(vectorToTable(Vector3(234,2434,454))), "\n\n" , toJSON(vectorToTable(Vector4(234,2434,454, 365))) )
-
--[[ OLD addEvent("warphal", true) addEventHandler("warphal",root,spawn) ]] local spawns = { {2014.47,1523.71,10.81}, {2023.47,1437.71,10.81}, {2121.47,1481.71,10.81}, {1928.47,1482.71,10.81} } function spawn () local rnd = math.random(#spawns) -- Using client pre-defined variable setElementPosition ( client, spawns[rnd][1],spawns[rnd][2],spawns[rnd][3]) iprint("spawn function has been called") -- debug line end addEvent("warphal", true) -- moved to here addEventHandler("warphal",resoourceRoot, spawn, false) -- receive the event only for the resourceRoot element. And not it's children: false = getPropagated triggerServerEvent ("warphal", resourceRoot) -- using the resourceRoot as source element resourceRoot is the main element created by the resource. Every element created by resource is attached to it. Pre-defined variables:
-
destroyElement(SapphireTeam)
-
1. Not really. It probably has multiple damage layers. 2. You can't cancel damage serverside, as that event triggers much too late. There is connection delay (ping). By the time you reset the health, the player might have been (insta) killed already. Possible solution for an overwrite: https://wiki.multitheftauto.com/wiki/OnClientExplosion cancelEvent() https://wiki.multitheftauto.com/wiki/CreateExplosion
-
Your calculations are a bit strange For example this line: x = rWidth - dxGetTextWidth(v) / table.getn(columns) - 1 --1 dxGetTextWidth(v) / table.getn(columns) --2 rWidth - --[[result of 1]] --3 --[[result of 2]] - 1 --4 x = --[[ result of 3]] Is this really the math order you intended? ---------- For example you have a max with of 500 pixels. containerWidth = 500 And you have 8 column (names). columns = {{},{},{},{},{},{},{},{}} First step. Calculate the width of the text per column! Second step. Calculate the total width of all text items together. (So that you can scale down [and up] the columns) Which is for example 450px. containerWidth / 450 = 1.111111... (scale factor!) Or higher, 600px containerWidth / 600 = 0.833333.... (scale factor!) If you multiply these values with your columns then shouldn’t they fit perfectly? Margins around? containerWidth_ = containerWidth - margin * 2 Margins in between? containerWidth_ = containerWidth - margin * (#columns - 1) Fixed column size? containerWidth / #columns It isn't that hard, just do it step by step by step by step.
-
https://wiki.multitheftauto.com/wiki/DxDrawLine3D See example on that page.
-
That really depends how you compare and use it. 1 on 1, sure it can be 30x faster. But aren't you comparing two different things? A function vs just an empty variable. If you take a look at dxDraw functions, it is obvious that they are being called every frame. Incompare to call getElementData there isn't much of a difference. The data is bound to the element, it is not like you have to search in all elementdata for it. Example: You use 60 dx functions each frame and 1 time a getElementData function. How much will we gain from optimize this function? The real danger of elementdata is in using it, without knowing what mechanisms are activated behind it, after it is SET.
-
After you destroyed an element. A saved userdata reference will remain inside of the Lua memory. A userdata reference is not an element itself. It is a value that can be used to refer to an element in MTA. ------ It is like having a cat which you named `miauw`. After it died of old age, you can still refer to your precious cat by calling it's name. `miauw` I have dinner for you! (calling function: giveCatFoot(cat)) And then your grandma reminds you of the fact that it has already died... (warning: element does not exist) ------- That is sort of how userdata references work. See function isElement for userdata validation. isElement
-
outputChatBox("|SWAT| ["..Rank.."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 000, 128, 192, true ) First layer of paint RGB = RED, GREEN, BLUE Second layers of paint: #HEX Tool: http://www.javascripter.net/faq/rgbtohex.htm
-
If that is the case, then I think you picked the wrong project. Be realistic and do smaller projects first. @gujuk2 Instead of a loading bar, you can also display a loading image or loading text. Check this example: https://wiki.multitheftauto.com/wiki/IsTransferBoxActive It is used to detect if the transferbox(download bar) is active.
-
-- serverside local resources = getResources () local resourceCount = #resources setElementData(resourceRoot, "resourceCount", resourceCount) -- clientside local resourceCount = getElementData(resourceRoot, "resourceCount") iprint("resourceCount:", resourceCount)
-
[...] You can do that in the meta.xml. <download_priority_group>1<download_priority_group /> If not set, the download priority group for a resource defaults to 0. If this is set higher than 0, then the resource will be downloaded and started on the client earlier than other resources. If set to less than 0, the resource will be downloaded and started on the client later than other resources. https://wiki.multitheftauto.com/wiki/Meta.xml
-
Use this event instead: https://wiki.multitheftauto.com/wiki/OnClientExplosion
-
It can be in another file but it has to be in the same resource. Making a connection just with a new + empty database will not solve your problem. Containers(tables) for the data have be generated before you can store or load data. If the connection function isn't in any of the files + there are no tables in the database, then it is recommended to consider it unfixable in case of not going to hire a paid scripter.
-
What about other players in the same server? What about you killing peds inside of a server that isn't yours? Did you modifi any mods or textures? Ask these kind of questions to yourself.
-
local didInsult = false -- State insult or not. for _, sMessage in pairs(insults) do if message == sMessage then didInsult = true -- ":O yea" Set insult state to true! break -- stop looping! end end (didInsult and functionA or functionB)() -- execute A or B -- How does this work? -- ??? Which function to use: didInsult and functionA or functionB -- didInsult == true = functionA -- didInsult == false = functionB -- (...)() < execute it! @Bilal135
-
It means that the connection to the database has been failed. This connection is used for the code and the database to be able to communicate with each other. In your code you should be looking for this function: dbConnect https://wiki.multitheftauto.com/wiki/DbConnect That is where the real problem starts. You have either received an error about the dbConnect function or the dbConnect function has never been called.
-
Are you looking for this? Disable: https://wiki.multitheftauto.com/wiki/ToggleControl Weapon use: https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponFire Or weapon switch: https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponSwitch (With matching example from your current request)
-
There are no events for wanted levels. But you can make them manually by triggering an event at the moment you set the player his wanted level in the gamemode.(this has to be done in the gamemode) You can also use this line there: triggerClientEvent(v,"StartEvadeTimer", v) (Just make sure to match the variable names with the gamemode)
-
Line 26: end, 1000, 0) The 0 at the end means infinity. If you write it like this: end, 1000, 1) It will only execute the code one time. If that is not the solution you want, then how about use element data to prevent re-triggering? Which you are already familiar with.(line 28)
-
Feel free to ask questions about the code! Manually debugging it makes understanding code a lot easier:
