-
Posts
96 -
Joined
-
Last visited
Everything posted by Moony
-
I apologize for being a nag. While I understand the pros of function within function, I still can't understand why this scipt isn't working. It shows up, but the sliders are not moving what they should move (left front door). I confused a few words; I had accidently set the slider labelled as "bonnet" to open the door ("capo" = bonnet). I also just set the ID of the element to open ('2' = front left door). Both things are fixed. Here's the last version of the script: The two prefix letters of the '-scroll' represent the door (i.e. fr- = frontleft-). Still, nothing's happening. Do I have to set the movement server-side? This is all happening client-side.
-
Hello again, The_GTA! Here's the complete code (client-side): function vehModif () vehmod = guiCreateWindow(0.74, 0.22, 0.25, 0.74, "Modificacion de Vehículo", true) guiWindowSetSizable(vehmod, false) openlabel = guiCreateLabel(0.23, 0.03, 0.52, 0.04, "Aberturas", true, vehmod) guiLabelSetColor(openlabel, 51, 194, 203) guiLabelSetHorizontalAlign(openlabel, "center", false) guiLabelSetVerticalAlign(openlabel, "center") capolabel = guiCreateLabel(0.27, 0.08, 0.46, 0.02, "Capot", true, vehmod) guiLabelSetHorizontalAlign(capolabel, "center", false) guiLabelSetVerticalAlign(capolabel, "center") caposcroll = guiCreateScrollBar(0.11, 0.10, 0.79, 0.03, true, true, vehmod) fllabel = guiCreateLabel(0.27, 0.14, 0.46, 0.02, "Puerta delatera izquierda", true, vehmod) guiLabelSetHorizontalAlign(fllabel, "center", false) guiLabelSetVerticalAlign(fllabel, "center") flscroll = guiCreateScrollBar(0.11, 0.16, 0.79, 0.03, true, true, vehmod) frlabel = guiCreateLabel(0.27, 0.21, 0.46, 0.02, "Puerta delatera derecha", true, vehmod) guiLabelSetHorizontalAlign(frlabel, "center", false) guiLabelSetVerticalAlign(frlabel, "center") frscroll = guiCreateScrollBar(0.11, 0.23, 0.79, 0.03, true, true, vehmod) rllabel = guiCreateLabel(0.27, 0.27, 0.46, 0.02, "Puerta trasera izquierda", true, vehmod) guiLabelSetHorizontalAlign(rllabel, "center", false) guiLabelSetVerticalAlign(rllabel, "center") rlscroll = guiCreateScrollBar(0.11, 0.29, 0.79, 0.03, true, true, vehmod) rrlabel = guiCreateLabel(0.27, 0.34, 0.46, 0.02, "Puerta trasera derecha", true, vehmod) guiLabelSetHorizontalAlign(rrlabel, "center", false) guiLabelSetVerticalAlign(rrlabel, "center") rrscroll = guiCreateScrollBar(0.11, 0.36, 0.79, 0.03, true, true, vehmod) baullabel = guiCreateLabel(0.27, 0.41, 0.46, 0.02, "Baúl", true, vehmod) guiLabelSetHorizontalAlign(baullabel, "center", false) guiLabelSetVerticalAlign(baullabel, "center") baulscroll = guiCreateScrollBar(0.11, 0.43, 0.79, 0.03, true, true, vehmod) guiSetVisible (vehmod, false) end addEventHandler ("onClientResourceStart", getRootElement(), vehModif) function openCapo(caposcroll) local theVeh = getPedOccupiedVehicle(localPlayer) local value1 = guiScrollBarGetScrollPosition(caposcroll) if theVeh and value1 then setVehicleDoorOpenRatio(theVeh, value1 / 100) end end addEventHandler("onClientGUIChanged", caposcroll, openCapo) function showVehModif() if (guiGetVisible(vehmod) == false) then guiSetVisible (vehmod, true) showCursor (true) else guiSetVisible (vehmod, false) showCursor (false) end end addCommandHandler("vehmod",showVehModif) bindKey ("F3", "down", showVehModif) I still couldn't completely understand the difference of what you told me in the other post. I'm running some tests to understand (this is one of them). I made sure each part of the script ran with an event handler. Everything works, except for the system applying the change when detecting the scrollbar moving.
-
Should it look something like this? function openCapo() local theVeh = getPedOccupiedVehicle(localPlayer) local value1 = guiScrollBarGetScrollPosition(caposcroll) if theVeh and value1 then setVehicleDoorOpenRatio(theVeh, value1 / 100) end end addEventHandler("onClientGUIChanged", caposcroll, openCapo) DB 3 says the second argument in 'addEventHandler' is nil. Changed it too 'getRootElement()', but it still doesn't work; DB 3 throws nothing. A similar script I found on MTA's resources plays around with 'triggerServerEvent', and the door ratios are being set server side. It made me wonder how the server.Lua catches the scrollbar ID that moved in order to modify the door number, and if I should too set the movement server-side, having the trigger client-side.
-
I decided to dive into the world of rotations. I know this might be incomplete and even incorrect: function openCapo() local theVeh = getPedOccupiedVehicle(localPlayer) local value1 = guiScrollBarGetScrollPosition(caposcroll) if theVeh and value1 then setVehicleComponentRotation (theVeh, bonnet_dummy, value1, rY, rZ) end end I've a GUI already created, and the visibility key bound. The first scrollbar (caposcroll) should affect the bonnet_dummy. This was made with absolute basic thinking process: "if I want doors to open, I need to get the position of the scrollbar". However, I know I still need to tell the game what's the math.min, what's the math.max, and, I think, to also give the order to respond only when the scrollbar is moved. I would appreciate a finger to point me in the right direction.
-
It works now. I have a doubt. I have a very basic script that pops up a help memo (similar to the F9 help menu): function openHelp (key, keystate) if (guiGetVisible(helper) == false) then guiSetVisible (helper, true) showCursor (true) else guiSetVisible (helper, false) showCursor (false) end end bindKey("F9", "down", openHelp) Above it, the elements: helper = guiCreateWindow(0.19, 0.20, 0.63, 0.64, "-- 'El Final de la Bala' --", true) guiWindowSetSizable(helper, false) tabs = guiCreateTabPanel(0.03, 0.05, 0.94, 0.91, true, helper) welcomeTab = guiCreateTab("Bienvenido", tabs) welcomeMemo = guiCreateMemo(0.01, 0.04, 0.98, 0.93, welcome, true, welcomeTab) guiMemoSetReadOnly (welcomeMemo, true) rulesTab = guiCreateTab("Reglas", tabs) rulesMemo = guiCreateMemo(0.01, 0.04, 0.98, 0.93, rules, true, rulesTab) guiMemoSetReadOnly (rulesMemo, true) functionsTab = guiCreateTab("Funciones", tabs) functionsMemo = guiCreateMemo(0.01, 0.04, 0.98, 0.93, functions, true, functionsTab) guiMemoSetReadOnly (functionsMemo, true) locationsTab = guiCreateTab("Locaciones", tabs) locationsMemo = guiCreateMemo(0.01, 0.04, 0.98, 0.93, locations, true, locationsTab) guiMemoSetReadOnly (locationsMemo, true) guiSetVisible(helper, false) These elements are placed as seen: without a 'function' header, nor any kind of event handler. However, this works just fine. The player can click through each tab and open/close the memo. Why is it not the same with the spawn panel? Why does it fail when the 'onClientGUIClick' is outside the creation function? I still don't quite get the difference. I had imagined that the event call would be called regardless of its position.
-
Though I did forget to add the event handler (which is actually 'onClientGUIClick'), adding it doesn't fix the issue. addEventHandler("onClientGUIClick", botonCrear, "up", createVehicleHandler,false) DB 3: expected element at argument 2 is nil. Line number is the event handler I just added. I tried removing the "up" argument, but nothing changes.
-
Hello, everybody! I'm following this tutorial to make a GUI with a car spawning function. Copy/pasting everything works up until the gridlist. The click doesn't. Could there be a mistake? I recreated the script on my own following step by step: - Client-side - And here is the problematic part: The GUI elements are the same. The only thing that changes are the names. Naturally, it should work by simply replacing the names. However, I believe there might be a mistake on the original script. With everything as it is, I can show and hide the GUI, and click on any vehicle. If I purposely trigger an output, nothing happens. So, waddaya think?
-
Would this happen even if I created a script that runs on its own resource folder, without any other scripts in the same .Lua?
-
I don't remember why I put it there, but next to the join function, I set a 'setSunSize' and 'setMoonSize'. I can't imagine how it could affect the other scripts, but if the randomseed is in the same .Lua as the join function, then I should move the celetial bodies' size to a different resource, right? Do you know, by any chance, how the random seed could affect other scripts that don't have a random factor? Like I told _Ace, a good example would be the size of both sun and moon. EDIT: would it be enough to just set up another server-type .Lua with the sun and moon, but within the same folder (being fetched by the same meta.xml that fetches the join script)?
-
Would it then be correct to say that 'math.randomseed' is affecting everything under it inside the function? Will it affect other functions outside this function that are above or beneath?
-
Excuse my possibly noobish questions, but: - Why are the parentheses next to 'getTickCount' empty? Is there supposed to be any value (not necessarily here, but maybe in any other function)? - How does the randomseed directly affects the selection of the coordinates within the table? Shouldn't you tell the 'math.randomseed' where to select pseudorandomly?
-
I have this: -- 2 points on each city. local spawnCoords = { {1125, -2036, 69.89, -90}, {2504, -1686, 13.55, 45}, {-1972, 643, 46.57, -45}, {-2720, -317, 7.85, 45}, {2023, 1008, 10.83, -90}, {1298, 2084, 12.83, -90}, } -- all skins. local validSkins = {0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312} function spawnPoints (player) local x,y,z,r = unpack(spawnCoords[math.random(1,#spawnCoords)]) spawnPlayer(source, x, y, z, r, validSkins[math.random(1,#validSkins)]) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerJoin", getRootElement(), spawnPoints) Althought it works, after giving it several tests, I realized the spawn locations where always in the same order, as well as the skins. Coincidentally, I've reached the tables subject in the MTA's tutorial, and I learned about <for key, value in pairs(table) do>. Contrary to "ipairs", "pairs" is supposed to give you a random reading throughout the table everytime the script is ran. I used 'broph.Lua' as a way to understand the process, and to make sure that if I do the same, it'll work. My small knowledge told me that, by adding <for key, value in pairs(spawnCoords) do> right after the beginning of the function, I would get the random effect of the table reading. However, the result is far from what I expected: it destroys the function, and the player doesn't spawn at all (black screen). I'm continuing the tutorial, but 'in pairs' is the last thing NanoBob mentions about the tables. This time, I'd like a bit of a challenge, so if you could give me the hints and point me in the right direction, I would appreciate that.
-
[SOLVED] Solution: stopping the resources that max's out the stats will set the stats to 0 (reminder). Thus, it is better to make a new resource that either: - sets the weapons properties to apply in each level (just in case), for which you'd have to set every property to "poor", "std", and "pro". - max's out the stats to each player (if you plan to keep the max stats resource).
-
We've got it, guys! Alright, so let me get this straight. First, my newly acquired knowledge: 1. Why is it better to use 'isPedInVehicle(player)' to get the boolean, instead of what I was using? What was my error in that statement? This was my thought process: if (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == true) -- if the marker is 'inFourD' (true); if the player is, in fact, a player (true); if there is a player in a vehicle (true), then -- do whatever 2. What's the specific function of 'Return'? Does it save process of going through the whole function, thus, reducing the process and, therefore, the lag as well? How does it know when to reach the end of the function? I realized that I made a recurring mistake in my scripts: getting the elements right. Is there any "Elements for Dummies" tutorial out there? Clearly one of my biggest problems is that subject. And, finally, to my understanding: if ( source == inFourD and getElementType(player) == "player" and isPedInVehicle(player) ) then -- if the marker is 'inFourD' (true); if the element to affect called 'player' is, in fact, a player (true); is the ped in a vehicle (true) then -- not let in -- stop here (return) if the above happens. If not, then -- if the marker is 'inFourD' (true); if the element to affect called 'player' is, in fact, a player (true); is the ped in a vehicle (false) then -- let in. -- that false result in isPedInVehicle is what works the magic. Is it right?
-
Here's the script: inFourD = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function inFourDragons (player, matchingDimension) if (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == true) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", hitPlayer, 0, 0, 0, true) elseif (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == false) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Ingresaste al casino '#DD0000Four Dragons#FFFFFF'.", hitPlayer, 0, 0, 0, true) setElementInterior (player, 10) setElementPosition (player, 2016.9376220703, 1017.0843505859, 996.875 ) setElementRotation (player, 0, 0, 90) end end addEventHandler ("onMarkerHit", getRootElement(), inFourDragons) Doing it client-side gives the invisible players. I read an old post that this had to be done server-side to fix the invisible players; however, I can't pinpoint the problem. As of this moment, with this script: - When in vehicle, player + vehicle is teleported to the same coords and interior 10, which results in an invisible world, player and vehicle, and it outputs "You've entered FDC.", when it should enter "Cars are not allowed". - When on foot, nothing happens. What could be the problem?
-
Any chance for this script to be updated/tested? I'm struggling with the same issue. Already have tried this script, but it doesn't work. Oddly, it teleports me to an emtpy interior (everything, including me, invisible) only when I'm on a vehicle.
-
I've made a server-type .Lua that should apply several 'setWeaponProperties' to the weapons. It works for some weapons, but not for others. For example, I've set the Deagle (replaced with a 6 bullet drum) to 'maxiumum_clip_ammo' = 6. This works correctly. However, with other weapons, it doesn't. Here's the script: function weaponProps () -- M9 -- setWeaponProperty(22, "pro", "maximum_clip_ammo", 14) -- Revolver -- setWeaponProperty(24, "pro", "maximum_clip_ammo", 6) -- Shotgun -- setWeaponProperty(25, "pro", "maximum_clip_ammo", 7) -- Uzi -- setWeaponProperty(28, "pro", "maximum_clip_ammo", 30) -- AKMS -- setWeaponProperty(30, "pro", "maximum_clip_ammo", 35) -- G36 -- setWeaponProperty(31, "pro", "maximum_clip_ammo", 40) -- Kar -- setWeaponProperty(33, "pro", "maximum_clip_ammo", 5) -- Mosin -- setWeaponProperty(34, "pro", "maximum_clip_ammo", 1) end addEventHandler ("onResourceStart", getRootElement(), weaponProps) Essentially, it runs as soon as the resource is started. As a beginner's test, I'm only modifying the max ammo clip. It works for: - Deagle (Revolver) - Shotgun - AK-47 (AKMS) - M4 (G36) - Rifle (Kar) - Sniper (Mosin) It doesn't work for: - Colt (M9) - UZI
-
28-Feb-2020 Detected a possible bug. I've created a slightly complex GUI with four selectable tabs inside a Window (similar to the helpmanager). Within the tabs, memos. Bug: 'Output' is not outputting anything. There is no code window showing up like it should. There are no error in DB 3. I am using the last build (downloaded a week ago from this day). I've created GUIs before with the same resource, and 'Output' worked. UPDATE: removed every "ñ", "á", "é", "í", "ó" and "ú", as well as any type of bracket and punctuation mark. Completely stripped every piece of text from everything other than english letters and numbers. 'Output' is not working. Addiontionally, I got a DB 3 error: "main.Lua: line 777: bad argument at 'destroyElement' [Expected element at argument1, got nil ]"
-
I've been messing around with 'setWeaponProperty' in order to understand how it works. I changed how the deagle is handled. Decided to undo the changes and, upon resetting everything, the weapon bugged. Image Any script with 'setWeaponProperty' has been removed, and the resource has been stopped and removed from metaserver.conf. Fixed after several restarts and total wipe of downloaded resources.
-
I finally managed too get it working. I mixed elements from the replies and other examples to understand how the element tree works. Thanks everyone for everything. Thanks for each piece of information and for the patience!
-
If you're talking about adding a code like several replies above, you can do so with the "<>" sign next to the text formatting. Another window will open, where you can simply copy and paste the code from Notepad++ to there. If it's too big, I advice you use the spoiler format (symbol is an eye) so the reply is compressed, yet accessible to the reader. Got it. So "if isElement(pedSounds[source] ) then destroyElement(pedSounds[source] ) end" destroys the element before reproducing another element. In other words, he is destroying the original sound and then playing the custom sound. To reproduce the custom sound, he is using "pedSounds[source] = Sound3D(source, weapons[weapon]", where source = PedShooter, PedSounds = any unique sound, Sound3D = the function [being played to the source (shooterPed) and reproducing "weapon" (the first argument of 'onClientPlayerWeaponFire')]. What would 'weapon' be equal to, then? I'll have to repeat this to myself several times along with some testing to fully understand it, but I think I generally get it. I went with someone a bit more simple before fully getting into the weapons: a simple script that plays a sound in the player's position (type="client"). function beatbox () local bX, bY, bZ = getElementPosition (client) local beat = playSound3D ("beatboxF.mp3", bX, bY, bZ, false) end addCommandHandler ("beatbox", beatbox) Meta has the file, the file works, but DB3 is saying that getElementPosition is nil, as well as 'vector3'. Ok! Ok! It works! The sound is always coming from the player. Now I need to make sure if other players can hear it coming from me. I used 'localPlayer' in place of 'client', and 'attachElements'. Why did 'localPlayer' worked?
-
A good excercise I found is to explain myself colloquially what this does. Would you be so kind and correct me if I'm wrong? 1st function: "Sound3D". My first guess is that, since there is no 'addEventHandler', the function will be applied as long as it is running and as soon as the player downloads it. First, you set the wX, wY, and wZ coordinates equal to the muzzle of the weapon being held by the shooter. From that moment, MTA will know that those three values represent the respective x, y and z of the muzzle. The muzzle will be relative to the player, whom we'll call "shooterPed'. Then, you do the same by saying that the word "sound" is equal to the sound that we have to reproduce, in 'playSound3D' format, with the coords that you previously set, and a false bool for 'loop'. Continuing the conditions, you also set that the sound will be attached to the player's position (a little variation to the player's height), you set the max distance the sound can be heard from, and the dimension and interior, which will be taken from the player's (shooterPed) dimension and interior. Is this correct? What's the return sound for? Also being applied as long as the resource is started and the player downloads it, you briefly set the sound to be played. You say that the weapons sound available as of this moment is for the Colt 45 (weapon ID = 22), and that the sound that will be played is the one called "Colt45.wav" at the given location (which is being taken from meta.xml) —if I were to add more weapons, I would need to repeat the 2nd function for each weapon—. You then equal 'PedSounds' to... nothing? And lastly, you disable the weapon sounds (5) of the world. Right? 2nd function: "onClientWeaponFire (weapon)". The parentheses are the first argument of the event handler 'onClientPlayerWeaponFire'. That means that whenever 'weapon' is fired, the function will be called. (Here's where I get stuck) first, you say that 'if weapons[weapon] then'; if true, then the next 'if' happens, which is the isElement and destroyElement. Why do you destroy this? From this point on, I can't translate what's happening. I can't understand "pedSounds[source] = Sound3D(source, weapons[weapon] )". Lastly, you close all 'if' and the function, and set the event handler to trigger the 2nd function when the client shoots. Clearly the 2nd function is where I'm having trouble at. Questions: - Is this server-side or client-side? - In the 1st function, you said that "local sound = playSound3D (sound3d,wX, wY, wZ, false )". Wouldn't you have to assign a value to 'sound3d'? How does the script know what 'sound3d' is equal to? - What's the use for "local PedSounds = {}"? Why empty? - Between so many '<word> = value', I get confused and need to reread to know what the word is equal to. I also get confused on when to use 'source', 'root', 'getRootElement(), 'localPlayer', 'client', etc. I just can't feel the difference. - I have more questions, but they might be answered if the ones before are answered. Also, thanks for being so sympathetic. And sorry for the random vent...
-
Using addEventHandler ("onClientPlayerWeaponFire", source, <functionName>) returns the default sounds. I've tried using the wiki's example, but I'm left with overlaid sounds. Even adding 'setWorldSoundEnabled' affecting '5' (gunfires) doesn't fix it. On top of it, I'm having a very hard time testing the changes (for which I tried using SlothBot, but I never figured it out. Also tried using 'setPedControlState', but the ped stood there and DB 3 gave me an invalid value for "fire"). This is really frustrating. I thought it would be easy. I know there are several experienced members helping me, but I would have never imagined it to be so hard. I'm back at level 1: I've got the custom sounds for each weapon, everyone hears them, but I can't set the custom sounds to be 3D (identify them from left or right, and hear them faded out when distanced).
-
Alright. Every shooting sound (included machine guns from planes) are muted. The guns I've gave a custom sound can be heard. Still, 'playSound3D' is not working. Weapons still can be heard equally from all distances.
-
To be honest, I don't know. I don't know a lot, but I had imagined that setting a playSound3D for a custom sound where its coordinates are the weapon's muzzle wouldn't look so complex. It doesn't work. The sound is still the default one.