Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2016-03-25, 21:21


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

Witam, jak zrobi? aby KA?DE auto o id np. 600 mia?o syreny ustawione przez skrypt???

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-25, 22:13


FaydenFX.







Wiek: 27
Na forum: 4197 dni
Posty: 246
Nick w MP: faydn

Piwa: 11

Respekt: 45,3

Strona serwera:

Kod:



-- Aby doda? d?wi?k dodaj folder z d?wi?kiem do meta.xml nast?pnie dodaj go tu.
-- 1 = id pojazdu, 2 = folder z syren?.


local dzwiekiPojazdow = {
{600, "twojanazwa.mp3"},
{600, "twojanazwa2.mp3"}, -- itp itp (zmieniaj?c id pojazdu etc.)
}

addEventHandler("onPlayerVehicleEnter", root, function()
local pojazd = getPedOccupiedVehicle(source)
if not pojazd then return end -- nie powinno si? wydarzy?
local model = getElementModel(pojazd) -- pobieramy model pojazdu
for i,v in ipairs(dzwiekiPojazdow) do
if model == v[1] then
bindKey(source, "[", "down", createSound)
bindKey(source, "]", "down", destroySound) -- na klawisz jaki chcesz
end
end
end)

addEventHandler("onPlayerVehicleExit", root, function()
local pojazd = getPedOccupiedVehicle(source)
if not pojazd then return end -- nie powinno si? wydarzy?
local model = getElementModel(pojazd) -- pobieramy model pojazdu
for i,v in ipairs(dzwiekiPojazdow) do
if model == v[1] then
unBindKey(source, "[", "down", createSound)
unBindKey(source, "]", "down", destroySound)
end
end
end)

function createSound(plr)
local pojazd = getPedOccupiedVehicle(plr)
if not pojazd then return end -- not vehicle
local model = getElementModel(pojazd)
for i,v in ipairs(dzwiekiPojazdow) do
if model == v[1] then
triggerClientEvent("createVehicleSound", resourceRoot, pojazd, v[2])
end
end
end

function destroySound(plr)
local pojazd = getPedOccupiedVehicle(plr)
if not pojazd then return end -- not vehicle
local model = getElementModel(pojazd)
for i,v in ipairs(dzwiekiPojazdow) do
if model == v[1] then
triggerClientEvent("destroyVehicleSound", resourceRoot, pojazd, v[2])
end
end
end


Strona clienta:

Kod:

addEvent("createVehicleSound", true)
addEventHandler("createVehicleSound", root, function(pojazd, dzwiek)
for i,v in ipairs(getAttachedElements(pojazd)) do if getElementType(v) == "sound" then return end end
local snd = playSound3D(dzwiek, 0, 0,0 , true) -- create sound
setSoundMaxDistance(snd, 650)
attachElements(snd, pojazd)
end)

