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

Wysłany: 2020-05-24, 15:00


HEATEX







Wiek: 25
Na forum: 2391 dni
Posty: 109
Nick w MP: HEATEX

Piwa: 1341

Respekt: 50

Ostrzeżeń: 20%
c_license.lua

--[[
    Resource: OURGame v2
    Developers: Split <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c) 2015 <split.programista@gmail.com>. All rights reserved.
]]

mojeW,mojeH = 1280, 1024
sW,sH = guiGetScreenSize()
w, h = (sW/mojeW), (sH/mojeH)

local sx, sy = guiGetScreenSize ()
 
prawko = false 

function mysz(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end

local marker=createMarker(-2033.08, -117.49, 1035.17-1, "cylinder", 1.2, 0, 122, 255, 55) -- Prawo Jazdy
setElementInterior(marker, 3)
setElementDimension(marker, 1)
setElementData(marker, 'typ', 'pojazd')

local marker2=createMarker(-2237.23, 2353.97, 4.98-1, "cylinder", 1.2, 0, 122, 255, 55) -- Licencja Lotnicza
setElementInterior(marker2, 0)

local t=createElement("text")
setElementInterior(t, 3)
setElementDimension(t, 1)
setElementPosition(t,-2033.08, -117.49, 1035.17)
setElementData(t,"name","Zdawanie na prawo jazdy")

local t2=createElement("text")
setElementInterior(t2, 0)
setElementPosition(t2, -2237.23, 2353.97, 4.98)
setElementData(t2,"name","Zdawanie licencji lotniczej")


local wm={}
--[[wm.gridlist=guiCreateWindow(0.21, 0.20, 0.57, 0.54, "Zdawanie prawa jazdy", true)
guiWindowSetSizable(wm.gridlist, false)
guiWindowSetMovable(wm.gridlist, false)
guiSetVisible(wm.gridlist, false)
wm.label=guiCreateLabel(0.02, 0.06, 0.96, 0.05, "Z poni?szej listy wybierz kategori? prawa jazdy do kt?rej chcesz przyst?pi? p??niej kliknij Przyst?p", true, wm.gridlist)
guiLabelSetHorizontalAlign(wm.label, "center", false)
guiLabelSetVerticalAlign(wm.label, "center")--]]
wm.gridlist=guiCreateGridList(357*w, 393*h, 567*w, 218*h, false)
guiGridListAddColumn(wm.gridlist, "Kategoria", 0.24)
guiGridListAddColumn(wm.gridlist, "Pojazdy", 0.24)
guiGridListAddColumn(wm.gridlist, "Koszt", 0.24)
guiGridListAddColumn(wm.gridlist, "Zaliczone", 0.24)
guiSetVisible(wm.gridlist, false)
guiSetAlpha(wm.gridlist, 0.8)
guiSetFont(wm.gridlist, "default-bold-small")
--wm.close=guiCreateButton(0.62, 0.83, 0.36, 0.13, "Zamknij", true)
--wm.submit=guiCreateButton(0.02, 0.83, 0.36, 0.13, "Przyst?p", true)

local function fillLicenseData()
    guiGridListClear(wm.gridlist)
    for i,v in ipairs(licenseCategory) do
        local row=guiGridListAddRow(wm.gridlist)
        guiGridListSetItemText(wm.gridlist, row, 1, v[1], false, false)
        guiGridListSetItemText(wm.gridlist, row, 2, v[2], false, false)
        guiGridListSetItemText(wm.gridlist, row, 3, v[3].." PLN", false, false)
        guiGridListSetItemData(wm.gridlist, row, 3, v[3])
        -- Settings
        if getElementData(localPlayer,"player:license:pj"..v[1]) == 1 then
            guiGridListSetItemText(wm.gridlist, row, 4, "TAK", false, false)
            guiGridListSetItemColor(wm.gridlist, row, 4, 0, 255, 0)
        else
            guiGridListSetItemText(wm.gridlist, row, 4, "NIE", false, false)
            guiGridListSetItemColor(wm.gridlist, row, 4, 255, 0, 0)
        end
    end
end

local function fillLicenseData2()
    guiGridListClear(wm.gridlist)
    for i,v in ipairs(licenseCategory2) do
        local row=guiGridListAddRow(wm.gridlist)
        guiGridListSetItemText(wm.gridlist, row, 1, v[1], false, false)
        guiGridListSetItemText(wm.gridlist, row, 2, v[2], false, false)
        guiGridListSetItemText(wm.gridlist, row, 3, v[3].." PLN", false, false)
        guiGridListSetItemData(wm.gridlist, row, 3, v[3])
        -- Settings
        if getElementData(localPlayer,"player:license:pj"..v[1]) == 1 then
            guiGridListSetItemText(wm.gridlist, row, 4, "TAK", false, false)
            guiGridListSetItemColor(wm.gridlist, row, 4, 0, 255, 0)
        else
            guiGridListSetItemText(wm.gridlist, row, 4, "NIE", false, false)
            guiGridListSetItemColor(wm.gridlist, row, 4, 255, 0, 0)
        end
    end
end

addEventHandler("onClientClick", root, function(btn, state)
    if btn == "left" and state == "down" then
    if prawko == true then
    if mysz(352*w, 624*h, 210*w, 78*h) then
    local selectedRow=guiGridListGetSelectedItem(wm.gridlist)
    if not selectedRow or selectedRow < 0 then return end
    local cat=guiGridListGetItemText(wm.gridlist, selectedRow, 1)
    local cost=guiGridListGetItemData(wm.gridlist, selectedRow, 3)
    local zdane=guiGridListGetItemText(wm.gridlist, selectedRow, 4)
    if tonumber(cost) > getPlayerMoney(localPlayer) then
        --outputChatBox("* Nie posiadasz tyle got?wki.", 255, 0, 0)
        triggerEvent('onClientAddNotification', localPlayer, 'Nie posiadasz wystarczaj?co got?wki\ndo przyst?pienia egzaminu z prawa jazdy', 'error')
        return
    end
    --[[if getPlayerName(localPlayer) ~= "Split" then
        outputChatBox("* W budowie...", 255, 0, 0)
        return
    end]]
    if zdane ~= "TAK" then
        triggerServerEvent("license:do", resourceRoot, tonumber(cost), cat)
        if not guiGetVisible(wm.gridlist) then return end
        guiSetVisible(wm.gridlist, false)
        showCursor(false)
    prawko = false
        removeEventHandler("onClientRender",root,gui3)
    else
        --outputChatBox("* Posiadasz ju? zdane prawo jazdy.", 255, 0, 0)
        triggerEvent('onClientAddNotification', localPlayer, 'Posiadasz prawo jazdy zaznaczonej kategorii.', 'error')
    end
    end
    end
    end
end)

addEventHandler("onClientClick", root, function(btn, state)
    if btn == "left" and state == "down" then
    if prawko == true then
    if mysz(718*w, 624*h, 210*w, 78*h) then
    if not guiGetVisible(wm.gridlist) then return end
    showCursor(false)
    guiSetVisible(wm.gridlist, false)
    removeEventHandler("onClientRender",root,gui3)
    prawko = false
    end
    end
    end
end)

addEventHandler("onClientMarkerHit", marker, function(el,md)
    if not md or el~=localPlayer then return end
    if guiGetVisible(wm.gridlist) then return end
    showCursor(true)
    guiSetVisible(wm.gridlist,true)
    if prawko == false then
    addEventHandler("onClientRender",root,gui3)
    prawko = true
    fillLicenseData()
    end
end)

addEventHandler("onClientMarkerHit", marker2, function(el,md)
    if not md or el~=localPlayer then return end
    if guiGetVisible(wm.gridlist) then return end
    showCursor(true)
    guiSetVisible(wm.gridlist,true)
    if prawko == false then
    addEventHandler("onClientRender",root,gui3)
    prawko = true
    fillLicenseData2()
    end
end)

function gui3()
        dxDrawImage(315*w, 313*h, 650*w, 400*h, "img/prawojazdy-psrpg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end

c_zdawanie.lua

--[[
    Resource: OURGame v2
    Developers: Split <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c) 2015 <split.programista@gmail.com>. All rights reserved.
]]

local licenseBlip
local licenseTarget
local licenseMarker
local licenseVehicle
local licenseCategory

local categoryPositions={
    ["A"]={
        {2115.80, -1762.90, 13.40},
        {2135.09, -1752.26, 13.40},
        {2175.67, -1752.17, 13.38},
        {2184.91, -1740.53, 13.38},
        {2207.03, -1732.19, 13.41},
        {2215.90, -1768.81, 13.36},
        {2218.52, -1855.57, 13.36},
        {2218.59, -1894.08, 13.36},
        {2185.17, -1894.39, 13.47},
        {2092.06, -1894.47, 13.47},
        {2082.00, -1908.50, 13.47},
        {2056.64, -1932.55, 13.47},
        {1991.55, -1932.46, 13.47},
        {1929.69, -1932.33, 13.47},
        {1857.41, -1932.47, 13.47},
        {1821.68, -1916.36, 13.47},
        {1804.67, -1895.92, 13.47},
        {1804.05, -1930.69, 13.47},
    },
    ["C"]={
        {2072.98, -1915.36, 13.55},
        {2080.45, -1908.60, 13.36},
        {2078.39, -1819.79, 13.36},
        {2092.70, -1752.02, 13.36},
        {2112.70, -1677.58, 13.36},
        {2112.76, -1608.70, 24.23},
        {2112.74, -1527.84, 23.85},
        {2112.71, -1479.04, 23.85},
        {2083.44, -1463.29, 23.85},
        {2019.42, -1463.45, 13.60},
        {1938.50, -1463.52, 13.60},
        {1863.57, -1463.25, 13.60},
        {1849.31, -1481.45, 13.60},
        {1832.49, -1544.36, 13.60},
        {1821.70, -1661.64, 13.60},
        {1821.78, -1815.02, 13.60},
        {1821.83, -1864.70, 13.60},
        {1816.34, -1884.93, 13.60},
        {1789.48, -1908.26, 13.60},
        {1775.47, -1919.50, 13.39},
    },
    ["B"]={
        {1800.55, -1854.99, 13.41},
        {1820.21, -1833.07, 13.41},
        {1793.59, -1830.77, 13.41},
        {1701.16, -1811.66, 13.41},
        {1689.84, -1774.26, 13.41},
        {1689.66, -1736.18, 13.41},
        {1688.81, -1618.47, 13.38},
        {1690.25, -1593.72, 13.38},
        {1734.13, -1597.24, 13.38},
        {1776.04, -1607.57, 13.38},
        {1813.59, -1612.92, 13.38},
        {1821.72, -1652.37, 13.38},
        {1821.94, -1760.65, 13.38},
        {1820.98, -1808.64, 13.38},
        {1820.73, -1853.71, 13.38},
        {1818.94, -1889.82, 13.39},
        {1803.95, -1891.31, 13.39},
        {1777.80, -1891.23, 13.39},
         
    },
    ["L"]={
        {-2227.07, 2287.34, 26.95},
        {-2269.48, 2247.53, 35.66},
        {-2339.91, 2199.13, 35.66},
        {-2472.09, 2112.43, 35.66},
        {-2549.21, 2064.18, 35.66},
        {-2672.07, 2004.84, 35.66},
        {-2748.91, 1935.96, 35.66},
        {-2681.77, 1846.71, 42.90},
        {-2444.56, 1937.27, 45.25},
        {-2341.07, 1992.45, 45.25},
        {-2206.64, 2108.53, 45.25},
        {-2227.78, 2326.71, 8.60},
    },
    ["T"]={
        {-2003.43,438.75,35.02},
        {-2003.63, 380.51, 35.50},
        {-2003.63, 348.35, 35.50},
        {-2003.76, 303.06, 35.29},
        {-2005.54, 250.22, 30.41},
        {-2006.50, 194.44, 28.00},
        {-2006.50, 128.62, 28.00},
        {-2006.54, 52.03, 31.28},
        {-2062.99, 30.38, 35.62},
        {-2136.52, 30.39, 35.62},
        {-2166.63, -15.67, 35.62},
        {-2188.21, -70.00, 35.62},
        {-2254.33, -61.16, 35.62},
        {-2254.57, 11.85, 35.62},
        {-2252.38, 88.17, 35.62},
        {-2251.50, 164.36, 35.62},
        {-2251.39, 242.88, 35.62},
        {-2251.43, 322.06, 35.62},
        {-2290.05, 400.80, 35.47},
        {-2357.34, 477.06, 31.12},
        {-2287.46, 508.61, 35.50},
        {-2264.88, 614.11, 44.05},
        {-2264.94, 748.61, 49.81},
        {-2264.88, 892.21, 66.91},
        {-2264.81, 1013.76, 84.66},
        {-2264.47, 1072.97, 81.14},
        {-2263.62, 1095.95, 80.17},
    },
}

function finishLicense(value)
    if isElement(licenseMarker) and licenseMarker then
        destroyElement(licenseMarker)
        licenseMarker=nil
    end
    if isElement(licenseBlip) and licenseBlip then
        destroyElement(licenseBlip)
        licenseBlip=nil
    end
    if value == true then
        licenseCategory=nil
        licenseVehicle=nil
        licenseMarker=nil
        licenseTarget=nil
        licenseBlip=nil
    end
end
addEvent("license:finish",true)
addEventHandler("license:finish", resourceRoot, finishLicense)

function showMarker()
    local pos=categoryPositions[licenseCategory][licenseTarget]
    if licenseCategory ~= "L" then
    licenseMarker=createMarker(pos[1], pos[2], pos[3], "checkpoint", 2, 0, 0, 255, 155)
    else
    licenseMarker=createMarker(pos[1], pos[2], pos[3], "ring", 3.5, 0, 0, 255, 155)
    end
    licenseBlip=createBlip(pos[1], pos[2], pos[3], 41, 1.15, 0, 255, 0)
    if categoryPositions[licenseCategory][licenseTarget+1] then
          e=categoryPositions[licenseCategory][licenseTarget+1]
        setMarkerTarget(licenseMarker, e[1], e[2], e[3])
    end
    addEventHandler("onClientMarkerHit", licenseMarker, function(el,md)
        if not md or el~=localPlayer then return end
        if not getPedOccupiedVehicle(el) then return end
        if licenseTarget < #categoryPositions[licenseCategory] then
            --local sound=playSound(":ogrpg-misc/misc/point.wav")
            --setSoundVolume(sound, 1.0)
            
            finishLicense(false)
            licenseTarget=licenseTarget+1
            showMarker()
        else
            --local sound=playSound(":ogrpg-misc/misc/success.flac")
            --setSoundVolume(sound, 1.0)

            --outputChatBox("* Zda?e?(a?) egzamin. Gratulacje!")
            triggerEvent('onClientAddNotification', localPlayer, 'Pomy?lnie zda?e? egzamin z prawa jazdy.\nGratulacje!', 'success')
            triggerServerEvent("license:vehdel", resourceRoot, licenseVehicle)
            setElementData(localPlayer,"player:license:pj"..licenseCategory, 1)
            finishLicense(true)
            fadeCamera(kierowca,false,1)
            setTimer(fadeCamera,1000,1,kierowca,true,1)
            setTimer(setElementPosition,1001,1,kierowca,1749.11, -1860.73, 13.57)
        end
    end)
end

addEvent("license:start",true)
addEventHandler("license:start", resourceRoot, function(category,vehicle)
    licenseTarget=1
    licenseBlip=nil
    licenseMarker=nil
    licenseCategory=category
    licenseVehicle=vehicle
    showMarker()
end)

punkty={}

function nalicz()
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    local x,y,z=getElementPosition(veh)
    table.insert(punkty, {x,y,z})
    outputChatBox("* Dodano")
end

addCommandHandler("zakoncz", function()
    for i,v in ipairs(punkty) do
        lol=string.format("{%.02f, %.02f, %.02f},", v[1], v[2], v[3])
        outputChatBox("        "..lol)
        killTimer(punkty_timer)
    end
end)

addCommandHandler("licz", function()
    outputChatBox("* Rozpocz??e?(a?) naliczanie, aby zako?czy? wpisz /zakoncz")
    punkty_timer=setTimer(nalicz, 3000, 0)
end)--]]

