Sergo86
Members-
Posts
58 -
Joined
-
Last visited
Sergo86's Achievements
Snitch (10/54)
0
Reputation
-
Hello, please tell me how to organize the synchronization of the movement of an object between two players in 3D, like this L
-
Держи звук надеюсь найдешь) 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
-
Hi all) how to use this script ? please help , I do not understand how to use it.
-
I have everything working, but debug swears Here is the complete script with sound --> http://rghost.ru/52566320
-
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))
-
again error, 58 lines bad 'sound/player' pointer @ 'SetSoundPaused'(1)
-
works, but swears debug, that's what gives: 29 lines bad 'sound/player' pointer @ 'isSoundPaused'(1)
-
Ну незнаю тогда почему шрифты тупили, но именно после того как я прописал атрибут client всё сразу заработало Без client шрифты работали, но только с английской раскладкой, с русской нефига
-
Короче всё я разобрался) Ошибка была в мете: я вместо этого писал это . Короче не указал что клиент и всё)) Memory тебе тоже спс
-
Короче вот такая беда: русские буквы мелкие, а английские нормальные(новый шрифт). В чём проблема? Почему русские буквы не отображаются нормально с помощью нового шрифта?? Помогите плз Я использовал guiCreateFont, guiSetFont, guiSetText, guiCreateLabel Может кому и пригодится в поиске проблемы)
-
а что мне нужно сделать , чтобы исправить это??
-
Пишет это 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)
-
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)