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

Wysłany: 2020-10-04, 17:10


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

Witajcie bawi? si? w tworzenie systemu naprawy i napotka?em problem z wykryciem kierowcy podpowiem, ?e chc? by wykry?o, ?e kierowca jest w cuboidzie


addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
   local cs=getElementData(source"snn_cs")
    if not cs then return end
    vehicles=getElementsWithinColShape(cs,"vehicle")
    vehicles2=getElementsWithinColShape(cs,"player")
    driver=getVehicleController(vehicles2)
     if #vehicles < 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym nie znajduje si?\npojazd''error')
        return
    end
    if #vehicles > 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym znajduje si?\nzbyt du?a ilo?? pojazd?w''error')
        return
    end
    if not driver then triggerEvent('onClientAddNotification'localPlayer'Brak kierowcy''error')
        return
    end


Marker b?dzie u?ywa?a osoba trzecia nie osoba kt?ra sied? w aucie.

Ostatnio zmieniony przez killercycDDS 2020-10-04, 17:23, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-04, 17:23


NotPaladyn







Wiek: 23
Na forum: 2790 dni
Posty: 866
Nick w MP: NotPaladyn

Piwa: 3135

Respekt: 690
Respekt: 690Respekt: 690


   Vice Admin: Jeśli potrzebujesz pomocy w sprawach organizacyjnych lub technicznych - skontaktuj się ze mną.
W argumencie funkcji getVehicleController podaje si? zmienn? pojazdu z kt?rego chcesz pobra? kierowc? a ty poda?e? gracza

Spr?buj tak:

driver=getVehicleController(vehicles)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-04, 17:25


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

Marker b?dzie u?ywa?a osoba trzecia nie osoba kt?ra sied? w aucie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-04, 18:02


NotPaladyn







Wiek: 23
Na forum: 2790 dni
Posty: 866
Nick w MP: NotPaladyn

Piwa: 3135

Respekt: 690
Respekt: 690Respekt: 690


   Vice Admin: Jeśli potrzebujesz pomocy w sprawach organizacyjnych lub technicznych - skontaktuj się ze mną.
Sorki, ?le zauwa?y?em

Kierowce pobierz tak:

addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
   local cs=getElementData(source"snn_cs")
    if not cs then return end
    vehicles=getElementsWithinColShape(cs,"vehicle")
    vehicles2=getElementsWithinColShape(cs,"player")
pojazd=getPedOccupiedVehicle(localPlayer)
    driver=getVehicleController(pojazd)
     if #vehicles < 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym nie znajduje si?\npojazd''error')
        return
    end
    if #vehicles > 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym znajduje si?\nzbyt du?a ilo?? pojazd?w''error')
        return
    end
    if not driver then triggerEvent('onClientAddNotification'localPlayer'Brak kierowcy''error')
        return
    end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-04, 21:46


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

NotPaladyn, dalej wywala b??d


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-04, 22:02


NotPaladyn







Wiek: 23
Na forum: 2790 dni
Posty: 866
Nick w MP: NotPaladyn

Piwa: 3135

Respekt: 690
Respekt: 690Respekt: 690


   Vice Admin: Jeśli potrzebujesz pomocy w sprawach organizacyjnych lub technicznych - skontaktuj się ze mną.
Spr?buj tak, ja testowa?em i mi dzia?a:
addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
   local cs=getElementData(source"snn_cs")
    if not cs then return end
    vehicles=getElementsWithinColShape(cs,"vehicle")
    vehicles2=getElementsWithinColShape(cs,"player")
    pojazd=getPedOccupiedVehicle(localPlayer)
     if #vehicles < 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym nie znajduje si?\npojazd''error')
        return
    end
    if #vehicles > 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym znajduje si?\nzbyt du?a ilo?? pojazd?w''error')
        return
    end
    if getVehicleController(pojazd) ~= localPlayer then triggerEvent('onClientAddNotification'localPlayer'Brak kierowcy''error')
        return
    end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-04, 22:30


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