s_zdawanie.lua

--[[
    Resource: OURGame v2
    Developers: Split <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c) 2015 <split.programista@gmail.com>. All rights reserved.
]]

--[[local marker2=createMarker(-2050.29,-106.16,35.24,"corona",2,170,200,0)

addEventHandler("onMarkerHit", marker2, function(el,md)
 setElementPosition(el,-2044.69,-94.57,35.17 )
end)--]]

--local zone = createColCuboid(-157.62562561035, 1108.4052734375, 18.613729476929, 7, 9.8, 6.4)
createBlip(-2237.23, 2353.97, 4.98, 5,2,0,0,0,0,0,275) 

addEvent("license:do",true)
addEventHandler("license:do", resourceRoot, function(cost,selected)
    if tonumber(cost) <= getPlayerMoney(client) then
        takePlayerMoney(client,cost)
    end

    local veh=nil
  licka_object = {}
      local elka = createObject(323,0,0,0)
        setElementCollisionsEnabled(elka, false)
    if selected == "A" then veh=createVehicle(463, 2116.76, -1783.53, 13.05, 0.0, 0.0, 4.2)
    attachElements(elka, veh, 0,-1.25,0.10,140,0,180)
    elseif selected == "B" then veh=createVehicle(458, 1725.82, -1854.93, 13.29, 360.0, 360.0, 269.3)
    attachElements(elka, veh, 0,0.10,0.7,90,0,180)
    elseif selected == "C" then veh=createVehicle(414, 2052.25, -1913.67, 13.23, 360.0, 0.0, 270.8)
    attachElements(elka, veh, 0,0.50,2.35,90,0,180)
    elseif selected == "L" then veh=createVehicle(469, -2227.61, 2325.41, 7.60, 0.2, 359.8, 180.0) end
    if not veh then return end
    if selected == "L" then
    setElementData(veh,"vehicle:desc","Egzamin Licencji Lotniczej\nKategoria "..selected)
    else
    setElementData(veh,"vehicle:desc","Egzamin prawa jazdy\nKategoria "..selected)
    end
    setElementData(veh,"vehicle:mileage",16442)
    setElementData(veh,"vehicle:fuel",100)
    setElementData(veh,"vehicle:lic",true)
    setElementDimension(client,0)
    setElementInterior(client,0)
    warpPedIntoVehicle(client,veh)
    triggerClientEvent(client, "license:start", resourceRoot, selected, veh)
end)

