Jump to content

IIYAMA

Moderators
  • Posts

    6,085
  • Joined

  • Last visited

  • Days Won

    215

Everything posted by IIYAMA

  1. -- serverside local resources = getResources () local resourceCount = #resources setElementData(resourceRoot, "resourceCount", resourceCount) -- clientside local resourceCount = getElementData(resourceRoot, "resourceCount") iprint("resourceCount:", resourceCount)
  2. [...] 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
  3. I also tried that world texture once and for some unknown reason it doesn't work. A shader specialist might know.
  4. Use this event instead: https://wiki.multitheftauto.com/wiki/OnClientExplosion
  5. 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.
  6. 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.
  7. Can all peds not get killed? If that is the case, then this event is cancelled in one of your resources: https://wiki.multitheftauto.com/wiki/OnClientPedDamage
  8. 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
  9. 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.
  10. 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)
  11. 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)
  12. 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)
  13. Feel free to ask questions about the code! Manually debugging it makes understanding code a lot easier:
  14. 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
  15. @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
  16. Ah sorry, in case of hitting the vehicle, you need to use ped target start. But you are almost there.
  17. 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...)
  18. 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.)
  19. The first two lines should be on top of the script. The rest should be inside of the function which is called every frame. (Name: renderPulse)
  20. 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.
  21. 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)
  22. I am not sure how those rockets are created, but why not solve the issue at the source? local nextShootTime = 0 function vehicleWeaponFire(thePresser, key, keyState, vehicleFireType) local vehModel = getElementModel(getPedOccupiedVehicle(thePresser)) local timeNow = getTickCount() -- system time if (armedVehicles[vehModel]) and timeNow > nextShootTime then -- if system time is higher than nextShootTime nextShootTime = timeNow + 5000 -- system time + 5000 ms = nextShootTime triggerEvent("onVehicleWeaponFire", thePresser, vehicleFireType, vehModel) end end And regarding your last issue: I think it is this: player = source It is a global after all, other players can also change the player variable globally before the timer is finished. So: local player = source But even so, I am not sure if the toggleControl function can block the bindKey. I put my doubts on that.
  23. Add more comments! What does your code do? The word `character` means in English different things: https://dictionary.cambridge.org/dictionary/english/character A person? A letter from a word? Variable names can only partly clarify what the code does. Comments will have to do the rest! Learn some more about local and global variables:
  24. Yea that is a possibility. @koragg Just keep in mind that: (if this issue is still around) 1. if you were listening serverside with the event onResourceStart. 2. Trigger the resourceRoot of that specific resource to clientside. 3. That after validating, the resourceRoot is not available yet. (Just run these 3 steps and you will understand what this means) Send over the resourceName instead and wait for onClientResourceStart(with high addEventHandler priority)
  25. @Stealthy Serval Why not move this to serverside? As far as I can see your code is already starting there. local loopCount = 0 local character = {} character[1] = {} character[2] = {} character[3] = {} acq = sql:query("SELECT * FROM characters WHERE account=?",getElementData(source,"getPlayerUsername")) for i,c in ipairs(acq)do if(characterCount == 1)then if(loopCount == 0)then character[1].skin = tonumber(c.skin) character[1].name = c.name character[1].cash = c.cash character[1].bank = c.bank loopCount = loopCount+1 end elseif(characterCount == 2)then if(loopCount == 0)then character[1].skin = tonumber(c.skin) character[1].name = c.name character[1].cash = c.cash character[1].bank = c.bank loopCount = loopCount+1 elseif(loopCount == 1)then character[2].skin = tonumber(c.skin) character[2].name = c.name character[2].cash = c.cash character[2].bank = c.bank loopCount = loopCount+1 end elseif(characterCount == 3)then if(loopCount == 0)then character[1].skin = tonumber(c.skin) character[1].name = c.name character[1].cash = c.cash character[1].bank = c.bank loopCount = loopCount+1 elseif(loopCount == 1)then character[2].skin = tonumber(c.skin) character[2].name = c.name character[2].cash = c.cash character[2].bank = c.bank loopCount = loopCount+1 elseif(loopCount == 2)then character[3].skin = tonumber(c.skin) character[3].name = c.name character[3].cash = c.cash character[3].bank = c.bank loopCount = loopCount+1 end end end
×
×
  • Create New...