addEvent("destroyVehicleSound", true)
addEventHandler("destroyVehicleSound", root, function(pojazd)
for i,v in ipairs(getAttachedElements(pojazd)) do
if getElementType(v) == "sound" then
destroyElement(v)
end
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 09:16


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

Chodzi mi o to ?e same sygna?y tworzy bez dzwi?ku i pod jednym klawiszem sie je w??cza i wy??cza( , )

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 09:18


Odważny

Początki LUA :P






Wiek: 26
Na forum: 3880 dni
Posty: 140
Nick w MP: ReseT_

Piwa: 166

Respekt: 50

Ja posiadam inny kod (oczywi?cie dzia?a) nie zmuszam aby? go bra?, lecz ka?dy go posiada:



activeSirens = {}


vehicleSiren = {
[300] = {"tytu?.mp3",nil}, --model pojazdu + ?cie?ka d?wi?kowa

setWorldSoundEnabled( 17, 10, false ) --?ciszenie klasycznych syren
setWorldSoundEnabled( 17, 11, false )

effectName = "i3dl2reverb"

for key, value in ipairs(getElementsByType("sound")) do
if getElementData(value,"siren") then
stopSound(value)
end
end

addEventHandler("onClientRender",root,function ()
for key, value in ipairs(getElementsByType("vehicle")) do

if getVehicleSirensOn(value) then
if not getElementData(value,"og.mikser") or not vehicleSiren[getElementModel(value)][2] then
  if not activeSirens[value] then
  if vehicleSiren[getElementModel(value)] then
  local syrena = vehicleSiren[getElementModel(value)][1] or "tytu?.mp3"
  activeSirens[value] = playSound3D(syrena,0,0,3,true)
  setSoundMinDistance(activeSirens[value],20) --g?o?no?? ?cie?ki d?wi?kowej
  setSoundMaxDistance(activeSirens[value],200)
  setElementParent(activeSirens[value],value)
  setSoundVolume(activeSirens[value],0.4)
  setElementData(activeSirens[value],"siren",true)
  --setSoundEffectEnabled(activeSirens[value],effectName,true)
  end
  end
  else
  if not activeSirens[value] then
  if vehicleSiren[getElementModel(value)] then
  if vehicleSiren[getElementModel(value)][2] then
  
  local syrena = vehicleSiren[getElementModel(value)][2] or "tytu?.mp3"
  activeSirens[value] = playSound3D(syrena,0,0,3,true)
  setSoundMinDistance(activeSirens[value],20)
  setSoundMaxDistance(activeSirens[value],200)
  setElementParent(activeSirens[value],value)
  setSoundVolume(activeSirens[value],0.4)
  setElementData(activeSirens[value],"siren",true)
  --setSoundEffectEnabled(activeSirens[value],effectName,true)
  end
  end
  end
  end
  else
  if activeSirens[value] then
  stopSound(activeSirens[value])
  activeSirens[value] = nil
  end
  end
  end
  

  
  end)
  
  
  
  
addEventHandler("onClientRender",root,function ()
for key, value in ipairs(getElementsByType("vehicle")) do
  if activeSirens[value] then
  local x, y, z = getElementPosition(value)
  setElementPosition(activeSirens[value],x,y,z)
  if not getVehicleController(value) then
  setSoundVolume(activeSirens[value],0.01)
  else
  setSoundVolume(activeSirens[value],0.4)
  end
  if getElementData(value,"og.sirenspeed") then
  if activeSirens[value] then
   setSoundSpeed(activeSirens[value],1.85)
  
  end
  else
  setSoundSpeed(activeSirens[value],1.0)
  end
  end
  
  
  
  
  

  end
  end)
  
  
  
addEventHandler("onClientRender",root,function ()
if isPedInVehicle(localPlayer) then
  local veh = getPedOccupiedVehicle(localPlayer)
  if getVehicleController(veh)==localPlayer and vehicleSiren[getElementModel(veh)] then
  if getKeyState("h") then
  if activeSirens[veh] then
  setElementData(veh,"og.sirenspeed",true)
  end
  else
  setElementData(veh,"og.sirenspeed",false)
  end
  end
  
  end
  end)
  --[[
  local w, h = guiGetScreenSize()
  
  function dxDrawTextRelative(text,x1,y1,x2,y2,color,scale,font,alignx,aligny,val1,val2,val3,val4,val5)
local x1 = (x1/1280)*w
local x2 = (x2/1280)*w
local y1 = (y1/1024)*h
local y2 = (y2/1024)*h
dxDrawText(text,x1,y1,x2,y2,color,scale/1280*w,scale/1024*h,font,alignx,aligny,val1,val2,val3,val4,val5)
end

function dxDrawRectangleRelative(startX, startY, width, height ,color, postGUI, subPixelPositioning  )
local x1 = (startX/1280)*w
local x2 = (width/1280)*w
local y1 = (startY/1024)*h
local y2 = (height/1024)*h
dxDrawRectangle(x1,y1,x2,y2,color,postGUI,subPixelPositioning)
end

function conState(state)
if state == true then
return {"ON", 31, 255, 31}
else
return {"OFF", 255, 31, 31}
end
end


ablevehicles = {
[600] = true, -- tw?j model pojazdu
}

addEventHandler("onClientRender",root,function ()
if isPedInVehicle(localPlayer) and ablevehicles[getElementModel(getPedOccupiedVehicle(localPlayer))] then
local veh = getPedOccupiedVehicle(localPlayer)
local syreny = conState(getElementData(veh,"og.sirens"))
local migacze = conState(getVehicleSirensOn(veh))
dxDrawRectangleRelative(793, 28, 170, 103, tocolor(0, 0, 0, 108), false)
dxDrawRectangleRelative(793, 28, 170, 21, tocolor(0, 0, 0, 108), false)
dxDrawRectangleRelative(811, 91, 25, 25, tocolor(migacze[2], migacze[3], migacze[4], 226), false)
dxDrawRectangleRelative(920, 91, 25, 25, tocolor(syreny[2], syreny[3], syreny[4], 226), false)
dxDrawTextRelative(migacze[1], 811, 91, 836, 116, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
dxDrawTextRelative(syreny[1], 920, 91, 945, 116, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Migacze 'H'", 793, 66, 859, 81, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Syreny 'J'", 897, 66, 963, 81, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Pojazd S?u?bowy", 793 - 1, 28 - 1, 963 - 1, 49 - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Pojazd S?u?bowy", 793 + 1, 28 - 1, 963 + 1, 49 - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Pojazd S?u?bowy", 793 - 1, 28 + 1, 963 - 1, 49 + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Pojazd S?u?bowy", 793 + 1, 28 + 1, 963 + 1, 49 + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
dxDrawTextRelative("Pojazd S?u?bowy", 793, 28, 963, 49, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
 end
 end)
        
 ]]--     
        


[ Dodano: 2016-03-26, 09:19 ]
Axmell, No to mryga?ki ;//

Podpis
, pomogłem Ci? Wynagrodź mnie :piwo: :P
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 15:54


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

Odwa?ny, No. Mryga?ki :D Wi?c jak mam sie na to zabra?.
- jak dac pozycje "mryga?k?w"
- jak da? kolor mryga?ek
- oraz jak se przypisac to JEDNEGO pojazdu?

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 16:40


Emm

***** ***






Wiek: 32
Na forum: 4021 dni
Posty: 3191
Nick w MP: Emm

Piwa: 6171

Respekt: 1580
Respekt: 1580Respekt: 1580


   Administrator: Admin ma zawsze rację | REGULAMIN FORUM | REKLAMA/VIP | .

Więcej informacji znajdziesz w Wikipedii MTA:

setVehicleSirens


Więcej informacji znajdziesz w Wikipedii MTA:

addVehicleSirens


Pomo?e Ci w tym sireneditor

Podpis

Użytkownik: 20.10.2015r
GTAO Member: 06.03.2016r
Support-Team: 20.01.2016r
Moderator: 30.03.2016r
Mod-Team: 08.10.2016r
Vice Admin: 04.05.2018r
Administrator: 03.05.2022r


! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 16:48


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

Te syreny b?d? pod 'H' tak? Bo ja bym chcia? je pod ' , '
sireneditorto tylko do pozycji no nie? :D

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:01


Odważny

Początki LUA :P






Wiek: 26
Na forum: 3880 dni
Posty: 140
Nick w MP: ReseT_

Piwa: 166

Respekt: 50

Axmell, Sireneditor to chyba to pozycji mryga?ek oraz koloru, nie jestem pewnien bo nigdy z niego nie korzysta?em

Podpis
, pomogłem Ci? Wynagrodź mnie :piwo: :P
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:05


Emm

***** ***






Wiek: 32
Na forum: 4021 dni
Posty: 3191
Nick w MP: Emm

Piwa: 6171

Respekt: 1580
Respekt: 1580Respekt: 1580


   Administrator: Admin ma zawsze rację | REGULAMIN FORUM | REKLAMA/VIP | .
"Axmell" napisał/a:

Te syreny b?d? pod 'H' tak? Bo ja bym chcia? je pod ' , '
sireneditorto tylko do pozycji no nie? :D

B?d? pod h, ale funkcje dodatkowo mo?na chyba zbindowa? na inny przycisk poprzez
Więcej informacji znajdziesz w Wikipedii MTA:

bindKey

Ale nie testowa?em

Podpis

Użytkownik: 20.10.2015r
GTAO Member: 06.03.2016r
Support-Team: 20.01.2016r
Moderator: 30.03.2016r
Mod-Team: 08.10.2016r
Vice Admin: 04.05.2018r
Administrator: 03.05.2022r


! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:13


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

Ale jak da? pod dane id auta( kazde auto o tym id) mryga?ke?

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:15


Emm

***** ***






Wiek: 32
Na forum: 4021 dni
Posty: 3191
Nick w MP: Emm

Piwa: 6171

Respekt: 1580
Respekt: 1580Respekt: 1580


   Administrator: Admin ma zawsze rację | REGULAMIN FORUM | REKLAMA/VIP | .
Tworzysz p?tle, w kt?rej pobierasz elementy, kt?re s? pojazdem, i p??niej sprawdzasz czy te pojazdy maj? id jakie? tam i je?li maj? to dodajesz syreny.

Podpis

Użytkownik: 20.10.2015r
GTAO Member: 06.03.2016r
Support-Team: 20.01.2016r
Moderator: 30.03.2016r
Mod-Team: 08.10.2016r
Vice Admin: 04.05.2018r
Administrator: 03.05.2022r


! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:36


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

Da?em te przyk?adowe syreny ale czego nie ma tych mryga?ek?

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:44


Emm

***** ***






Wiek: 32
Na forum: 4021 dni
Posty: 3191
Nick w MP: Emm

Piwa: 6171

Respekt: 1580
Respekt: 1580Respekt: 1580


   Administrator: Admin ma zawsze rację | REGULAMIN FORUM | REKLAMA/VIP | .
Podaj kod

Podpis

Użytkownik: 20.10.2015r
GTAO Member: 06.03.2016r
Support-Team: 20.01.2016r
Moderator: 30.03.2016r
Mod-Team: 08.10.2016r
Vice Admin: 04.05.2018r
Administrator: 03.05.2022r


! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-29, 11:34


Axmell

E-Commerce






Wiek: 24
Na forum: 3951 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

addEventHandler("onVehicleEnter",root,function(player,seat)
   if(player)and(seat==0)then
      addVehicleSirens(source,1,1)
   end
end)
 
addEventHandler("onVehicleExit",root,function(player,seat)
   if(player)and(seat==0)then
      removeVehicleSirens(source)
   end
end)


[ Dodano: 2016-03-30, 13:12 ]
I nie ma mryga?ek

Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: syreny
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » SYRENY Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku