-
Posts
6,089 -
Joined
-
Last visited
-
Days Won
216
Everything posted by IIYAMA
-
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:
-
local allSkins = getValidPedModels() -- get all skins, (this only has to be executed one time) do -- DO this when pressing a button local index = 1 local skin = getElementModel(ped) local nextButtonUsed = true -- did I press right(true)? Or left(false) -- find the (new) skin index from the table for i=1, #allSkins do if allSkins[i] == skin then index = i + (nextButtonUsed and 1 or -1) break end end -- Index not matching the table? Adjust! if index < 1 then index = #allSkins elseif index > #allSkins then index = 1 end -- set the model setElementModel(ped, allSkins[index]) end
-
@Tebex The event system is created for that purpose. Use the addCommandHandler in one resource and pass this information global around all the resources that need it. (Or even fire the event even without addCommandHandler) Event functions serverside: https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions#Event_functions You can also use export functions. But you have to be very specific about: between which resources you are communicating(?) https://wiki.multitheftauto.com/wiki/Call
-
Using a named function directly as an anonymous function is not allowed in lua: setTimer(function trigger(player) (So remove trigger) local wantedLvl = getPlayerWantedLevel (root) Getting the wanted level of the root element, Hmm, is the root that evil? Maybe you would have more luck if you get it from each player? triggerClientEvent(player,"StartEvadeTimer",player) Triggering to a player in the server every 1 second? Should be fine if everybody does have fast internet and ping under the 50... but we both know that isn't the case in MTA. (No UDP trigger event support, /me crying...)
-
Subtract the ped-target-start position from the ped-target-end postion(or hit position) https://wiki.multitheftauto.com/wiki/GetPedTargetStart https://wiki.multitheftauto.com/wiki/GetPedTargetEnd And then make a vector of it + normalize it: https://wiki.multitheftauto.com/wiki/Vector/Vector3#getNormalized If the vehicle is at a remote location, then use instead of the ped start position, the vehicle position and do the same steps. (You might want to consider using the hit location of the event instead of the ped-target-end position.)
-
That will not help you understand what the code does, or do you have some magic for that? This code does: Defining the animation duration Calculate the time when the animation should end. Getting the time now. Calculate the amount of animation-time left. Calculate the progress of the animation. The progress is a value from 0 t/m 1. 0 = 0%, 0.5 = 50%, 1 = 100% Which you can multiply with the alpha: progress * 255 (alpha) Shouldn't be too hard to understand? After all, the variable names speak for them self.
-
It is a very complex process. But the best way to do this is by using the "os time". https://wiki.multitheftauto.com/wiki/GetTickCount local duration = 5000 local futureTime = getTickCount() + duration local timeNow = getTickCount() local timeLeft = futureTime - timeNow if timeLeft > 0 then -- animation ran NOT out of time ? local progress = (duration - timeLeft) / duration if progress > 0.5 then else end end Try to understand this concept first . ------------------------------------------------------- Feel free to use my content animator. It might to be too complex for you, but maybe you find your answer in the code. (next page) Pre requirement: For the functions: addRenderEvent, removeRenderEvent Content animator: Example, this is an animated rectangle: Fill in: id duration delay func (function where you do the animation stuff) parameters (default/start values) animations (these will animate/change the values of the parameters) Warning: The animations do not wait for each other, that is where the delay setting comes in. setTimer(function () local sample = { id = "sample", -- optional duration = 5000, -- or "infinity" / "inf" delay = 1000, func = function (param) local rectangleSize = 100 * param.scaleFactorY dxDrawRectangle ( param.screenCenterX - rectangleSize / 2, param.screenCenterY - rectangleSize / 2, rectangleSize, rectangleSize, tocolor ( 255, 0, 0, param.opacityStart ) ) end, -- optional 1 parameters = { opacityStart = 0 }, -- optional 2 (requires optional 1) animations = { { parameter = "opacityStart", from = 0, to = 255, duration = 2000, delay = 0, -- optional 3 easingType = "OutInBounce", easingAmplitude = 1.0 -- }, { parameter = "opacityStart", from = 255, to = 0, duration = 2000, delay = 2000 } } } createAnimatedContent (sample) end, 100, 1)
