Jump to content

Moony

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by Moony

  1. I'm sorry, but I can't figure how to use the 'isElement' in this case. I've checked other examples, but it is very difficult for me to locate the function and understand how it's being treated/treats other functions. Here's the slightly modified script: How I understand, by defining that the three variables (wX, wY, wZ) represent the variables in 'getPedWeaponMuzzlePosition', if I do what I did with the G36, the sound would always come from the muffler of the weapon any player is carrying. However, after another test to make sure, I can confirm that the playSound3D is working, but the custom sound is not being processed. As a result, players can hear the weapon fade out as they get further away, but the sound is the GTA's default one. If I replace 'playSound3D' with 'playSound', the custom sound will be heard, but the fade out will not exist.
  2. ATM is fixed. Works correctly now. The sound needs to come from 'getPedWeaponMuzzlePosition', which is relative to the player's position. Strangely, if I add that, the custom sound is replaced by the GTA's default sound; contrarily, if I don't add the function, the custom sound remains, yet the sound can be heard equally on all distances.
  3. Next issue might be simple. I added custom sounds of guns. They work correctly. However, 'playSound3D' is not picking them up. I've set the vectors to 'getPedMuzzlePosition', but the custom sound is being heard on equal volume from next to the player to the point where the player is not being drawn anymore (draw distance). function onClientPlayerWeaponFire ( weapon ) local wX, wY, wZ = getPedWeaponMuzzlePosition ( getLocalPlayer() ) local x, y, z = getElementPosition ( getLocalPlayer() ) if weapon == 22 then--colt45 playSound3D ( "sounds/Colt45.wav", false ) elseif weapon == 23 then--silenced playSound3D ( "sounds/Silenced.wav", false ) elseif weapon == 24 then--deagle playSound3D ( "sounds/Deagle.wav", false ) elseif weapon == 25 then--shotgun playSound3D ( "sounds/Shotgun.wav", false ) elseif weapon == 26 then--sawn-off playSound3D ( "sounds/Sawed-Off.wav", false ) elseif weapon == 27 then--combat shotgun playSound3D ( "sounds/Combat Shotgun.wav", false ) elseif weapon == 28 or weapon == 32 then--uzi/tec-9 playSound3D ( "sounds/UZI_Tec9.wav", false ) elseif weapon == 29 then--mp5 playSound3D ( "sounds/MP5.wav", false ) elseif weapon == 30 then--AKMS playSound3D ( "sounds/AKMS.wav", false ) elseif weapon == 31 then--G36 playSound3D ( "sounds/G36.wav", false ) elseif weapon == 33 then--rifle playSound3D ( "sounds/Rifle.wav", false ) elseif weapon == 34 then--sniper playSound3D ( "sounds/Sniper.wav", false ) end end addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), onClientPlayerWeaponFire ) (Script was downloaded. Author is "Dr.PhillyBLunt".)
  4. I changed 'root' to 'hitPlayer', 'source', 'player', 'localPlayer', and neither work. They either stop giving money, or give money to all players. UPDATE: Works: added 'client' in place of 'root'. Now, each client receive the money and the message. Others players are not affected. I guess it's [SOLVED] Next issue: output to all when using Teleports. I guess that I would have to add the same if to the client.Lua on each teleport function... Loading... Works!
  5. With that added to the client.Lua, now only the hitPlayer receives the message. However, all players are receiving the amount of money specified in the script.
  6. I apologize. I had some errors in my script. It's been fixed now. It is the original with the output issues.
  7. I've found six issues so far. Being alone, everything seemed fine; with players, these issues are visible. For the sake of organization and to avoid overwhelming, I'll be going through each issue (if possible), instead of throwing everything at once —unless asked otherwise—. First in the list is about client.Lua's 'outputChatBox' showing to everyone in the chatbox: I've got two scripts in this moment that are causing said inconvenient: a quick ATM system and a teleport system. The ATM is a simple marker that, when hit, gives you $500, and outputs that information. The teleports work the same way, but instead, the set the interior, position and rotation of the player, and output a message. ATM: Client: (this example's location is at LV's gas station, next to Four Dragon's Casino). atm1 = createMarker (2123.0048828125, 897.57653808594, 10.1796875, "cylinder", 1, 0, 100, 0, 170) function moneyLawn (hitPlayer, matchingDimension) if (source == atm1) and (isPedInVehicle(hitPlayer) == false) then triggerServerEvent ("givePlayerMoney", hitPlayer) outputChatBox ("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: El servidor te regaló #006400$500.", 0, 0, 0, true) end end (translation: "The server gave you $500") Server: function giveToPlayer () givePlayerMoney (root, 500) end addEvent ("giveMoney", true) addEventHandler ("giveMoney", root, giveToPlayer) Because of its close relation, I'll also name another issue regarding this script. The money is being given to all players in the server, and it is being multiplied by each player. This means that is, for example, I have 3 players in my server, when any player touches the marker, each player will be given $500 x amountOfPlayers = $1500. Teleports: (I have a few other teleports, but they only change interior and position). Client: ------------------------- -- FOUR DRAGONS CASINO -- ------------------------- inFourD = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function inFourDragons (hitPlayer, matchingDimension) if (source == inFourD) and (isPedInVehicle(hitPlayer) == true) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", 0, 0, 0, true) elseif (source == inFourD) and (isPedInVehicle(hitPlayer) == false) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Ingresaste al casino '#DD0000Four Dragons#FFFFFF'.", 0, 0, 0, true) setElementInterior (hitPlayer, 10) setElementPosition (hitPlayer, 2016.9376220703, 1017.0843505859, 996.875 ) setElementRotation (hitPlayer, 0, 0, 90) end end addEventHandler ("onClientMarkerHit", root, inFourDragons) outFourD = createMarker (2018.9376220703, 1017.0843505859, 995.875, "cylinder", 1, 255, 0, 0, 153) setElementInterior (outFourD, 10) function outFourDragons (hitPlayer, matchingDimension) if (source == outFourD) and (isPedInVehicle(hitPlayer) == true) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", 0, 0, 0, true) elseif (source == outFourD) and (isPedInVehicle(hitPlayer) == false) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Te retiraste del casino '#DD0000Four Dragons#FFFFFF'.", 0, 0, 0, true) setElementInterior (hitPlayer, 0) setElementPosition (hitPlayer, 2021.76953125, 1007.0116577148, 10.7203125 ) setElementRotation (hitPlayer, 0, 0, 90) end end addEventHandler ("onClientMarkerHit", root, outFourDragons) [translation: (if player in veh) "No cars allowed". (if player not in veh) "You've entered/exited "Four Dragons" casino".] There is no server. This similar post, which I'm following, says that in client-side, the output is bound to be shown just for the player who triggered the event.
  8. Would it be ok to reply here instead of making a new topic? I got this far: -- Already created all the GUI elements. -- Reference: -- "onWep": GUI window. -- "closeGUI": name given to close button. function markerVisible (player, onWep) -- This works normally. It also shows all the child elements (buttons, labels, close button). local sound = playSound ("sounds/merchantWAYB.mp3") guiSetVisible (weaponGUI, true) showCursor (true) end addEventHandler("onClientMarkerHit", onWep, markerVisible) function markerInvisible (closeGUI) if (guiGetVisible(weaponGUI) == true) then -- Refer to legend to get source of this bit. guiSetVisible (weaponGUI, false) showCursor (false) end end addEventHandler("onClientGUIClick", closeGUI, markerInvisible, false) Legend: I got the 'if' from here I'm getting an error: line 43 (addEventHandler), expected element at argument 2, got nil. What could be the problem?
  9. I've successfully created a marker that triggers 'givePlayerMoney' and 'outputChatBox' when 'onClientMarkerHit' in a client.Lua. Does the server see the amount of money the player now has? Do I have to sync the money to the server with some kind of 'getPlayerMoney' in a server.Lua? I'm planning on making a weapons GUI that works with the player's money.
  10. Alright. I think I'm getting it. I just read about the event called 'onClientMarkerHit'. The parameters are 'hitPlayer' and 'matchingDimension'. The function is called "MarkerHit". Teleport2 = createMarker (2021.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function MarkerHit (hitElement, matchingDimension) outputChatBox("What are you doing??!") end addEventHandler ("onClientMarkerHit", root, MarkerHit) addCommandHandler ("four2", MarkerHit) I'm aware it says 'hitElement'. This works completely. Seems to me that the 1st argument of 'addEventHandler' ("onClientMarkerHit") is connected to both arguments of the function 'MarkerHit' ('hitElement' and 'matchingDimension'). I also know that the arguments of the function can have any name; regardless, they will be treated the same way. Hold on... When I use the event 'onClientMarkerHit', am I conditioning the system to read the function as such? As if the system would be saying: "This dude added an event handler. Which is it? "onClientMarkerHit"? Alright then, there should be two arguments in the function. Are there two arguments? Yes. That means that this function will surely be about something hitting any marker. Once a marker is hit, I will have to output something into the chatbox". And if I want to do something to the hitElement, I'd have to tell it to the system in the arguments of the scripts. Alright. I guess we can celebrate now. I've got the script running, with a message, and even with an 'if' that prohibits players in a vehicle to enter. This experience is slowly turning into a crazier rollercoaster. Thanks to everyone for such amazing help and guidance!
  11. How should I look for the explanation to the arguments of a function? I'm getting extremely confused as to why sometimes the parentheses (function functionName() <-- this) are empty, and sometimes they have more than one argument. I've seen "thePlayer", "elemenet", "hitElement", "matchingDimension", "vehicle", "player", and more. I've even seen handlers that show the function variable with more elements than the beginning of the function. How do they affect the function? How are they related to the tree of the function? PS: english is not my first language. I'm good with casual talking, but when it comes to specific stuff, I struggle to find the words and even confuse myself sometimes. If there is anything that you [reader(s)] don't understand, let me know.
  12. Let's go for something much simpler. infourdragons = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function saythis (player) if (player == infourdragons) then outputChatBox ("What are you doing?", player, true) end end addEventHandler("onHitMarker", player, "saythis") I know there are a lot of errors and missing functions. I just don't know which. -Made the marker - Check -Created the function - Check -----If a player is in same place as the marker - Check — — Though I know that that would include a single point, and that is impossible to hit. -----If the marker is touched, the chatbox will show a message to the player - Check. -The event is triggered when the marker is hit by a player - Check. What am I missing?
  13. One of these days I'll acquire the habit of confirming the uppercase B. Thanks!
  14. I kept experimenting with this. I found a script that opened a panel with several teleports. They all had crazy x, y, and z values that were being respected. I modified them and got two teleports working (so far): one that takes the player to the entrance of "Four Dragons Casino", and one that takes the player inside the casino. Using setElementInterior, setElementPosition, and setElementRotation worked fine. I managed to obtain the what I had imagined. I decided to take one more step, and use markers to achieve the same result. As of this moment, there is a marker right next to the entrance of the casino, on the outside. The script looks as such: infourdragons = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) -- Coords for a spot next to the doors of the casino, on the outside. function enteredDragons(hitElement, matchingDimension) -- I tested the script with no values between parentheses. if (source == infourdragons and getElementType (player) == "player") then setElementInterior (player, 0) setElementPosition (player, 2018.9376220703, 1017.0843505859, 996.875 ) -- Coords for a spot next to the doors of the casino, on the inside. setElementRotation (player, 0, 0, 90) outputChatbox ("Entraste al Casino 'Four Dragons'", player, true) end end addEventHandler ("onMarkerHit", root, enteredDragons) (Translation: "You've entered 'Four Dragons Casino'". The marker shows up beautifully. I can modify it as desired. Everything else is not working. There is no output and no teleportation. Where could be the error?
  15. Oh my god. I feel so embarrassed. Thank you very much!, @ReZurrecti0n and @majqq
  16. A good example would be The Four Dragons Casino. The interior spawn point (where you appear when you are teleported by the F1 panel/admin panel) is located at z = 990 (aprox). I had assumed that if I set the interior to the casino, and z to where you spawn, you would be taken there. Likewise, the examples in the wiki (setElementInterior) give values of z higher than 900. After a few tries. I found the limit between 300 and 400.
  17. Ok, so you've got the official functions for mta on one side. They can be found in the link provided above. On the other side, custom functions are functions created by the developer. Having a 'function functionName' will asign the name to a function, and between that and 'end', you add the official functions that will do what the developer wants, such as throwing something to the chatbox, creating elements, teleporting the player, changing names, setting timers, and many many other things. Is this correct?
  18. I'm struggling to make it work. I know it's just to name an example. I just felt curious and decided to experiment with it. After hours of trial and error, I couldn't find the issue. It's not working. The script looks like this (server.Lua): function ShowExample() outputChatBox("This is the Server Script!") -- Another very basic message -- triggerClientEvent (source, "Client-ClientTest", source) -- Momentarily disabled. end addCommandHandler ("test", ShowExample) Nothing is happening. No errors, no sentences in chatbox... May I ask one last thing (even though you've already helped me dozens of times over other posts xD)? Would you take a look at it and see if there is anything I'm missing?
  19. I found a way to edit the necessary files without losing my stuff. It's safer but less practical, as there are a lot of resources I am not using; but since I don't know the use of many of the default resources, I would prefer to stay away from the complicated stuff. What I did was create a "Stock MTA" backup, and unzip what I need. So, if I want to mess around with any of the resources, I can simply look for it, unzip everything, edit it, and move it to the original resource. This way, I only tried to get rid of all the vehicle spawns from the gamemode 'play'. It didn't work; apparently, there is something else managing the spawns. I still need to do more research.
  20. First, I began with this: When entering either marker, you are taken to the specified location. It works perfectly. Both markers take me to the desired location in San Andreas' map. I moved them around and changed the shape of the marker just to be sure. There were no problems. Then, I found this: This is supposed to teleport you into the specified interior (nº0), and the coordinates next to the interior (x, y, z) The chatbox outputs the expected message. However, there is no teleporting to the specified place. The function 'setElementInterior' looks good, judging by what the wiki says. What am I missing? Something tells me it's a very obvious error I'm failing to see.
  21. I recently dove into this simple thing called "scripting and building a server". Naturally —added to my already curious personality—, I always come up with a doubt, a question, or any sort of uncertainty. After a week of messing around with it, I noticed that 5 of the 10 last posts made in the Script section were from me. I was having so much fun —truthfully— that I just kept on finding new things to ask. I'm pretty sure they are common questions. I'm not asking to have a script from scratch, or to be taught absolutely everything. It is most commonly about errors and to help myself understand the colloquial language of the scripts. However, I can't help but think that maybe it's not the best approach. I always think to myself "try to find it on your own", but I frenquently find myself getting even more confused the more I tour into each command and function. Is there a certain tacit limit as to how many questions can be asked? Is there any way to get the necessary help without flooding the sections?
  22. Alrighty. I will see what I can do, and how I do with a complete wipe and start from scratch. Thanks for taking the time and patience
×
×
  • Create New...