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

Wysłany: 2016-01-30, 13:17


Querex







Wiek: 32
Na forum: 4149 dni
Posty: 79
Nick w MP: Querex

Piwa: 41

Respekt: 50

Witam posiadam problem, ot?? po wej?ciu w marker i nacisni?ciu przycisku zamontuj kompletnie nic sie nie dzieje. Czego jest to wina? Za pomoc zimne :piwo:

S side:
   local strefyMontazu={
  ls1_1={
    colsphere={2039.7182617188,1543.8753662109,10555},
    mpos={2034.0075683594,1542.7623291016,10},
    
  },
--  pc={
 --   colsphere={2576.15,5.61,28.20,5},
 --   mpos={2575.69,-4.11,27.59},
 -- },

}

createBlipAttachedTo mpos52 )

for i,v in pairs(strefyMontazu) do
  if v.cuboid then
    v.cs=createColCuboid(unpack(v.cuboid))
  elseif v.colsphere then
    v.cs=createColSphere(unpack(v.colsphere))
  end
  v.marker=createMarker(v.mpos[1], v.mpos[2], v.mpos[3], "cylinder"10,0,0,100)
  setElementData(v.marker,"cs",v.cs)
  setElementData(v.marker,"praca",v.praca)
end

local function czyElementWStrefieMontazu(e)
  for i,v in pairs(strefyMontazu) do
    if isElementWithinColShape(e,v.csthen return true end
  end
  return false
end


local function pracownik(id)
    local query=string.format("SELECT rank FROM lss_character_factions WHERE faction_id=3 AND character_id=%d"id)
    local wynik=exports.DB:pobierzWyniki(query)
    if (wynik and wynik.rankthen return true else return false end
end

--   triggerServerEvent("montazSwiatel"resourceRootnaprawiany_pojazdkolorkoszt)  
addEvent("montazSwiatel"true)
addEventHandler("montazSwiatel"resourceRoot, function (pojazdkolorkoszt)
  if not pojazd or not kolor or not koszt then return end
  if koszt>getPlayerMoney(client) or koszt<or koszt~=koszt then
  --  outputChatBox("Nie sta? Ci? na monta? tych ?wiate?."client)
             str "Nie sta? Ci? na monta? tych ?wiate?"
   triggerClientEvent(client"CreateBox"getRootElement(), str)    
    return
  end
--  outputDebugString("ev")
  if not isElement(pojazdthen return end
  local vdbid=getPlayerName(client)
  local dbid=getElementData(client,"dbid")
  local pdbid=getElementData(pojazd,"dbid")
    local c=getElementData(client,"character")
    if (not c or not c.idthen return end
    if (not pracownik(tonumber(c.id))) then
    --outputChatBox("(( nie masz klucza do tej bramy ))"gracz)
            str "Nie pracujesz w warsztacie"
   triggerClientEvent(client"CreateBox"getRootElement(), str)    
return 
end

 
 -- if not pdbid or not vdbid or not dbid or vdbid~=dbid then return end
--  local przebieg=getElementData(pojazd,"przebieg") or 0
  takePlayerMoney(clientkoszt)
  setVehicleHeadLightColor(pojazdkolor[1],kolor[2],kolor[3])
  setTimer(setVehicleHeadLightColor5001pojazdkolor[1],kolor[2],kolor[3])
 -- setElementData(pojazd"hl_przebieg"przebiegfalse)
 outputDebugString("Kolory: " .. tostring(kolor[1]))
 outputDebugString("pdbid: " .. tostring(pdbid))

  local query=string.format("UPDATE lss_vehicles SET headlightcolor='%d,%d,%d' WHERE id=%d LIMIT 1"kolor[1] or 255,kolor[2] or 255,kolor[3] or 255pdbid)
  exports.DB2:zapytanie(query)
  
  outputDebugString("Montaz swiatel " .. kolor[1])
  triggerClientEvent(client,"montazComplete"resourceRoot)
  

  exports["lss-admin"]:gameView_add(string.format("TUNING montaz ZAROWEK kolor %d,%d,%d pojazd %d gracz %s "kolor[1] or 255kolor[2] or 255kolor[3] or 255pdbidvdbid))
end)

--[[
-- przepalanie zarowek!
addEvent("setVehicleOverrideLights"true)
addEventHandler("setVehicleOverrideLights"root, function(state)
    if state~=2 then return end
    local dbid=getElementData(source"dbid")
    if not dbid then return end

  --  local przebieg=getElementData(source"przebieg")
  --  if not przebieg then return end

   -- local hl_przebieg=getElementData(source,"hl_przebieg")
   -- if not hl_przebieg then return end

    local kierowca=getVehicleController(source)
    if not kierowca then return end

    -- tylko wlascicielowi moze przepalic sie zarowka masc na bol dupy
    local player_dbid=getElementData(kierowca"dbid")
--    local vehicle_owner=getElementData(source"owning_player")
--    if not player_dbid or not vehicle_owner or vehicle_owner~=player_dbid then return end
    if not player_dbid then return end

--    outputDebugString("pojazd " .. dbid .. " przebieg " .. przebieg .. " hl_przebieg ." .. hl_przebieg)
  --  hl_przebieg=hl_przebieg+2500 -- przepalamy po 2.5kkm
  --  if hl_przebieg>przebieg then
      return
    end

    -- przepalamy
    setVehicleLightState(source,1,1)
    setVehicleLightState(source,0,1)
    setVehicleHeadLightColor(source255,255,255)
    exports["pl-logs"]:gameView_add(string.format("TUNING przepalenie ZAROWEK pojazd %d gracz %d"dbidplayer_dbid))
    --setElementData(source"hl_przebieg"przebiegfalse)
    exports.DB2:szybkieZapytanie("UPDATE pl_vehicles SET headlightcolor=NULL WHERE id=? LIMIT 1"dbid)
    outputChatBox("* W poje?dzie przepalaj? si? ?ar?wki."kierowca)

end)




--   triggerServerEvent("montazElementu"resourceRootnaprawiany_pojazdczesckoszt)  
addEvent("montazElementu"true)
addEventHandler("montazElementu"resourceRoot, function(pojazdczesckoszt)
--  outputDebugString("Naprawa elementu " .. czesc .. " za " .. koszt)

  local kierowca=getVehicleController(pojazd)
  if not kierowca then
    outputChatBox("W poje?dzie nie ma w?a?ciciela."client)
    return
  end

  local kdbid=getElementData(kierowca,"dbid") or 0
  local vdbid=getElementData(pojazd,"owning_player")
  if not vdbid or kdbid~=vdbid then
    outputChatBox("W poje?dzie na miejscu kierowcy musi siedzie? w?a?ciciel pojazdu.",client)
    return
  end

  if not czyElementWStrefieMontazu(pojazdthen
    outputChatBox("Pojazd nie znajduje si? w strefie monta?u."client)
    return
  end

  if koszt>getPlayerMoney(clientthen
    return
  end

  if czesc<0 then

    -- czesci specjalnetuning mechanicznytaksometr
    if czesc==-1 then

      if koszt<0 then
        if not getElementData(pojazd"k_tm1"then
          outputChatBox("* Ten pojazd nie posiada tego komponentu."client)
          return
        end
        removeElementData(pojazd"k_tm1")
        givePlayerMoney(kierowca, -koszt)
        exports["pl-logs"]:gameView_add(string.format("TUNING demontaz k_tm1 pojazd %d gracz %d"getElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
        outputChatBox("Z pojazdu zdemontowano uk?ad tuninguj?cy."kierowca)
      else
        if getElementData(pojazd"k_tm1"then
          outputChatBox("* Ten pojazd ju? posiada ten komponent."client)
          return
        end
        setElementData(pojazd"k_tm1"true)
        takePlayerMoney(clientkoszt)
        exports["pl-logs"]:gameView_add(string.format("TUNING montaz k_tm1 pojazd %d gracz %d"getElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
        outputChatBox("* W poje?dzie zamontowano uk?ad tuninguj?cy.",kierowca)
      end
    elseif czesc==-2 then
      local lvl=getElementData(client"level") or 0
      if true or lvl<3 then
            outputChatBox("* Uk?ad nie jest jeszcze dost?pny na rynku."client)
            triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
            return
      end
    elseif czesc==-10 then

      local lvl=getElementData(client"level") or 0
      if lvl<3 then
            outputChatBox("* Montaz taksometru w trakcie przygotowywania."client)
            triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
            return
      end


      if koszt<0 then
        if not getElementData(pojazd"k_tax"then
          outputChatBox("* Ten pojazd nie posiada tego komponentu."client)
          return
        end
        removeElementData(pojazd"k_tax")
        givePlayerMoney(kierowca, -koszt)
        exports["pl-logs"]:gameView_add(string.format("TUNING demontaz k_tax pojazd %d gracz %d"getElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
        outputChatBox("* Z pojazdu zdemontowano taksometr."kierowca)
      else
        if getElementData(pojazd"k_tax"then
          outputChatBox("* Ten pojazd ju? posiada ten komponent."client)
          return
        end
        setElementData(pojazd"k_tax"true)
        takePlayerMoney(clientkoszt)
        exports["pl-logs"]:gameView_add(string.format("TUNING montaz k_tax pojazd %d gracz %d"getElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
        outputChatBox("* W poje?dzie zamontowano taksometr."kierowca)
      end

    elseif czesc==-11 then

      if getElementModel(pojazd)~=586 then
            outputChatBox("* Nie mo?na zamontowa? tej cz??ci w tym poje?dzie."client)
            triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
            return
      end


      if koszt<0 then
        if not getElementData(pojazd"k_nj"then
          outputChatBox("* Ten pojazd nie posiada tego komponentu."client)
          return
        end
        removeElementData(pojazd"k_nj")
        givePlayerMoney(kierowca, -koszt)
        exports["pl-logs"]:gameView_add(string.format("TUNING demontaz k_nj pojazd %d gracz %d"getElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
        outputChatBox("* z pojazdu zdemontowano modyfikacj? do nauki jazdy."kierowca)
      else
        if getElementData(pojazd"k_nj"then
          outputChatBox("* Ten pojazd ju? posiada ten komponent."client)
          return
        end
        setElementData(pojazd"k_nj"true)
        takePlayerMoney(clientkoszt)
        exports["pl-logs"]:gameView_add(string.format("TUNING montaz k_nj pojazd %d gracz %d"getElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
        outputChatBox("* W poje?dzie zamontowano modyfikacj? do nauki jazdy."kierowca)
      end

    end
    exports["pl-vehicle"]:veh_save(pojazd)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
    return
  end


--  outputChatBox("Koszt " .. koszt)
  if koszt<0 then
    -- demontaz tuningu
    if not removeVehicleUpgrade(pojazdczescthen return end
    givePlayerMoney(kierowca, -koszt)
    outputChatBox("* Z pojazdu zdemontowano cz??? " .. czescclient)
    outputChatBox("* Z pojazdu zdemontowano cz??? " .. czesckierowca)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
    exports["pl-vehicles"]:veh_save(pojazd)
    exports["pl-logs"]:gameView_add(string.format("TUNING demontaz element %d pojazd %d gracz %d"czescgetElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
    return
  end

  if not addVehicleUpgrade(pojazdczescthen
    outputChatBox("* Ta cz??? nie pasuje do tego pojazdu."client)
    outputChatBox("* Mechanik przymierzy? cz??? " .. czesc .. " ale nie pasuje ona do tego pojazdu."kierowca)
    exports["pl-logs"]:gameView_add("incompatible upgrade, vmodel: " .. getElementModel(pojazd) .. ", upgrade id: " .. czesc)
    return
  end
  takePlayerMoney(clientkoszt)
  outputChatBox("* W poje?dzie zamontowano cz??? " .. czescclient)
  outputChatBox("* w poje?dzie zamontowano cz??? " .. czesckierowca)
  triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  exports["pl-logs"]:gameView_add(string.format("TUNING montaz element %d pojazd %d gracz %d"czescgetElementData(pojazd,"dbid") or 0getElementData(client,"dbid") or 0))
  exports["pl-vehicles"]:veh_save(pojazd)
end)
]]--       







C side:


   local w_m={}
w_m.wnd guiCreateWindow(0.49,0.1667,0.4344,0.675,"",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Zamontuj",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Rodzaj"0.6 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt"0.30 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil
local npr,npg,npb=255,255,255


local function isVehicleUpgradeSlotAllowed(i)
  if i==8 then return false end
  return true
end


local kolorki={
  {"Stanardowe",                            { 255,255,255}, 500},
  {"Xenon ULTRA",                           { 104133205}, 3500},
  {"Xenon Plasma",                          { 196197255}, 3600},
  {"SMD LED",                               { 251243160}, 4500},
  {"LED Yellow",                            { 25525516}, 8800},
  {"Philips Blue Vision Xenon",             { 93223255}, 5000},
  {"Street Panther",                        { 252670}, 8800},
  {"Philips Ocean Blue",                    { 9270221}, 5000},
  {"Philips Ocean Green",                   { 9222170}, 5000},
  {"Orange Panoramix",                       { 2551200}, 6300},
  {"Asterix LED Pulsar",                    { 2550255}, 8200},
  {"Obelix Creme",                            { 255222173}, 4200},
  {"Drastic Lime",                            { 02550}, 8800},
  {"Drastic Blue",                            { 00255}, 8800},
  {"Drastic Red",                            { 25500}, 8800},
  {"George Pink",                           { 255,0,122}, 7800},
  
}
local function fillVehicleData(v)
  guiGridListClear(w_m.grid)
  guiSetText(w_m.btn_napraw"Zamontuj")

  for i,v in ipairs(kolorki) do
      local row=guiGridListAddRow(w_m.grid)
      guiGridListSetItemText(w_m.grid,row,1," "..v[1],false,false)
      guiGridListSetItemColor(w_m.grid,row,1,v[2][1],v[2][2],v[2][3])
      guiGridListSetItemData(w_m.grid,row,1,v[2])
      guiGridListSetItemText(w_m.grid,row,2,v[3], false,false)
      guiGridListSetItemData(w_m.grid,row,2,v[3])
  end

  if true then return end
end


addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
  if not md or el~=localPlayer then return end
--[[
  local lvl=getElementData(el,"level") or 0
  if lvl<1 then
    outputChatBox("* Kod od montazu swiatel w trakcie przygotowywania.")
    return
  end
]]--
  local cs=getElementData(source"cs")
  local praca=getElementData(source"praca")
  local lpraca=getElementData(localPlayer"praca:kod")
  if praca and lpraca~=praca then return end -- gracz nie jest pracownikiem

  local pojazdy=getElementsWithinColShape(cs,"vehicle")
  if #pojazdy<1 then
    outputChatBox("Na stanowisku montazu nie ma zadnego pojazdu.")
    return
  end
  if #pojazdy>1 then
    outputChatBox("Na stanowisku montazu jest zbyt duzo pojazd?w.")
    return
  end

  if getElementHealth(pojazdy[1])<950 or getVehicleLightState(pojazdy[1],0)~=or getVehicleLightState(pojazdy[1],1)~=0 then
    outputChatBox("Pojazd na stanowisku jest za bardzo uszkodzony.")
    return
  end

  setVehicleOverrideLights(pojazdy[1],2)
  fillVehicleData(pojazdy[1])
  guiSetEnabled(w_m.btn_naprawfalse)
  guiSetText(w_m.lbl_info,"")
  guiSetVisible(w_m.wndtrue)  
  showCursor(true)
  naprawiany_pojazd=pojazdy[1]
  npr,npg,npb=getVehicleHeadLightColor(pojazdy[1])
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
  if el~=localPlayer then return end
  guiSetVisible(w_m.wndfalse)
  showCursor(false)
  if naprawiany_pojazd and isElement(naprawiany_pojazdthen
    setVehicleOverrideLights(naprawiany_pojazd1)
    setVehicleOverrideLights(naprawiany_pojazd,1)
    setVehicleHeadLightColor(naprawiany_pojazdnpr,npg,npb)
  end
  naprawiany_pojazd=nil
  npr,npg,npb=255,255,255
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
  guiSetVisible(w_m.wndfalse)
  showCursor(false)  

  if naprawiany_pojazd and isElement(naprawiany_pojazdthen
    setVehicleOverrideLights(naprawiany_pojazd1)
    setVehicleOverrideLights(naprawiany_pojazd1)
    setVehicleHeadLightColor(naprawiany_pojazdnpr,npg,npb)
  end
  npr,npg,npb=255,255,255
  naprawiany_pojazd=nil
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
    guiSetText(w_m.lbl_info,"")
    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if (selectedRow<0then
      guiSetEnabled(w_m.btn_napraw,false)
      return
    end
    local kolor=guiGridListGetItemData(w_m.gridselectedRow1)
    
    setVehicleHeadLightColor(naprawiany_pojazdkolor[1],kolor[2],kolor[3])

    guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()

addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
  if getPedOccupiedVehicle(localPlayerthen
    return
  end

  if getTickCount()-napraw_lu<1000 then return end

  if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

  selectedRowguiGridListGetSelectedItem w_m.grid) or -1
  if selectedRow<0 then return end
  local koszt=math.floor(guiGridListGetItemData(w_m.gridselectedRow2))

  if koszt>getPlayerMoney(localPlayerthen
    guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
    return
  end

  local kolor=guiGridListGetItemData(w_m.gridselectedRow1)
  napraw_lu=getTickCount()
  triggerServerEvent("montazSwiatel"resourceRootnaprawiany_pojazdkolorkoszt)  
endfalse)

-- triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
addEvent("montazComplete"true)
addEventHandler("montazComplete"resourceRoot, function(pojazd)
  guiSetVisible(w_m.wndfalse)
  showCursor(false)
  if naprawiany_pojazd and isElement(naprawiany_pojazdthen
    setVehicleOverrideLights(naprawiany_pojazd1)
    triggerServerEvent("setVehicleOverrideLights"naprawiany_pojazd,1)
--    setVehicleHeadLightColor(naprawiany_pojazdnpr,npg,npb)
  end
  naprawiany_pojazd=nil
  npr,npg,npb=255,255,255
end)  


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-30, 16:45


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

trigger pod tytu?em 'montazSwiatel' jest zakomentowany na server-side

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Tagi: tune
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Tune 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