Orkhan Posted August 8, 2013 Share Posted August 8, 2013 При переключение скоростей глушитель начинает стрелять огнём,турбина кароче backfire_client local fxShowValTest = false local curEngine = 0 function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z 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 getVectors(x, y, z, x2, y2, z2) return x - x2, y - y2, z-z2; end function createBackFire(theVeh, scx, scy, scz) local fireChords={} local dist = 0.04 for i = 1, 6 do local x, y, z = getPositionFromElementOffset(theVeh,scx,scy-dist,scz) fireChords[i]= {pX = x, pY = y, pZ = z} dist = dist + 0.2 end local x,y,z = getPositionFromElementOffset(theVeh,scx,scy,scz) local x2,y2,z2 = getPositionFromElementOffset(theVeh,scx,0,scz) local v1, v2, v3 = getVectors(x,y,z, x2,y2,z2) for i, val in ipairs(fireChords) do fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1+1.5,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1-1.5,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3-0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+1,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+10,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-10,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-1,v3+0.8, true) end local s = playSound3D("sound/backfire2.wav", x,y,z, false) setSoundMaxDistance( s, 80 ) setSoundVolume(s, 0.5) end function chandeMonitoringState(state,veh) if (state) then theVehicle = veh addEventHandler ( "onClientPreRender", root, monitorCurEngine ) else removeEventHandler ( "onClientPreRender", root, monitorCurEngine ) theVehicle=nil theTestVehicle=nil end end addEvent ( "chandeMonitoringState", true ) addEventHandler ( "chandeMonitoringState", getRootElement(), chandeMonitoringState) --[[ addEventHandler("onClientPlayerVehicleExit",getRootElement(), function(theVeh, seat) if ( seat==0 ) then theVehicle = nil theTestVehicle=nil removeEventHandler ( "onClientPreRender", root, monitorCurEngine ) end end ) ]] addCommandHandler("devm", function(cmd, val) if tonumber(val) == 0 then removeEventHandler ( "onClientPreRender", root, testMode ) removeEventHandler("onClientKey", root, playerPressedKey) else theTestVehicle = getPedOccupiedVehicle ( localPlayer ) if theTestVehicle then tpx, tpy, tpz = 0, 0, 1 if fxShowValTest then --fxShowValTest = false --removeEventHandler ( "onClientPreRender", root, testMode ) else fxShowValTest = true addEventHandler ( "onClientPreRender", root, testMode ) addEventHandler("onClientKey", root, playerPressedKey) end else outputChatBox("get in vehicle!!!", 255,0,0) end end end) local step = 0.2 function playerPressedKey(button, press) if button == "arrow_u" or button == "arrow_d" or button == "arrow_r" or button == "arrow_l" then local curstep = step if (press) then if getKeyState( "lalt" ) == true or getKeyState( "ralt" ) == true then curstep=step/2 end if button == "arrow_u" then if getKeyState( "lctrl" ) == true or getKeyState( "rctrl" ) == true then tpy = tpy+curstep else tpz = tpz+curstep end elseif button == "arrow_d" then if getKeyState( "lctrl" ) == true or getKeyState( "rctrl" ) == true then tpy = tpy-curstep else tpz = tpz-curstep end elseif button == "arrow_l" then tpx = tpx-curstep elseif button == "arrow_r" then tpx = tpx+curstep end outputChatBox("x= "..tostring(tpx).." y= "..tostring(tpy).." z= "..tostring(tpz), 255,255,0) end end end function testMode() local x, y, z = getPositionFromElementOffset(theTestVehicle,tpx, tpy, tpz) local x2, y2, z2 = getPositionFromElementOffset(theTestVehicle,tpx, 0, tpz) local v1, v2, v3 = getVectors(x, y, z, x2, y2, z2) fxAddGunshot(x, y, z, v1,v2,v3, true) end local refreshTime = 50 --ms local aLastCheck = 0 function monitorCurEngine() if ( getTickCount() >= aLastCheck ) then local cur = tonumber(getVehicleCurrentGear (theVehicle)) if ( cur ~= curEngine ) then if (tonumber(getElementSpeed(theVehicle, "kph")) > 5 ) then triggerServerEvent ( "create3DBackfireSound", root, theVehicle) curEngine = cur end end aLastCheck = getTickCount() + refreshTime end end addEvent ( "create3DBackfireSoundClient", true ) addEventHandler ( "create3DBackfireSoundClient", getRootElement(), createBackFire) backfire_settings <vehs_setting> <!-- name: имя машины(Смотреть в WIKI), x y z: позиция вырывающегося огня, относительно машины. x - расстояние влево, y - расстояние вперед, z - расстояние вверх P.S. Советую от найденого y отнимать 1 (для лучшей отображаемости) --> <veh name="Hotring Racer" x="0.55" y="-1.6" z="-0.3" /> <veh name="Hotring Racer 2" x="-0.55" y="-1.4" z="-0.45" /> <veh name="Hotring Racer 3" x="-0.55" y="-1.4" z="-0.6" /> <veh name="Club" x="-0.55" y="-1.4" z="-0.6" /> </vehs_setting> sound sound папка тоже есть там backfire1 и backfire2 (вот не смог и его сюда на форм залить(звуки)) Link to comment
Flaker Posted August 8, 2013 Share Posted August 8, 2013 Вот эта говнокод... Криворукий какой-то писал... Таких вообще нельзя к коду даже близко подпускать... Поколение деградирует... Рашка разваливается... Нашим флагом уже подтираются панк, мать его, группы... Вот тебе серверная часть, и можешь не спрашивать откуда я это взял: local CarsSettings = {} function setElementSpeed(element, unit, speed) if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) return true end return false 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 addEventHandler ( "onResourceStart", resourceRoot, function ( ) local StationsFile = xmlLoadFile ( "backfire_settings.xml" ) if ( StationsFile ) then outputDebugString ( "backfire_settings.xml successfully open") for _, data in ipairs ( xmlNodeGetChildren ( StationsFile ) ) do local attrs = xmlNodeGetAttributes ( data ) CarsSettings[tostring(attrs.name)] = { x = tonumber(attrs.x), y = tonumber(attrs.y), z = tonumber(attrs.z) } end else outputDebugString ( "Failed to open to backfire_settings.xml", 1 ) end end ) addEvent ( "create3DBackfireSound", true ) addEventHandler ( "create3DBackfireSound", root, function ( theVehicle) if ( theVehicle ) then local vehicleName = getVehicleName( theVehicle ) if ( type(CarsSettings[vehicleName]) == "table" ) then local x, y, z = tonumber(CarsSettings[vehicleName].x), tonumber(CarsSettings[vehicleName].y), tonumber(CarsSettings[vehicleName].z); triggerClientEvent(root, "create3DBackfireSoundClient", root, theVehicle, x, y, z) end end end ) function startMonitoring ( thePlayer, seat, jacked ) if (seat == 0) then triggerClientEvent(thePlayer, "chandeMonitoringState", thePlayer, true, source) end end addEventHandler ( "onVehicleEnter", getRootElement(), startMonitoring ) function stopMonitoring ( thePlayer, seat, jacked ) if (seat == 0) then triggerClientEvent(thePlayer, "chandeMonitoringState", thePlayer, false) end end addEventHandler ( "onVehicleExit", getRootElement(), stopMonitoring ) Link to comment
Scripting Moderators Sarrum Posted August 8, 2013 Scripting Moderators Share Posted August 8, 2013 Чтож Вы за человек такой, Orkhan... Не стыдно воровать клиент часть? Это еще добрый Flaker поделился своим творением, другой бы отпинал Вас. Link to comment
gold4iter Posted August 8, 2013 Share Posted August 8, 2013 Да уж за воровство есть статья) А я не знал что скрипты грузятся на клиента. Думал всё на стороне сервера. Link to comment
Orkhan Posted August 8, 2013 Author Share Posted August 8, 2013 Flaker Спасибо большое за сервер файл,но у меня почему то не работает не находит ресурс может в мете ошибка ? meta <meta> <info author="Name" version="1.0.0" type="misc" /> <script src="backfire_client.lua" type="client"/> <script src="backfire_server.lua" type="server"/> <config src="backfire_settings.xml"/> <file src="sounds/backfire1.mp3"/> <file src="sounds/backfire2.mp3"/> </meta> Link to comment
Flaker Posted August 8, 2013 Share Posted August 8, 2013 Держи полностью ресурс: http://rghost.ru/47980256. Его ставь. Должен работать. Если не работает смотри debugscript 3 Link to comment
Narrator Posted August 8, 2013 Share Posted August 8, 2013 flaker, преклоняюсь перед вашей терпимостью)) Link to comment
nejiko Posted September 1, 2013 Share Posted September 1, 2013 Держи полностью ресурс: http://rghost.ru/47980256.Его ставь. Должен работать. Если не работает смотри debugscript 3 Можно линк в ПМ? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now