addEvent("license:vehdel", true)
addEventHandler("license:vehdel", resourceRoot, function(veh)
    destroyElement(veh)
end)

addEventHandler("onPlayerQuit", root, function()
    local veh=getPedOccupiedVehicle(source)
    if not veh then return end
    if getVehicleController(veh) ~= source then return end
    if not getElementData(veh,"vehicle:lic") then return end
    destroyElement(veh)
end)

addEventHandler("onVehicleDamage", resourceRoot, function(loss)
    local kierowca=getVehicleController(source)
    local lot = getElementModel(source)
    if not kierowca then return end
    if not getElementData(source,"vehicle:lic") then return end
    destroyElement(source)
    --outputChatBox("* Uszkodzi?e?(a?) pojazd, nie zdajesz egzaminu!", kierowca, 255, 0, 0)
    triggerClientEvent(kierowca, 'onClientAddNotification', kierowca, 'Uszkodzi?e?/a? pojazd egzaminacyjny,\nnie zdajesz egzaminu.', 'error')
    triggerClientEvent(kierowca, "license:finish", resourceRoot, true)
    fadeCamera(kierowca,false,1)
    setTimer(fadeCamera,1000,1,kierowca,true,1)
    if lot == 469 then
    setTimer(setElementPosition,1001,1,kierowca,-2240.70, 2350.85, 4.98)
    else
    setTimer(setElementPosition,1001,1,kierowca,1749.11, -1860.73, 13.57)
    end
end)

addEventHandler("onVehicleStartExit", resourceRoot, function()
    cancelEvent()
end)

--[[addCommandHandler("lotgp", function(plr,cmd)
    local x,y,z=getElementPosition(plr)
    local p=string.format("{%.02f, %.02f, %.02f},", x,y,z)
    outputChatBox(p, plr)
end)

addCommandHandler("lotgp2", function(plr,cmd)
    local veh=getPedOccupiedVehicle(plr)
    if not veh then return end
    local x,y,z=getElementPosition(veh)
    local rx,ry,rz=getElementRotation(veh)
    local p=string.format("%.02f, %.02f, %.02f, %.02f, %.02f, %.02f", x,y,z,rx,ry,rz)
    outputChatBox(p, plr)
end)--]]


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-05-24, 15:03


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8


Więcej informacji znajdziesz w Wikipedii MTA:

setElementCollidableWith


Postaw piwo autorowi tego posta
 

 
Tagi: wylaczenie :: kolizji :: pojazdow :: zdawajacych :: prawko
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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