NotPaladyn, dzia?a ale nie tak jak chce. Dzia?a jak ja siedz? jako kierowca i wjad? w marker. A gdy inna osoba siedzi i ja wejd? w marker by mu naprawi? to wywala ten b??d co jest wy?ej




--local cub createColCuboid(-1679.6823730469, -197.1694641113312.89843754.53)

function przecinek(liczba)  
    local format liczba  
    while true do      
        formatstring.gsub(format"^(-?%d+)(%d%d%d)"'%1,%2')    
        if ( k==then      
            break  
        end  
    end  
    return format
end



local matker createMarker(-1680.82, -210.1114.15-0.8,"cylinder",2,255,215,0)

mojeW,mojeH 12801024
sW,sH guiGetScreenSize()
w= (sW/mojeW), (sH/mojeH)

local sxsy guiGetScreenSize ()

--local marker2 createMarker(-1679.57, -198.9014.15-0.8,"cylinder",2,255,215,0)

naprawa false

function gui()
    dxDrawImage(315*w313*h650*w400*h"naprawa-psrpg.png"000tocolor(255255255255), false)
end

function gui_rozpoczecia_duty()
    local wynagrodzenie = (5000)
    local xd getElementData(localPlayer,"mech:minuty") or 0
    local kasa tonumber(xd)*tonumber(wynagrodzenie) or 0
    dxDrawImage(593269606617":ec-logowanie/img/to_fajen.png"000tocolor(255255255255), false)
    dxDrawText("Rozpocz?cie S?u?by Mechanika"5952701199327tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawText("Tutaj mo?esz rozpocz?? s?u?b? jako machanik aut./nPraca w tym polega na naprawianiu aut innym gracz?.\nZa godzin? s?u?b? otrzymasz X PLN."5973331199677tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawRectangle(77780518281tocolor(000164), false)
    dxDrawRectangle(101780518281tocolor(000164), false)
    dxDrawText("Przepracowa?e?: "..xd.." min\nOtrzymasz: "..kasa.." PLN"10176771199805tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawText("Wyp?a? przepracowane minuty"10178051199886tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    if getElementData(localPlayer,"mechanik:duty"then 
    dxDrawText("Zako?cz S?u?b?"777805959886tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    else
    dxDrawText("Rozpocznij S?u?b?"777805959886tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    end
end

function napis()
    if((getTickCount()-tickxd) > 1000)then
        tickxd=getTickCount();
        timexd=timexd+1;
    end
    dxDrawText("#3366FFMechanik:#FFFFFF "..secondsToClock(timexd).. ""171197918201044tocolor(255255255255), 1.30"default""center""center"falsefalsefalsetruefalse)
end

local doFixed={
    {"Silnik"1fn=function(veh) if getElementHealth(veh)>=2040 then return true end; return false end},
    {"Maska"2fn=function(veh) if getVehicleDoorState(veh0)==0 then return true end; return false end},
    {"Baga?nik"3fn=function(veh) if getVehicleDoorState(veh1)==0 then return true end; return false end},
    {"Drzwi lewy prz?d"4fn=function(veh) if getVehicleDoorState(veh2)==0 then return true end; return false end},
    {"Drzwi prawy prz?d"5fn=function(veh) if getVehicleDoorState(veh3)==0 then return true end; return false end},
    {"Drzwi lewy ty?"6fn=function(veh) if getVehicleDoorState(veh4)==0 then return true end; return false end},
    {"Drzwi prawy ty?"7fn=function(veh) if getVehicleDoorState(veh5)==0 then return true end; return false end},
    {"Szyba przednia"8fn=function(veh) if getVehiclePanelState(veh4)==0 then return true end; return false end},
    {"Zderzak przedni"9fn=function(veh) if getVehiclePanelState(veh5)==0 then return true end; return false end},
    {"Zderzak tylni"10fn=function(veh) if getVehiclePanelState(veh6)==0 then return true end; return false end},
    {"?wiat?o lewe przednie"11fn=function(veh) if getVehicleLightState(veh0)==0 then return true end; return false end},
    {"?wiat?a prawe przednie"12fn=function(veh) if getVehicleLightState(veh1)==0 then return true end; return false end},
    {"?wiat?a lewe tylnie"13fn=function(veh) if getVehicleLightState(veh2)==0 then return true end; return false end},
    {"?wiat?a prawe tylnie"14fn=function(veh) if getVehicleLightState(veh3)==0 then return true end; return false end},
}

local wm={}
local isVehicles=nil
wm.gridlist guiCreateGridList(357*w393*h567*w218*hfalse)
guiGridListAddColumn(wm.gridlist"Cz???"0.45)
guiGridListAddColumn(wm.gridlist"Koszt"0.45)
guiGridListAddRow(wm.gridlist)
guiSetVisible(wm.gridlistfalse)
guiSetAlpha(wm.gridlist0.8)
guiSetFont(wm.gridlist"default-bold-small")

local function refreshGUI()
    if not isVehicles then return end
    guiGridListClear(wm.gridlist)
    for i,v in pairs(doFixed) do
        if v.fn(isVehicles)==false then
            local row guiGridListAddRow(wm.gridlist)
            guiGridListSetItemText(wm.gridlistrow1v[1], falsefalse)
            guiGridListSetItemData(wm.gridlistrow1i)
            guiGridListSetItemText(wm.gridlistrow2przecinek(doCosts[i]).." PLN"falsefalse)
            guiGridListSetItemData(wm.gridlistrow2doCosts[i])
end
end
end
local doCosts ={ 500010001000200010002000150015000200010000100000400033001500 }

addEvent("napison",true)
addEventHandler("napison",resourceRoot,function()
    tickxd getTickCount()
    timexd 0
    addEventHandler("onClientRender"rootnapis)
end)
addEvent("napisoff",true)
addEventHandler("napisoff",resourceRoot,function()
    tickxd getTickCount()
    timexd 0
    removeEventHandler("onClientRender"rootnapis)
end)

addEventHandler("onClientMarkerHit"matker, function(el,md)
    if el~=localPlayer then return end
    if getPedOccupiedVehicle(elthen return end
        showCursor(true)
        addEventHandler("onClientRender"rootgui_rozpoczecia_duty)
        setElementData(el"marker:mechanik"true)
end)

addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
   cs=getElementData(source"snn_cs")
    if not cs then return end
    vehicles=getElementsWithinColShape(cs,"vehicle")
    --pojazd=getPedOccupiedVehicle(localPlayer)
     if #vehicles < 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym nie znajduje si?\npojazd''error')
        return
    end
    if #vehicles > 1 then
        triggerEvent('onClientAddNotification'localPlayer'Na stanowisku naprawczym znajduje si?\nzbyt du?a ilo?? pojazd?w''error')
        return
    end
    --[[pojazd=getPedOccupiedVehicle(vehicles)
    kierowca getVehicleController(vehicles)
    if kierowca then triggerEvent('onClientAddNotification'localPlayer'Brak kierowcy''error')
        return
    end--]]
    showCursor(truefalse)
    guiSetVisible(wm.gridlisttrue)
    if naprawa == false then
    addEventHandler("onClientRender",root,gui)
    naprawa true
    isVehicles vehicles[1]
    guiGridListClear(wm.gridlist)
    for i,v in pairs(doFixed) do
        if v.fn(isVehicles)==false then
            local row guiGridListAddRow(wm.gridlist)
            guiGridListSetItemText(wm.gridlistrow1v[1], falsefalse)
            guiGridListSetItemData(wm.gridlistrow1i)
            guiGridListSetItemText(wm.gridlistrow2,przecinek(doCosts[i]).." $"falsefalse)
            guiGridListSetItemData(wm.gridlistrow2doCosts[i])
            guiGridListSetItemText(wm.gridlistrow1v[1], falsefalse)
            guiGridListSetItemData(wm.gridlistrow1i)
end
end
end
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(wm.gridlistfalse)
    removeEventHandler("onClientRender",root,gui)
    naprawa false
    isVehicles=nil
    showCursor(false)
end)

addEventHandler("onClientClick"root, function(btnstate)
    if btn == "left" and state == "down" then
    if mysz(77780518281) and isEventHandlerAdded("onClientRender"rootgui_rozpoczecia_dutythen
    triggerServerEvent("rozpocznij:sluzbe",root,localPlayer,localPlayer)
    removeEventHandler("onClientRender"rootgui_rozpoczecia_duty)
    showCursor(false)
    setElementData(localPlayer,"marker:mechanik",false)
end 
end
end)



function secondsToClock(seconds)
    seconds seconds or 0
    if seconds <= 0 then
        return "00:00"
    else
        hours string.format("%02.f"math.floor(seconds/3600))
        mins string.format("%02.f"math.floor(seconds/60 - (hours*60)))
        secs string.format("%02.f"math.floor(seconds hours*3600 mins *60))
        return "" .. mins .." minuty " .. secs .. " sekundy "
    end
    end
    

        function mysz xywidthheight )
            if ( not isCursorShowing( ) ) then
                return false
            end
            local sxsy guiGetScreenSize ( )
            local cxcy getCursorPosition ( )
            local cxcy = ( cx sx ), ( cy sy )
            if ( cx >= and cx <= width ) and ( cy >= and cy <= height then
                return true
            else
                return false
            end
        end
        
        
        function isEventHandlerAddedsEventNamepElementAttachedTofunc )
            if typesEventName ) == 'string' and isElementpElementAttachedTo ) and typefunc ) == 'function' then
                 local aAttachedFunctions getEventHandlerssEventNamepElementAttachedTo )
                 if typeaAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
                      for iv in ipairsaAttachedFunctions ) do
                           if == func then
                            return true
                       end
                  end
             end
            end
            return false
        end


        function getPartName(tkey)
            for i,v in pairs(t) do
                if v[2]==key then
                    return v[1]
                end
            end
        end

        addEventHandler("onClientClick"root, function(btnstate)
            if btn == "left" and state == "down" then
            if naprawa == true then
            if mysz(352*w624*h210*w78*hthen
            if not isVehicles or not isElement(isVehiclesthen return end
            selectedRow guiGridListGetSelectedItem(wm.gridlist) or -1
            if selectedRow 0 then return end
            local cost guiGridListGetItemData(wm.gridlistselectedRow2)
            if cost getElementData(localPlayer,"kasa:gracza") and not getElementData(localPlayer"player:duty") == "SP" and not getElementData(localPlayer"player:duty") == "P" and not getElementData(localPlayer"player:duty") == "PR" and not getElementData(localPlayer"player:duty") == "SATS" then
                outputChatBox("#bf0101(&#10006;) #FFFFFFNie masz tyle got?wki!"255,255,255true)
                cancelEvent()
                return
            end
            if getElementData(localPlayer"player:duty") == "SP" then cost 0 end
            if getElementData(localPlayer"player:duty") == "P" then cost 0 end
            if getElementData(localPlayer"player:duty") == "PR" then cost 0 end
            local part guiGridListGetItemData(wm.gridlistselectedRow1)
            if getElementData(vehicles2,"kasa:gracza") < cost then 
                triggerEvent('onClientAddNotification'localPlayer'Nie posiadasz wystarczaj?co got?wki\ndo naprawy pojazdu''error') return end    
            outputChatBox('(&#10004;) Naprawi?e? cz???: ' .. tostring(getPartName(doFixedpart255,255,255true)))
            setElementData(vehicles2,"kasa:gracza"getElementData(vehicles2,"kasa:gracza")-cost)
            setElementData(localPlayer,"kasa:gracza"getElementData(localPlayer,"kasa:gracza")+cost)
            --triggerServerEvent("takePlayerMoney"localPlayercost)
            triggerServerEvent("montazElementu"rootisVehicles"naprawa"partcost)
            setTimer(function()
                refreshGUI()
            end100002)
            end
            end
            end
        end)
    


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-07, 11:46


kamison

Przyszły programista .lua






Wiek: 25
Na forum: 3302 dni
Posty: 391
Nick w MP: kamison

Piwa: 594

Respekt: 205,3
Respekt: 205,3Respekt: 205,3

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-07, 12:33


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

"kamison" napisał/a:


Auto znajduje si? w cuboidzie a kapk? obok jest marker, kt?ry b?dzie obs?ugiwany przez osob? trzeci? a nie osob?, kt?ra siedzi w poje?dzie :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-07, 13:23


kamison

Przyszły programista .lua






Wiek: 25
Na forum: 3302 dni
Posty: 391
Nick w MP: kamison

Piwa: 594

Respekt: 205,3
Respekt: 205,3Respekt: 205,3

"killercycDDS" napisał/a:

"kamison" napisał/a:


Auto znajduje si? w cuboidzie a kapk? obok jest marker, kt?ry b?dzie obs?ugiwany przez osob? trzeci? a nie osob?, kt?ra siedzi w poje?dzie :D


W takim razie po co w og?le sprawdza? czy kto? jest w aucie?
Zr?b tylko sprawdzenie if getElementType(el) == "vehicle" then i tyle. Nie widz? w tym wypadku sensu sprawdzania czy kto? jest w aucie

Podpis
Coś tam kiedyś robiłem.

DC: kamison_.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-07, 21:37


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

"kamison" napisał/a:

"killercycDDS" napisał/a:

"kamison" napisał/a:


Auto znajduje si? w cuboidzie a kapk? obok jest marker, kt?ry b?dzie obs?ugiwany przez osob? trzeci? a nie osob?, kt?ra siedzi w poje?dzie :D


W takim razie po co w og?le sprawdza? czy kto? jest w aucie?
Zr?b tylko sprawdzenie if getElementType(el) == "vehicle" then i tyle. Nie widz? w tym wypadku sensu sprawdzania czy kto? jest w aucie


Jest bo b?d? robi? tak, ?e mechanik jak wybierze opcje i pobierze osobie w aucie hajs a mechanikowi da

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-07, 21:47


kamison

Przyszły programista .lua






Wiek: 25
Na forum: 3302 dni
Posty: 391
Nick w MP: kamison

Piwa: 594

Respekt: 205,3
Respekt: 205,3Respekt: 205,3

Czyli musisz skorzysta? z tej funkcji kt?r? poda?em w przyk?adzie

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-08, 07:41


chade

bad argument






Wiek: 24
Na forum: 3379 dni
Posty: 19
Nick w MP: Hoskin

Piwa: 2645

Respekt: 70


Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleController


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-08, 08:49


kamison

Przyszły programista .lua






Wiek: 25
Na forum: 3302 dni
Posty: 391
Nick w MP: kamison

Piwa: 594

Respekt: 205,3
Respekt: 205,3Respekt: 205,3

"chade" napisał/a:


Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleController


By?o, on musi skorzysta? z funkcji, kt?r? poda?em w przyk?adzie innej opcji nie ma.

Podpis
Coś tam kiedyś robiłem.

DC: kamison_.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-10-14, 13:13


maciek3286

LUA Developer






Wiek: 26
Na forum: 5201 dni
Posty: 230
Nick w MP: maciek00

Piwa: 3207

Respekt: 101,5
Respekt: 101,5

killercycDDS, nie sprawdzisz tego po stronie klienta. Musia? by? tworzy? marker czy tam colshape po stronie serwera i wtedy pobiera? pojazd z colshape je?li jest to wtedy dopiero kierowc?.

Postaw piwo autorowi tego posta
 

 
Tagi: wykrycie :: kierowcy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » wykrycie kierowcy Odpowiedz do tematu

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