Jump to content

Sergo86

Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by Sergo86

  1. Ok, thx, maybe there is some sort of example?
  2. Hello, please tell me how to organize the synchronization of the movement of an object between two players in 3D, like this L
  3. Держи звук надеюсь найдешь) function updateEngineSound() -- We get a table of all vehicles on the server: local allVehicles = getElementsByType("vehicle") -- we then do a loop that will iterate over that table: for index, veh in ipairs (allVehicles) do --It's like saying: "For each vehicle, do this" -- we get the model of the vehicle local model = getElementModel(veh) -- if the model is equal to 411 then do this if model == 411 then -- if the engine is on if getVehicleEngineState(veh) then -- we get the position of that vehicle local x, y, z = getElementPosition(veh) -- we then try to get the sound we maybe created and stored as an element data -- for that vehicle. If we didn't yet, then it will return false. local sound = getElementData(veh, "engineSound") -- if the inverse of sound is true (same as: if sound is equal to false) -- Note that "not false" will give true if not sound then -- we create the sound at the veh position and loop it sound = playSound3D("sounds/song.mp3", x, y, z, true) -- we store that sound in an element data I decided to call "engineSound" setElementData(veh, "engineSound", sound) end -- if the sound is paused (because the engine was off) then if isSoundPaused(veh) then -- we "unpause" the sound setSoundPaused(sound, false) end -- we then need to get the speed local velocityX, velocityY, velocityZ = getElementVelocity(veh) -- calculate the global speed in mph from the 3 velocities: -- use pythagorean theorem to get actual velocity -- raising something to the exponent of 0.5 is the same thing as taking a square root. local actualspeed = (velocityX^2 + velocityY^2 + velocityZ^2)^(0.5) -- multiply by 50 to obtain the speed in meters per second and -- then by 111.847 to obtain the speed in meters per hour local mph = actualspeed * 50 * 111.847 -- we try to calculate the sound speed according to the mph -- I guess 80mph is the speed that the original sound sounds like and -- I also guess 0.25 is the min speed that the sound can be at to still sounds like an engine. -- I added 80/minSoundSpeed to 80 to compensate the minSoundSpeed we added local minSoundSpeed = 0.25 local soundSpeed = mph/(80+80/minSoundSpeed) + minSoundSpeed -- and then we apply it to the sound setSoundSpeed (sound, soundSpeed) -- and finally update the sound position to follow the vehicle setElementPosition(sound, x, y, z) else -- otherwise (so if the engine is off) -- we pause the sound setSoundPaused(sound, true) end -- close the "if engine was on" end -- close the "if model was 411" end -- end of the loop end setTimer(updateEngineSound, 50, 0) --repeat that function every 50 ms
  4. Hi all) how to use this script ? please help , I do not understand how to use it.
  5. I have everything working, but debug swears Here is the complete script with sound --> http://rghost.ru/52566320
  6. Read my post above. @SERGEY86RUS: Who dafuq are you ?! Didn't even noticed you weren't the guy I was helping since the begining nor the author of this thread. what it means dafug ???? i don't understand))
  7. again error, 58 lines bad 'sound/player' pointer @ 'SetSoundPaused'(1)
  8. works, but swears debug, that's what gives: 29 lines bad 'sound/player' pointer @ 'isSoundPaused'(1)
  9. Ну незнаю тогда почему шрифты тупили, но именно после того как я прописал атрибут client всё сразу заработало Без client шрифты работали, но только с английской раскладкой, с русской нефига
  10. Короче всё я разобрался) Ошибка была в мете: я вместо этого писал это . Короче не указал что клиент и всё)) Memory тебе тоже спс
  11. Короче вот такая беда: русские буквы мелкие, а английские нормальные(новый шрифт). В чём проблема? Почему русские буквы не отображаются нормально с помощью нового шрифта?? Помогите плз Я использовал guiCreateFont, guiSetFont, guiSetText, guiCreateLabel Может кому и пригодится в поиске проблемы)
  12. а что мне нужно сделать , чтобы исправить это??
  13. Пишет это onclientrender with this function is already handled , в строке 109. И ещё звук пропадает)). Помогите решить. local engine_sound = "files/engine.wav" local idle_soundfile = "files/engine_idle.wav" local sound = nil local idle_sound = nil function getVehicleRPM(vehicle) if (vehicle) then if (isVehicleOnGround(vehicle)) then if (getVehicleEngineState(vehicle) == true) then if(getVehicleCurrentGear(vehicle) > 0) then vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/getVehicleCurrentGear(vehicle))*220) + 0.5) if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end else vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/1)*220) + 0.5) if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end end else vehicleRPM = 0 end else if (getVehicleEngineState(vehicle) == true) then vehicleRPM = vehicleRPM - 150 if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end else vehicleRPM = 0 end end return tonumber(vehicleRPM) else return 0 end end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function engine_func() local veh = getPedOccupiedVehicle ( getLocalPlayer()) if veh then if getElementModel ( veh ) == 411 then if getVehicleEngineState ( veh ) == true then if getElementSpeed ( veh, "kmh" ) > 10 then if idle_sound then destroyElement ( idle_sound ) idle_sound = nil end if sound == nil then sound = playSound3D ( engine_sound, 0, 0, 0, true ) attachElements ( sound, veh ) end setSoundSpeed ( sound, getVehicleRPM(veh)/10000 ) elseif getElementSpeed ( veh, "kmh" ) < 10 then if idle_sound == nil then idle_sound = playSound3D ( idle_soundfile, 0, 0, 0, true ) setSoundVolume ( idle_sound, 0.2 ) attachElements ( idle_sound, veh ) end elseif getElementSpeed ( veh, "kmh" ) == 0 then if sound then destroyElement ( sound ) sound = nil end end else if sound then destroyElement ( sound ) sound = nil end if idle_sound then destroyElement ( idle_sound ) idle_sound = nil end end end end end addEventHandler ( "onClientVehicleEnter", getRootElement(), function() if getElementModel ( source ) == 411 then setWorldSoundEnabled( 40, false ) addEventHandler ( "onClientRender", getRootElement(), engine_func ) end end) addEventHandler ( "onClientVehicleExit", getRootElement(), function() if getElementModel ( source ) == 411 then setWorldSoundEnabled( 40, true ) removeEventHandler ( "onClientRender", getRootElement(), engine_func ) end end)
  14. This script replaces the sound of Infernus. The problem is that when I made one Infernus sound works when will create 1 more Infernus sound disappears, even the standard. Help fix client side local engine_sound = "files/engine.wav" local idle_soundfile = "files/engine_idle.wav" local sound = nil local idle_sound = nil function getVehicleRPM(vehicle) if (vehicle) then if (isVehicleOnGround(vehicle)) then if (getVehicleEngineState(vehicle) == true) then if(getVehicleCurrentGear(vehicle) > 0) then vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/getVehicleCurrentGear(vehicle))*220) + 0.5) if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end else vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/1)*220) + 0.5) if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end end else vehicleRPM = 0 end else if (getVehicleEngineState(vehicle) == true) then vehicleRPM = vehicleRPM - 150 if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end else vehicleRPM = 0 end end return tonumber(vehicleRPM) else return 0 end end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function engine_func() local veh = getPedOccupiedVehicle ( getLocalPlayer()) if veh then if getElementModel ( veh ) == 411 then if getVehicleEngineState ( veh ) == true then if getElementSpeed ( veh, "kmh" ) > 10 then if idle_sound then destroyElement ( idle_sound ) idle_sound = nil end if sound == nil then sound = playSound3D ( engine_sound, 0, 0, 0, true ) attachElements ( sound, veh ) end setSoundSpeed ( sound, getVehicleRPM(veh)/10000 ) elseif getElementSpeed ( veh, "kmh" ) < 10 then if idle_sound == nil then idle_sound = playSound3D ( idle_soundfile, 0, 0, 0, true ) setSoundVolume ( idle_sound, 0.2 ) attachElements ( idle_sound, veh ) end elseif getElementSpeed ( veh, "kmh" ) == 0 then if sound then destroyElement ( sound ) sound = nil end end else if sound then destroyElement ( sound ) sound = nil end if idle_sound then destroyElement ( idle_sound ) idle_sound = nil end end end end end addEventHandler ( "onClientVehicleEnter", getRootElement(), function() if getElementModel ( source ) == 411 then setWorldSoundEnabled( 40, false ) addEventHandler ( "onClientRender", getRootElement(), engine_func ) end end) addEventHandler ( "onClientVehicleExit", getRootElement(), function() setWorldSoundEnabled( 40, true ) removeEventHandler ( "onClientRender", getRootElement(), engine_func ) end)
  15. Этот скрипт заменяет звук у инфернуса. Проблема в том что когда создал 1 инфернус звук пашет, когда создашь ещё 1 инфернус звук пропадает , даже стандартный. Помогите исправить Сторона клиент local engine_sound = "files/engine.wav" local idle_soundfile = "files/engine_idle.wav" local sound = nil local idle_sound = nil function getVehicleRPM(vehicle) if (vehicle) then if (isVehicleOnGround(vehicle)) then if (getVehicleEngineState(vehicle) == true) then if(getVehicleCurrentGear(vehicle) > 0) then vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/getVehicleCurrentGear(vehicle))*220) + 0.5) if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end else vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/1)*220) + 0.5) if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end end else vehicleRPM = 0 end else if (getVehicleEngineState(vehicle) == true) then vehicleRPM = vehicleRPM - 150 if (vehicleRPM < 650) then vehicleRPM = math.random(650, 750) elseif (vehicleRPM >= 9800) then vehicleRPM = 9800 end else vehicleRPM = 0 end end return tonumber(vehicleRPM) else return 0 end end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function engine_func() local veh = getPedOccupiedVehicle ( getLocalPlayer()) if veh then if getElementModel ( veh ) == 411 then if getVehicleEngineState ( veh ) == true then if getElementSpeed ( veh, "kmh" ) > 10 then if idle_sound then destroyElement ( idle_sound ) idle_sound = nil end if sound == nil then sound = playSound3D ( engine_sound, 0, 0, 0, true ) attachElements ( sound, veh ) end setSoundSpeed ( sound, getVehicleRPM(veh)/10000 ) elseif getElementSpeed ( veh, "kmh" ) < 10 then if idle_sound == nil then idle_sound = playSound3D ( idle_soundfile, 0, 0, 0, true ) setSoundVolume ( idle_sound, 0.2 ) attachElements ( idle_sound, veh ) end elseif getElementSpeed ( veh, "kmh" ) == 0 then if sound then destroyElement ( sound ) sound = nil end end else if sound then destroyElement ( sound ) sound = nil end if idle_sound then destroyElement ( idle_sound ) idle_sound = nil end end end end end addEventHandler ( "onClientVehicleEnter", getRootElement(), function() if getElementModel ( source ) == 411 then setWorldSoundEnabled( 40, false ) addEventHandler ( "onClientRender", getRootElement(), engine_func ) end end) addEventHandler ( "onClientVehicleExit", getRootElement(), function() setWorldSoundEnabled( 40, true ) removeEventHandler ( "onClientRender", getRootElement(), engine_func ) end)
  16. Спасибо kenix, а ты не мог бы показать как вставить всё это в мой код?
  17. Сори что не правильно задал вопрос).Я имел в виду то как в этот код добавить удаление объектов, например если объекты созданы командой их удалить)
  18. Помогите пожалуйста, не могу удалить созданый объект.Подскажите как правильно сделать удаление объекта. Код function attachNeon1( thePlayer ) if not isPedInVehicle( thePlayer ) then return end local vehicle = getPedOccupiedVehicle( thePlayer ) local obj1a = createObject( 16783, 0, 0, 0, 0, 0, 0 ) -- Создаем объект local obj2a = createObject( 16783, 0, 0, 0, 0, 0, 0 ) -- Создаем объект attachElements( obj1a, vehicle, 0.8, 0.1, -0.5 ) -- Тут настраиваем положение объекта (: attachElements( obj2a, vehicle, -0.8, 0.1, -0.5 ) -- Тут настраиваем положение объекта (: end addCommandHandler( "neon1", attachNeon1 )
  19. Я понимаю)просто подобное видел.
  20. А как указать для определённого авто?
  21. Кто нибудь может подсказать как заменить звук двигателя, к примеру у infernus?
  22. Помогите сделать маркер при въезде на него пишет bar argument?
  23. А как можно прибавить настройки к текущим?
×
×
  • Create New...