Jump to content

Xwad

Members
  • Posts

    1,089
  • Joined

  • Last visited

Everything posted by Xwad

  1. And is it possible to fix it with sync?
  2. Hi! I have added some new sounds for vehicles. My problem is that other players cant hear it! Pls help. Thanks in Advance. Maybe need i sync with server? As you can see there are a lot of playSound3D functions, these functions can only hear the local player:/ why?! function onEnter () local vehicle = getPedOccupiedVehicle(localPlayer) local id = getElementModel ( vehicle ) if id == 480 then local x,y,z = getElementPosition(vehicle) local sound_engine = playSound3D("files/engine.wav",x,y,z, true) setSoundMaxDistance( sound_engine, 50 ) setSoundVolume(sound_engine, 0.-- s8) --> attachElements ( sound_engine, vehicle, 0, 0, 0, 0, 0, 0) setElementData (localPlayer, "sound_engine", sound_engine) end end addEventHandler("onClientVehicleEnter", getRootElement(), onEnter) function onExit( thePlayer, seat ) if thePlayer == localPlayer then local model = getElementModel ( source ) if model == 480 then local sound_engine = getElementData ( localPlayer, "sound_engine" ) local sound_track = getElementData ( localPlayer, "sound_track" ) local sound_move = getElementData ( localPlayer, "sound_move" ) local sound_mg = getElementData ( localPlayer, "sound_mg" ) stopSound(sound_engine) if isElement(sound_track) then stopSound(sound_track) end if isElement(sound_move) then stopSound(sound_move) end if isElement(sound_mg) then stopSound(sound_mg) end end end end addEventHandler("onClientVehicleExit",root, onExit) addEventHandler("onClientVehicleExplode",root, onExit) addEventHandler("onClientResourceStop",root, onExit) function projectileSound ( creator ) local zeType = getProjectileType( source ) if zeType == 21 then local veh = getPedOccupiedVehicle(localPlayer) if getElementModel(veh) == 480 then local x,y,z = getElementPosition ( veh ) sound_shoot = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_shoot, 80 ) setSoundVolume(sound_shoot, 1) attachElements ( sound_shoot, veh, 0,0,0 ) end end end addEventHandler( "onClientProjectileCreation", getRootElement(), projectileSound ) function stop_sound() if isPedInVehicle ( localPlayer ) then local vehicle = getPedOccupiedVehicle(localPlayer) local sound_track = getElementData ( localPlayer, "sound_track" ) local sound_start = getElementData ( localPlayer, "sound_start" ) local sound_move = getElementData ( localPlayer, "sound_move" ) local vx,vy,vz = getElementVelocity(vehicle) local id = getElementModel ( vehicle ) if id == 480 then if vx+vy+vz == 0 then if isElement(sound_track) then stopSound(sound_track) removeEventHandler("onClientRender", root, stop_sound) end if isElement(sound_move) then stopSound(sound_move) removeEventHandler("onClientRender", root, stop_sound) end end end end end function stop_sound2() if isPedInVehicle ( localPlayer ) then local vehicle = getPedOccupiedVehicle(localPlayer) local sound_move = getElementData ( localPlayer, "sound_move" ) local id = getElementModel ( vehicle ) if id == 480 then if isElement(sound_move) then stopSound(sound_move) end end end end function start_sound() if isPedInVehicle ( localPlayer ) then local vehicle = getPedOccupiedVehicle(localPlayer) local id = getElementModel ( vehicle ) if id == 480 then if not isElement(sound_track) then local x,y,z = getElementPosition(vehicle) local sound_track = playSound3D("files/tracks.wav",x,y,z, true) setSoundMaxDistance( sound_track, 40 ) setSoundVolume(sound_track, 0.7) attachElements ( sound_track, vehicle, 0,0,0 ) setElementData (localPlayer, "sound_track", sound_track) local sound_start = playSound3D("files/start.wav",x,y,z, false) setSoundMaxDistance( sound_start, 40 ) setSoundVolume(sound_start, 0.5) attachElements ( sound_start, vehicle, 0,0,0 ) setElementData (localPlayer, "sound_start", sound_start) setTimer ( function () if not isElement(sound_move) then local sound_move = playSound3D("files/tank_move.wav",x,y,z, true) setSoundMaxDistance( sound_move, 40 ) setSoundVolume(sound_move, 0.45) attachElements ( sound_move, vehicle, 0,0,0 ) setElementData (localPlayer, "sound_move", sound_move) end end, 200, 1 ) setTimer ( function () addEventHandler("onClientRender", root, stop_sound) end, 50, 1 ) end end end end function bindTheKeys () bindKey ( "w", "down", start_sound ) bindKey ( "s", "down", start_sound ) bindKey ( "w", "up", stop_sound2 ) bindKey ( "s", "up", stop_sound2 ) end addEventHandler("onClientResourceStart",root, bindTheKeys)
  3. Its working now thanks! Thanks to everybody!!
  4. Good idea i try it thanks!
  5. How , where, what? You mean set the rx to rx=math.deg(-rx) ? Becaouse when i tried that than it was rotating to the good direction but it was rotating very fast.
  6. I made this script which creates a weapon and attach it to a vehicle. The weapon will rotate to that direction where the vehicle turret is looking at. The rx is rotating in the wrong direction! When the vehicles barrel Its rotating up then the weapon is rotatimg down, and when the barrel is rotating down then the weapon is rotating up:/ the rz is working correctly! heres the code. Thanks in advance! client.lua function rotate_object(veh) local veh = getPedOccupiedVehicle ( localPlayer ) local _,_,rz = getVehicleComponentRotation(veh, "misc_a") local rx,_,_ = getVehicleComponentRotation(veh, "misc_b") triggerServerEvent("rotate_object", localPlayer, veh,rx,rz, localPlayer) end server.lua function rotate_object(veh,rx,rz) local object = getElementData ( veh, "object" ) local object2 = getElementData ( veh, "object2" ) local weapon = getElementData ( veh, "weapon" ) setElementAttachedOffsets ( object, 0, 0, 0, 0, 7, rz+95) setElementAttachedOffsets ( object2, 0.9, -0.6, 3, 0, rx+0, 0) --<--- this line setElementAttachedOffsets ( weapon, 0.9, -0.6, 3, rx+7, 0) end addEvent("rotate_object", true) addEventHandler("rotate_object", root, rotate_object)
  7. No i dont want to warp the player in other seats. I want to warp the player inside the vehicle. Becaouse i cant enter the vehicle cuz of the skin
  8. I added some skins to vehicles so when i try to enter a vehicle i can cuz of the skin. So i decided to make a script that instantly warps the player into the vehicle when the player is trying to enter it. The only problem is that the player does not warp into the car.. i got no debugscript tanks = { [541]=true,[415]=true,[480]=true,[562]=true,[587]=true } function enterVehicle ( player, seat, jacked ) if ( tanks[getElementModel(source)] ) then outputChatBox ( "enter" ) cancelEvent() local x,y,z = getElementPosition(player) local x,y,z = getElementPosition(source) warpPedIntoVehicle ( player, source ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
  9. one more question: Why is the rx rotating in the wrong direction? it should be rotate up when the tanks turret barrel is rotating up. Its rotating to the opposite direction:/ the rz is working correctly! heres the code. Thanks in advance! client.lua function rotate_object(veh) local veh = getPedOccupiedVehicle ( localPlayer ) local _,_,rz = getVehicleComponentRotation(veh, "misc_a") local rx,_,_ = getVehicleComponentRotation(veh, "misc_b") triggerServerEvent("rotate_object", localPlayer, veh,rx,rz, localPlayer) end server.lua function rotate_object(veh,rx,rz) local object = getElementData ( veh, "object" ) local object2 = getElementData ( veh, "object2" ) local weapon = getElementData ( veh, "weapon" ) setElementAttachedOffsets ( object, 0, 0, 0, 0, 7, rz+95) setElementAttachedOffsets ( object2, 0.9, -0.6, 3, 0, rx+0, 0) setElementAttachedOffsets ( weapon, 0.9, -0.6, 3, rx+7, 0, 0) end addEvent("rotate_object", true) addEventHandler("rotate_object", root, rotate_object)
  10. Xwad

    limited weapons

    Why dont you make a spawn panel for your server instead of freeroam? Its much easier.. players can choose their weapons in the spawn panel
  11. Now i have edit it and its working but its not always exploding cuz sometimes the vehicle does not take any demage:/ for example if i drop the bomb from low height.
  12. Wow zoRRoM! onVehicleDemage is a very good idea! the only problem is that its exploding immediatelly.. maybe becaouse the object is demaging it?
  13. And is the event also triggering if i am not inside the vehicle? I dont want it for plane, i want it for the car "alpha" (id: 602)
  14. Okay:D Yeah that would be very good, thanks!
  15. Or is it possible to blow the vehicle when its hitting a world object?
  16. I got no debug:( i edited a little bit the script but its still not working:/ Timers = {} function attach(playerSource, commandName) local theVehicle = getPedOccupiedVehicle ( playerSource ) if theVehicle then x,y,z = getElementPosition(theVehicle) rx,ry,rz = getVehicleRotation(theVehicle) missle = createObject(3786,x,y,z,rx,ry,rz) attachElements(missle,theVehicle,0,0,-1.1,0,0,-90) end end function detach(playerSource, commandName) local theVehicle = getPedOccupiedVehicle ( playerSource ) if theVehicle then x,y,z = getElementPosition(playerSource) rx,ry,rz = getVehicleRotation(getPedOccupiedVehicle(playerSource)) vx,vy,vz = getElementVelocity(getPedOccupiedVehicle(playerSource)) detachElements(missle) veh = createVehicle(602, x,y,z-2,rx,ry,rz) setElementVelocity(veh,vx,vy,vz) --setElementAlpha ( veh, 0 ) attachElements(missle,veh,0,0,0,0,0,270) for i = 1,50 do if Timers[i] == nil then Timers[i] = setTimer(checkBlow, 100,500, veh, playerSource, i) break end end end end function checkBlow(veh, playerSource, index) vx,vy,vz = getElementVelocity(veh) if isPedInVehicle(playerSource) then outputChatBox("checkBlow", source, 0, 0, 200) if vx+vy+vz == 0 then outputChatBox("blow", source, 255, 0, 0) local x,y,z = getElementPosition(vehicle) Timers[index] = nil blowVehicle(vehicle) else outputDebugString("Velocity: ".. (vx+vy+vz)) end end end addCommandHandler("a", attach) addCommandHandler("d", detach)
  17. This script makes possible to drop bombs from planes. My problem is that the bomb is not exploding when its velocity is 0 pls help! SERVER SIDED Timers = {} function attach(playerSource, commandName) if isPedInVehicle(playerSource) == true then x,y,z = getElementPosition(playerSource) rx,ry,rz = getVehicleRotation(getPedOccupiedVehicle(playerSource)) missle = createObject(3786,x,y,z,rx,ry,rz) --attachElements(vehicle,getPedOccupiedVehicle(playerSource),0,0,-1.7,rz,ry,rz) attachElements(missle,getPedOccupiedVehicle(playerSource),0,0,-1.1,0,355,270) end end function detach(playerSource, commandName) if isPedInVehicle(playerSource) == true then x,y,z = getElementPosition(playerSource) rx,ry,rz = getVehicleRotation(getPedOccupiedVehicle(playerSource)) detachElements(missle) vx,vy,vz = getElementVelocity(getPedOccupiedVehicle(playerSource)) vehicle = createVehicle(602, x,y,z-2,rx,ry,rz) setElementVelocity(vehicle,vx,vy,vz) setElementAlpha ( vehicle, 0 ) attachElements(missle,vehicle,0,0,0,0,0,270) for i = 1,50 do if Timers[i] == null then Timers[i] = setTimer(checkBlow, 100,500, vehicle, playerSource, i) break end end end end function checkBlow(vehicle, thePlayer, index) vx,vy,vz = getElementVelocity(vehicle) vehicle1x, vehicle1y, vehicle1z = getElementPosition ( vehicle ) if isPedInVehicle(thePlayer) then vehicle2x, vehicle2y, vehicle2z = getElementPosition ( getPedOccupiedVehicle(thePlayer) ) outputChatBox("checkBlow", source, 0, 0, 200) if vx+vy+vz == 0 then outputChatBox("blow", source, 255, 0, 0) local x,y,z = getElementPosition(vehicle) createExplosion ( x+5,y+5,z, 10) Timers[index] = null blowVehicle(vehicle) end end end addCommandHandler("a", attach) addCommandHandler("d", detach)
  18. really??! You mean theres the same script in the dayz gamemode?
  19. really??! You mean theres the same script in the dayz gamemode?
  20. yes its good now:D Thanks!
  21. yes its good now:D Thanks!
  22. its wokring with all vehicles expect the rhino
×
×
  • Create New...