-
Posts
33 -
Joined
-
Last visited
Everything posted by Crook4Money
-
[Question] How do you get PlaySound3D to follow
Crook4Money replied to Crook4Money's topic in Scripting
Interesting formatting. It worked. tyty. -
I made a script that I had to restart from scratch due to not backing it up and completely breaking it. When the script was in a better state I could get the sound to follow the vehicle I was driving, but I can't seem to get that to happen again. function startMySound(thePlayer) if ( isPedInVehicle ( thePlayer ) ) then local vehicle = getPedOccupiedVehicle(thePlayer) local x,y,z = getElementPosition( vehicle ) playSound3D( "sound1.mp3", x, y, z, true ) end end addEventHandler( "onClientVehicleEnter", root, startMySound ) From what I tried to remember from the last script setting the x,y,z to the vehicle was allowing the sound to follow the vehicle using the local coordinates, but the sound now just starts at the car and stays where the sound started playing. How do I get it to track your position? Edit: Come to think of it I couldn't get PlaySound3D to work at all with the original script for whatever reason and instead used PlaySound which would follow the player by default. So I guess I never had this working to begin with.
-
I just didn't know you could set a separate timer within a single function. I tried it a couple times before, but it didn't work for whatever reason. Maybe my pointless return values were messing something up.
-
I had to try about a couple hundred different variables to get what I wanted, but I finally got it using my previous script. function moveDoor(player, vehicle) local vehicle = getPedOccupiedVehicle(player) local money = getPlayerMoney(player) if ( money >= 200 ) and getElementHealth(vehicle) < 1000 then local move = moveObject(door1, moveTime, 2071.5, -1831.4000244141, 14.60000038147, 0, 90, 0) triggerClientEvent("doorSound", resourceRoot) if move then isMoving = false setTimer(moveDoor, moveTime, 1, true) end setTimer(function() moveObject(door1, moveTime, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) isMoving = false triggerClientEvent("doorSound", resourceRoot) end, 6000, 1) end end addEventHandler("onMarkerHit", marker1, moveDoor) Function thing may be wrong again, but whatever. It works.
-
I just need door 2 to trigger after the first. The reason I'm having issues though is that the second door is on a timer where as the first door isn't. Also they're the same door. It goes up and then down.
-
Unfortunately the changes made have the same result. The second door still isn't responding correctly. It's actually responding the exact same way as it was previously. This was the change I needed to work. I don't know how to get it to respond to the second line of script as I was actually asking this question originally. setTimer(door2, moveTime, 1, true)--This will trigger door2 after moveTime is over Edit: Before this post door 1 was responding correctly and door 2 was either responding incorrectly or not at all. After the changes this is still the case.
-
I use the wiki everytime I have a problem. I guess I just messed up the vehicle part as I was copying it from the beginning of my script that does something entirely different. function moveDoor(hitElement, dimension) I'm also completely oblivious to the use of the words in the ( ) as well which has been causing me issues for quite some time.
-
That was just the part of the script I was having issues with. The entire script is 81 lines.
-
I'm basically trying to tell one function that if another function happens to go ahead and do the thing. function moveDoor(player, vehicle) local vehicle = getPedOccupiedVehicle(player) local money = getPlayerMoney(player) if ( money >= 200 ) and getElementHealth(vehicle) < 1000 then if isMoving then return end if source == marker1 then local move = moveObject(door1, moveTime, 2071.5, -1831.4000244141, 14.60000038147, 0, 90, 0) triggerClientEvent("doorSound", resourceRoot) if move then isMoving = false setTimer(moveDoor, moveTime, 1, true) end end end end addEventHandler("onMarkerHit", marker1, moveDoor) function door2(player, vehicle) setTimer(function() if moveDoor = true then moveObject(door1, moveTime, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) isMoving = false triggerClientEvent("doorSound", resourceRoot) end end, 6000, 1) end addEventHandler("onMarkerHit", marker1, door2) I'm trying to do this as the second door function is giving me problems so bypassing the whole "trying to get it to work similarly" would be great if I could just tell it to start if the first door function starts. My problem with duplicating the scripts which wasn't a problem when I first did it, but then became one is that it says that I'm trying to attach numbers to booleans, nils or even that the player element is registering as a vehicle.
-
How would you go about showing the radius on the map?
-
Ah, I thought I'd have to use a ColShape which is what I was trying before. This was a lot more complex than I originally thought. lol Nice. It works just as I wanted it to. Thanks.
-
Can anyone show me a simple script for making a player lose health if he's in a marker or something. I can't seem to get the player to lose health that way. Basically trying to go for a zone method like PUBG where you lose health over time in a circle.
-
That was kind've the problem I guess. I copied one of your guys scripts that had the argument like this. local vehHealth = getElementHealth( theVehicle ) I had to change all of "theVehicle"s to just "vehicle". I finally got my script working as it should now with a ton of trying to do workarounds till I figured out why the element wasn't established. I'm not sure in which cases you'd use "theVehicle", but I know that it works cos I tried MOG's script and it was functional in his. Maybe I'm just missing something with that. Idk. Was funny tho cos I actually rebuilt my script in a different structure and tho it was pointless what I needed it to do came out better and more consistent. Probably. Only messing around with scripting for a month or two is pretty tough especially just getting into creating my own script for once and getting into the use of else/if. I definitely wouldn't have been able to get my script to function the way I wanted to without your guys help. Thanks
-
When I try to use local vehHealth = getElementHealth( theVehicle ) if vehHealth >= 999 then or if getElementHealth(vehicle) < 1000 then in my script I keep getting an error "attempt to compare number with boolean."
-
Ah, thanks. I was curious if other markers would interact the same way. I was just using root as a placeholder for not knowing what I'm doing. I'll try to implement this tomorrow. I like the simplicity of it anyways and doesn't seem to cause as many issues as I was having earlier.
-
Edited last post too many times. Cut out a bit of the script and messed it up and had to fix it. It's supposed to look like this. I tried to add "if getElementHealth(vehicle) < 1000 then" but I couldn't get it to output "Vehicle is already repaired." using else/ifs. I just got a botched script if I added element data to get that output. Otherwise it told me I wasn't in a vehicle when I was. I'll try to recreate that script. I just wanted to post this here before I broke the script again. local door1 = createObject(5422, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) local marker1 = createMarker(2063.5, -1831.1999511719, 13, "cylinder",6,225,225,255,20) local isMoving = false local moveTime = 1000 local doorDown = 5000 function repairVehicle ( thePlayer, commandName) setTimer ( function() if ( isPedInVehicle ( thePlayer ) ) then local vehicle = getPedOccupiedVehicle(player) local money = getPlayerMoney(thePlayer) if ( money >= 200 ) then takePlayerMoney(thePlayer, 200) outputChatBox (" Your vehicle is restored. ", thePlayer, 0, 200, 0 ) local theVehicle = getPedOccupiedVehicle ( thePlayer) local fix = fixVehicle ( theVehicle ) if (money < 200) then fixVehicle ( theVehicle ) return false end else outputChatBox ( "Failed to fix your vehicle.", thePlayer) end else outputChatBox ( "You're not in a vehicle!", thePlayer, 200, 0, 0 ) end end, 5000, 1) end addEventHandler("onMarkerHit", root, repairVehicle) function moveDoor(player) if isMoving then return end if source == marker1 then local move = moveObject(door1, moveTime, 2071.5, -1831.4000244141, 14.60000038147, 0, 90, 0) if move then isMoving = false setTimer(moveDoor, moveTime, 1, true) end end end addEventHandler("onMarkerHit", root, moveDoor) function door2() setTimer(function() moveObject(door1, moveTime, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) isMoving = false end, 6000, 1) end addEventHandler("onMarkerHit", root, door2)
-
Looks like this now. local door1 = createObject(5422, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) local marker1 = createMarker(2063.5, -1831.1999511719, 13, "cylinder",6,225,225,255,20) local isMoving = false local moveTime = 1000 local doorDown = 5000 function repairVehicle ( thePlayer, commandName) setTimer ( function() if ( isPedInVehicle ( thePlayer ) ) then if ( money >= 200 ) then takePlayerMoney(thePlayer, 200) outputChatBox (" Your vehicle is restored. ", thePlayer, 0, 200, 0 ) local theVehicle = getPedOccupiedVehicle ( thePlayer) local fix = fixVehicle ( theVehicle ) local money = getPlayerMoney(thePlayer) if (money < 200) then fixVehicle ( theVehicle ) return false end else outputChatBox ( "Failed to fix your vehicle.", thePlayer) end else outputChatBox ( "You're not in a vehicle!", thePlayer, 200, 0, 0 ) end end, 5000, 1) end addEventHandler("onMarkerHit", root, repairVehicle) function moveDoor(player) if isMoving then return end if source == marker1 then local move = moveObject(door1, moveTime, 2071.5, -1831.4000244141, 14.60000038147, 0, 90, 0) if move then isMoving = false setTimer(moveDoor, moveTime, 1, true) end end end addEventHandler("onMarkerHit", root, moveDoor) function door2() setTimer(function() moveObject(door1, moveTime, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) isMoving = false end, 6000, 1) end addEventHandler("onMarkerHit", root, door2)
-
I just realized that I had the lines in the wrong places. Money should've been first and if there wasn't enough money then it shouldn't fix the vehicle. Crazy it took me several hours to figure that out. lol I like how you set the vehicle damage to not fix a repaired vehicle. Trying to work that into my script now.
-
I've been trying to make a functioning pay & spray, but have finally came to a problem trying to figure out how to use the else/if. Basically I've gotten the pay and spray to function the way I want it to, but I can't figure out how to keep it from taking money when you don't have enough and how to make it also not fix the vehicle when you don't have enough money. local door1 = createObject(5422, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) local marker1 = createMarker(2063.5, -1831.1999511719, 13, "cylinder",6,225,225,255,20) local isMoving = false local moveTime = 1000 local doorDown = 5000 local playerMoney = false function repairVehicle ( thePlayer, commandName) setTimer ( function() if ( isPedInVehicle ( thePlayer ) ) then local theVehicle = getPedOccupiedVehicle ( thePlayer) local fix = fixVehicle ( theVehicle ) if ( fix ) then takePlayerMoney(thePlayer, 200) outputChatBox (" Your vehicle is restored. ", thePlayer, 0, 200, 0 ) local money = getPlayerMoney(thePlayer) if (money < 200) then return false end elseif outputChatBox ( "Failed to fix your vehicle.", thePlayer) then givePlayerMoney(thePlayer, 200) end else outputChatBox ( "You're not in a vehicle!", thePlayer, 200, 0, 0 ) end end, 5000, 1) end addEventHandler("onMarkerHit", root, repairVehicle) function moveDoor(player) if isMoving then return end if source == marker1 then local move = moveObject(door1, moveTime, 2071.5, -1831.4000244141, 14.60000038147, 0, 90, 0) if move then isMoving = false setTimer(moveDoor, moveTime, 1, true) end end end addEventHandler("onMarkerHit", root, moveDoor) function door2() setTimer(function() moveObject(door1, moveTime, 2072.5, -1831.4200244141, 16.5, 0, -90, 0) isMoving = false end, 6000, 1) end addEventHandler("onMarkerHit", root, door2)
-
I just recently realized the world remover in the map editor can remove the entire map, but not all the objects like misc type objects can be removed. How would you go about the removal of objects that don't seem to be picked up by the world remover?
-
Yeah, luckily I only had a toll booth in the map and had an older version of my script that took only about 15min to correct. Just started with a fresh map since the previous one would no longer load and had a backup test map so I could get the coordinates for all my vehicles for use in a script. All in all was quite the learning experience.
-
I see now that if you save over the map in the editor it deletes your resources. Least I have an explanation for that. Guess just not saving in the editor would solve that problem.
-
I had things added to my map via the map editor and I scripted a toll booth in it as well which was working. When I went to add an additional script to my working toll both the map stopped loading and my script got deleted somehow. On top of that none of the vehicles will load in that I put in via the map editor unless I'm using the map editor now. I have no idea what happened. How do I keep that from happening again?
-
Ah, I thought it was a custom panel. I changed the interface before, but I guess I didn't realize you had to click "Ok" for it to show. Ended up downloading the black version and using that. lol