-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
function hill_Enter ( thePlayer, matchingDimension ) if getElementType(thePlayer) == "player" then -- check if the hit element is actually a player local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) As @Blast3r said.
-
You can't attach an addEventHandler to an element that doesn't exist yet.(it exist after the addCommandHandler has been executed. Feel free to apply this tutorial: (because a parent element can be created and attached before the children are created)
-
Nice but keep in mind that inspect is actually for debugging. I recommend you to use tostring to convert numbers to strings. Because inspect does a lot more in the background than tostring does. Which is probably using a lot more cpu then needed. local numberToString = tostring(123) -- "123" local x = tostring(closestPoint[1]) local y = tostring(closestPoint[2]) local z = tostring(closestPoint[3]) local r = tostring(closestPoint[4]) local spawn = x..", "..y..", "..z..", "..r Also it is very important to use locals, to improve atleast the hierarchy of the code. In my opinion the most important thing about using locals, is that you as code writer know when data shouldn't be saved for a longer period. It must be GONE, because you don't need it any more. https://wiki.multitheftauto.com/wiki/Local https://www.lua.org/pil/4.2.html Whaaahaha brings back memories, when I started with lua.
-
closestPoint[4] This is what closestPoint is now: { 1173, -1323, 15, 270} {[1] = 1173, [2] = -1323, [3] = 15, [4] = 270} This is how the table index works, when the keys are not defined. The inspect function will convert all data types to a string, please study: https://wiki.multitheftauto.com/wiki/Inspect So a boolean will look like something like this: "true" / "false" A number will look like something like this: "1323435" A table will look like something like this: "{123, 5656}" ETC.
-
The most simplest way is this: function getDistance(thePlayer) -- get the player position local px,py,pz = getElementPosition( thePlayer ) --Player location -- prepare 2 variables, but do not give them a value yet. local closestDistance local closestPoint -- loop through the tables for i=1,#hosp_loc do local hx, hy, hz = hosp_loc[i][1], hosp_loc[i][2], hosp_loc[i][3] --Hospital locations local distance = getDistanceBetweenPoints3D (hx, hy, hz, px, py, pz) --Get the distance between player and hospitals if not closestDistance or distance < closestDistance then -- If the closestDistance is nil/(false) OR the distance is smaller than the closestDistance. closestDistance = distance -- save the distance in closestDistance, which is located outside of the loop. closestPoint = hosp_loc[i] -- save the point in closestPoint, which is located outside of the loop. end end outputChatBox(inspect(closestPoint), thePlayer, 255, 170, 85) -- debug the closestPoint variable, should be a table! end
-
You need to give it atleast two values. output = math.min(distance, output) You can also fill in 3 or 100 values.
-
local destroyTimer function blips() if isTimer (destroyTimer) then return end local blipGroupElement = createElement("blipGroupElement") for i=1,#ATM_Locations do local x,y,z = ATM_Locations[i][1],ATM_Locations[i][2],ATM_Locations[i][3] local blip = createBlip ( x, y, z, 52, 1, 0, 0, 0, 255, 0, 500) setElementParent(blip, blipGroupElement) end destroyTimer = setTimer( destroyBlips, 10000, 1, blipGroupElement) end addCommandHandler( "ATM", blips, false ) function destroyBlips(blipGroupElement) if isElement(blipGroupElement) then destroyElement(blipGroupElement) end end Must be working. Local variables can not leave their block. function blips() -- block local blipGroupElement = createElement("blipGroupElement") -- block end -- blipGroupElement can not be used here. But lucky setTimer accepts custom parameters. destroyTimer = setTimer( destroyBlips, 10000, 1, blipGroupElement) function destroyBlips(blipGroupElement) if isElement(blipGroupElement) then destroyElement(blipGroupElement) end end destroyTimer = setTimer( destroyBlips, 10000, 1, blipGroupElement) function destroyBlips(blipGroupElement) if isElement(blipGroupElement) then destroyElement(blipGroupElement) end end
-
Info: You create for every blip a timer. But when the function is recalled, you only destroy 1 timer. The variable `destroyTimer` can only contain 1 value at the same time, so only one timer. Info: The distance check is within function `blips`, which is only executed when you write the command. So it doesn't recheck after that. Solution: See on page: https://wiki.multitheftauto.com/wiki/CreateBlip visibleDistance If you set this, you don't have to destroy blips any more. It will simply stream them out. Alternative method to destroy multiple elements. See this tutorial, it will make your life a lot easier. In the tutorial you can see that I set a parent element of all children. If you do the same and destroy the parent element instead, all children will also be destroyed. local blipGroupElement = createElement("blipGroupElement") -- for loop -- ADD here your blips setElementParent(blip, blipGroupElement) -- end destroyElement(blipGroupElement) -- All blips are destroyed
-
The sound of an engine exist out of multiple different sounds to make it `sound` differently. Afaik the sound(not sound group) you disable is equal for all vehicles. But I can be wrong.
-
It is a common mistake (I am making sometimes the same mistake), but there is always wiki to find it.
-
hmm Then there is only one way left. Record the sound and play it for every vehicle.
-
YUP
-
https://wiki.multitheftauto.com/wiki/TriggerClientEvent Syntax: bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) You forgot to set the sendTo.
-
True. But you never said it was also for the other players. AFAIK the sound is less present for the players near the heli than the player in the heli. It shouldn't be that much of a problem.
-
Yes? Off in a heli On not in a heli Or do I look that stupid?
-
Because you haven't found it yet. The boss is probably created serverside, because it has to be synced with all other players. I do not know the script, neither I am going to spend time searching it for you (I don't have that luxury either). This will be your first research case, where you have to search and find a component you want to edit. Did you know that I spend more than 30 hours researching a single resource? (one of the first large resources I came in contact with) While researching I started to edit things on the way, which makes researching a bit more interesting. Tell me @TorNix~|nR, how much energy and time are you going to spend on achieving this?
-
Before you can try, you have to understand else those 100 times are for nothing. So tell me what did you learn from the code?
-
You will have to study the script that is creating the `boss`, because this is just bull:~ code and will not get you anywhere. Check for export functions or custom events you could trigger.
-
edit line 1, to: sha1 = { Edit line 297, to: -- nothing
-
ONLY the file " sha1.lua", not a folder. Just put it in the root/top layer of the resource where you are going to using this sha1 function. Then open the meta.xml of the resource. (which is also in the root/top layer) And add there between the meta tags: <meta>HERE</meta> This: <script src="sha1.lua" />
-
I really hope you didn't copy the Github comments with it. Because the code you posted contains them, if so try to copy the raw format of it. Raw format: https://raw.githubusercontent.com/kikito/sha1.lua/master/sha1.lua Replace:(it is in your code, seek and find) sha1(password) With: sha1.sha1(password) Make sure to check if the code you download is working. :
-
local sounds = {} function onSay1() if isElement(source) then local x, y, z = getElementPosition(source) local sound = playSound3D('say1.mp3',x,y,z) setSoundMaxDistance(sound, 25) sounds[#sounds + 1] = {sound = sound, player = source} end end addEvent("onSay1",true) addEventHandler("onSay1", root, onSay1) addEventHandler("onClientRender", root, function () if #sounds > 0 then for i=#sounds, 1, -1 do local soundData = sounds[i] local sound = soundData.sound local player = soundData.player if isElement(sound) and isElement(player) then local x, y, z = getElementPosition(player) setElementPosition (sound, x, y, z) else table.remove(sounds, i) end end end end) triggerClientEvent (root, "onSay1", player) Something like this. (untested)
-
This is all there is.
-
onClientPreRender < (do not use attachElements)