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

Wysłany: 2019-02-06, 01:32


killercycDDS

Migacz






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

Piwa: 1659

Respekt: 22

Witam bawi? si? w przerabianie prac i napotka?em pewien problem ot?? nie wiem jak zrobi? odczyt pozycji randomowego markeru np w innym pliku mam spis marker?w. Losuje mi jaki? randomowy i jak zrobi? by odczyta? ten marker i pokaza? dok?d mamy jecha?. Wiem tyle, ?e do odczytu s?u?y getZoneName


local function deleteElements(textcolor)
    guiGridListClear(data.gridlist[1])
    showCursor(not isCursorShowing(), false)
    guiSetVisible(data.window[1], not guiGetVisible(data.window[1]))
    
    if text and color then
        outputChatBox(textcolor[1], color[2], color[3], true)
    end
end

local function checkPlayerVehicle(player)
    local vehicle player.vehicle
    if vehicle and vehicle.controller == player then
        if vehicle.model == 482 or vehicle.model == 413 or vehicle.model == 456 or vehicle.model == 414 or vehicle.model == 455 or vehicle.model == 609 or vehicle.model == 515 then
            return true
        end
    end
    return falseoutputChatBox("Tw?j pojazd nie jest pojazdem dostawczym !"25500true)
end

_fadeCamera fadeCamera
local function fadeCamera(optionplayer)
    if player:getData("player:vip"then timestamp 6000 else timestamp 10000 end
    if player:getData("player:svip"then timestamp 4000 else timestamp 10000 end
    if player:getData("player:mpremium"then timestamp 1000 else timestamp 10000 end
    local vehicle player.vehicle
    
    if option == "commencement" then
        _fadeCamera(false1000)
        addEventHandler("onClientRender",root,render)
        setElementData(player,"player:hud_visible",true)
        showChat(false)
        vehicle.frozen not vehicle.frozen
        
        Timer(function()
            _fadeCamera(true1)
            vehicle.frozen not vehicle.frozen
            renderstop()
            showChat(true)
            setElementData(player,"player:hud_visible",false)
        endtimestamp1)
    elseif option == "end" then
        _fadeCamera(false1000)
        addEventHandler("onClientRender",root,render2)
        setElementData(player,"player:hud_visible",true)
        showChat(false)
        vehicle.frozen not vehicle.frozen
        
        Timer(function()
            _fadeCamera(true1)
            vehicle.frozen not vehicle.frozen
            --vehicle:setData("vehicle:desc",false)
            triggerServerEvent("remove3DTextFromElement"rootvehicle)
            renderstop2()
            showChat(true)
            setElementData(player,"player:hud_visible",false)
            local data player:getData("player:order")
            if data then
                outputChatBox("Otrzymujesz "..data.received.." + 1PKT pracy!"02550true)
            end
            triggerServerEvent("iyw_kurier:give_cash"resourceRootstring.gsub(data.received"£"""))
            
            if isElement(sphere) and isElement(blipthen
                blip:destroy()
                sphere:destroy()
            end
            
            player:setData("player:order"false)
        endtimestamp1)
    end
end

addEventHandler("onClientMarkerHit"resourceRoot, function(playerdimension)
    if player == localPlayer and dimension then
        if source:getData("marker:loading"then
            local vehicle player.vehicle
            if not vehicle or vehicle.controller ~= player then return false end

            if not player:getData("player:order"then
                if checkPlayerVehicle(playerthen
                    for i,v in ipairs(data.order) do
                        guiGridListAddRow(data.gridlist[1])
                        guiGridListSetItemText(data.gridlist[1], i-11ifalsefalse)
                        guiGridListSetItemText(data.gridlist[1], i-12v[1], falsefalse)
                        guiGridListSetItemText(data.gridlist[1], i-13string.format("%.00f PLN"v[2]), falsefalse)
                        guiGridListSetItemText(data.gridlist[1], i-14tonumber(v[3]), falsefalse)
                    end
                    
                    showCursor(not isCursorShowing(), false)
                    guiSetVisible(data.window[1], not guiGetVisible(data.window[1]))
                    guiSetText(data.window[1], "Praca spedytora - ilo?? PKT: "..player:getData("player:scorespedytor").."")
                end
            end
        end
    end
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(playerdimension)
    if player == localPlayer and dimension then
        if source:getData("marker:loading"then
            local vehicle player.vehicle
            if not vehicle then return false end

            if guiGetVisible(data.window[1]) then
                deleteElements(_,_)
            end
        end
    end
end)

addEventHandler("onClientVehicleExit"root, function(playerseat)
    local kara = (15000)
    if player == localPlayer and seat then
        if player:getData("player:order"then
            player:setData("player:order"false)
            takePlayerMoney(kara)
            outputChatBox("Opu?ci?e?(a?) pojazd maj?c aktywny kurs, praca zostaje przerwana. Otrzymujesz kar? wysoko?ci " ..kara.. " £ "25500true)
            if isElement(sphere) or isElement(blipthen
                sphere:destroy()
                blip:destroy()
            end
        end
    end
end)

addEventHandler("onClientGUIClick"resourceRoot, function(buttonstate)
    if button == "left" and state == "up" then
        if source == data.button[1then
            local selected guiGridListGetSelectedItem(data.gridlist[1]) or -1
            if selected 0 then return falseoutputChatBox("Najpierw zaznacz towar!"25500trueend
            
            local id guiGridListGetItemText(data.gridlist[1], selected1)
            local name guiGridListGetItemText(data.gridlist[1], selected2)
            local money guiGridListGetItemText(data.gridlist[1], selected3)
            local score guiGridListGetItemText(data.gridlist[1], selected4)
            local v getPedOccupiedVehicle (localPlayer)
            local xygetElementPosition (co tu wstawic)
            local location getZoneName xy)
            local miasto getZoneName (xyztrue)
            
            if (tonumber(localPlayer:getData("player:scorespedytor")) >= tonumber(score)) then
                randomResult math.random(1#data.marker)
                local position = {getElementPosition(localPlayer)}
                if getDistanceBetweenPoints3D(position[1], position[2], position[3], data.marker[randomResult][1], data.marker[randomResult][2], data.marker[randomResult][3]) <= 20 then
                    outputChatBox("Wylosowano bliski marker, sp?buj ponownie!"25500true)
                else
                    fadeCamera("commencement"localPlayer)
                    deleteElements("Podj??e? zlecenie, udaj si? do punktu oznaczonym blipem 'C'!, Punkt znajduje sie w "..miasto.. " w " ..location.. "  Powodzenia ", {02550})
                    localPlayer:setData("player:order", {["name"] = string.lower(name), ["received"] = money})
                    --v:setData("vehicle:desc","Praca Transportera\nZa?adunek: "..name.."")
                    triggerServerEvent("add3DTextForElement"rootv,{0,0,0},"Praca Transportera\nZa?adunek: "..name.."",{255,255,255,255},"czcionka4",1.0,30,1)
                    sphere ColShape.Sphere(data.marker[randomResult][1], data.marker[randomResult][2], data.marker[randomResult][3], 3.50)
                    blip createBlipAttachedTo(sphere12625500255099999.0)
                end
                
                addEventHandler("onClientColShapeHit"resourceRoot, function(playerdimension)
                    if player == localPlayer and dimension then
                        if source == sphere then
                            fadeCamera("end"player)
                        end
                    end
                end)
            else
                return falseoutputChatBox("Nie posiadasz tyle punkt?w! ("..score.." score)"25500true)
            end
        elseif source == data.button[2then
            deleteElements(_,_)
        end
    end
end)

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

function render()
    dxDrawImage(433*w259*h500*w200*h"img/zaladunek.png"000tocolor(255255255255), false)
end

function render2()
    dxDrawImage(433*w259*h500*w200*h"img/rozladunek.png"000tocolor(255255255255), false)
end

function renderstop()
    removeEventHandler("onClientRender",root,render)
end

function renderstop2()
    removeEventHandler("onClientRender",root,render2)
end


a chodzi mi o t? linijk? bo nie wiem co wstawi?

            local xygetElementPosition (co tu wstawic)
            local location getZoneName xy)
            local miasto getZoneName (xyztrue)


markery w innym pliku

data = {gridlist = {}, window = {}, button = {}, size 4lastRandomResultcolor = {009080}}
data.marker = {
    {369.75, -2043.867.67},
    {848.63, -1822.1312.19},
    {-1567.03, -2735.3048.54},
    {-2328.49, -1618.51483.71},
    {-1945.10, -1084.7030.78},
    {-2524.29, -604.01132.56},
    {-2793.32, -380.377.04},
    {-2354.25, -154.4535.32},
    {-2769.76229.407.06},
    {-2208.21639.7649.44},
    {-1790.541428.627.19},
    {-2512.311205.4137.42},
    {-2261.072287.734.82},
    {-1267.022708.0350.07},
    {-926.002026.4860.91},
    {-366.771129.8419.76},
    {2144.142808.8610.82},
    {2444.982290.2610.82},
    {1722.322105.3410.82},
    {2206.281514.6710.82},
    {2461.041158.9610.82},
    {1542.481033.9010.82},
    {1098.741450.0812.55},
    {1500.63773.2410.82},
    {1288.60342.6519.55},
    {1925.90174.9037.28},
}


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-06, 16:06


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4006 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2176

Respekt: 110
Respekt: 110

Masz poprawiony kod, powinno dzia?a?.

local function deleteElements(textcolor)
    guiGridListClear(data.gridlist[1])
    showCursor(not isCursorShowing(), false)
    guiSetVisible(data.window[1], not guiGetVisible(data.window[1]))
    
    if text and color then
        outputChatBox(textcolor[1], color[2], color[3], true)
    end
end

local function checkPlayerVehicle(player)
    local vehicle player.vehicle
    if vehicle and vehicle.controller == player then
        if vehicle.model == 482 or vehicle.model == 413 or vehicle.model == 456 or vehicle.model == 414 or vehicle.model == 455 or vehicle.model == 609 or vehicle.model == 515 then
            return true
        end
    end
    return falseoutputChatBox("Tw?j pojazd nie jest pojazdem dostawczym !"25500true)
end

_fadeCamera fadeCamera
local function fadeCamera(optionplayer)
    if player:getData("player:vip"then timestamp 6000 else timestamp 10000 end
    if player:getData("player:svip"then timestamp 4000 else timestamp 10000 end
    if player:getData("player:mpremium"then timestamp 1000 else timestamp 10000 end
    local vehicle player.vehicle
    
    if option == "commencement" then
        _fadeCamera(false1000)
        addEventHandler("onClientRender",root,render)
        setElementData(player,"player:hud_visible",true)
        showChat(false)
        vehicle.frozen not vehicle.frozen
        
        Timer(function()
            _fadeCamera(true1)
            vehicle.frozen not vehicle.frozen
            renderstop()
            showChat(true)
            setElementData(player,"player:hud_visible",false)
        endtimestamp1)
    elseif option == "end" then
        _fadeCamera(false1000)
        addEventHandler("onClientRender",root,render2)
        setElementData(player,"player:hud_visible",true)
        showChat(false)
        vehicle.frozen not vehicle.frozen
        
        Timer(function()
            _fadeCamera(true1)
            vehicle.frozen not vehicle.frozen
            --vehicle:setData("vehicle:desc",false)
            triggerServerEvent("remove3DTextFromElement"rootvehicle)
            renderstop2()
            showChat(true)
            setElementData(player,"player:hud_visible",false)
            local data player:getData("player:order")
            if data then
                outputChatBox("Otrzymujesz "..data.received.." + 1PKT pracy!"02550true)
            end
            triggerServerEvent("iyw_kurier:give_cash"resourceRootstring.gsub(data.received"&#163;"""))
            
            if isElement(sphere) and isElement(blipthen
                blip:destroy()
                sphere:destroy()
            end
            
            player:setData("player:order"false)
        endtimestamp1)
    end
end

addEventHandler("onClientMarkerHit"resourceRoot, function(playerdimension)
    if player == localPlayer and dimension then
        if source:getData("marker:loading"then
            local vehicle player.vehicle
            if not vehicle or vehicle.controller ~= player then return false end

            if not player:getData("player:order"then
                if checkPlayerVehicle(playerthen
                    for i,v in ipairs(data.order) do
                        guiGridListAddRow(data.gridlist[1])
                        guiGridListSetItemText(data.gridlist[1], i-11ifalsefalse)
                        guiGridListSetItemText(data.gridlist[1], i-12v[1], falsefalse)
                        guiGridListSetItemText(data.gridlist[1], i-13string.format("%.00f PLN"v[2]), falsefalse)
                        guiGridListSetItemText(data.gridlist[1], i-14tonumber(v[3]), falsefalse)
                    end
                    
                    showCursor(not isCursorShowing(), false)
                    guiSetVisible(data.window[1], not guiGetVisible(data.window[1]))
                    guiSetText(data.window[1], "Praca spedytora - ilo?? PKT: "..player:getData("player:scorespedytor").."")
                end
            end
        end
    end
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(playerdimension)
    if player == localPlayer and dimension then
        if source:getData("marker:loading"then
            local vehicle player.vehicle
            if not vehicle then return false end

            if guiGetVisible(data.window[1]) then
                deleteElements(_,_)
            end
        end
    end
end)

addEventHandler("onClientVehicleExit"root, function(playerseat)
    local kara = (15000)
    if player == localPlayer and seat then
        if player:getData("player:order"then
            player:setData("player:order"false)
            takePlayerMoney(kara)
            outputChatBox("Opu?ci?e?(a?) pojazd maj?c aktywny kurs, praca zostaje przerwana. Otrzymujesz kar? wysoko?ci " ..kara.. " &#163; "25500true)
            if isElement(sphere) or isElement(blipthen
                sphere:destroy()
                blip:destroy()
            end
        end
    end
end)

addEventHandler("onClientGUIClick"resourceRoot, function(buttonstate)
    if button == "left" and state == "up" then
        if source == data.button[1then
            local selected guiGridListGetSelectedItem(data.gridlist[1]) or -1
            if selected 0 then return falseoutputChatBox("Najpierw zaznacz towar!"25500trueend
            
            local id guiGridListGetItemText(data.gridlist[1], selected1)
            local name guiGridListGetItemText(data.gridlist[1], selected2)
            local money guiGridListGetItemText(data.gridlist[1], selected3)
            local score guiGridListGetItemText(data.gridlist[1], selected4)
            local v getPedOccupiedVehicle (localPlayer)
            randomResult math.random(1#data.marker)
            local xydata.marker[randomResult][1], data.marker[randomResult][2], data.marker[randomResult][3]
            local location getZoneName xy)
            local miasto getZoneName (xyztrue)
            
            if (tonumber(localPlayer:getData("player:scorespedytor")) >= tonumber(score)) then
                local position = {getElementPosition(localPlayer)}
                if getDistanceBetweenPoints3D(position[1], position[2], position[3], data.marker[randomResult][1], data.marker[randomResult][2], data.marker[randomResult][3]) <= 20 then
                    outputChatBox("Wylosowano bliski marker, sp?buj ponownie!"25500true)
                else
                    fadeCamera("commencement"localPlayer)
                    deleteElements("Podj??e? zlecenie, udaj si? do punktu oznaczonym blipem 'C'!, Punkt znajduje sie w "..miasto.. " w " ..location.. "  Powodzenia ", {02550})
                    localPlayer:setData("player:order", {["name"] = string.lower(name), ["received"] = money})
                    --v:setData("vehicle:desc","Praca Transportera\nZa?adunek: "..name.."")
                    triggerServerEvent("add3DTextForElement"rootv,{0,0,0},"Praca Transportera\nZa?adunek: "..name.."",{255,255,255,255},"czcionka4",1.0,30,1)
                    sphere ColShape.Sphere(data.marker[randomResult][1], data.marker[randomResult][2], data.marker[randomResult][3], 3.50)
                    blip createBlipAttachedTo(sphere12625500255099999.0)
                end
                
                addEventHandler("onClientColShapeHit"resourceRoot, function(playerdimension)
                    if player == localPlayer and dimension then
                        if source == sphere then
                            fadeCamera("end"player)
                        end
                    end
                end)
            else
                return falseoutputChatBox("Nie posiadasz tyle punkt?w! ("..score.." score)"25500true)
            end
        elseif source == data.button[2then
            deleteElements(_,_)
        end
    end
end)

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

function render()
    dxDrawImage(433*w259*h500*w200*h"img/zaladunek.png"000tocolor(255255255255), false)
end

function render2()
    dxDrawImage(433*w259*h500*w200*h"img/rozladunek.png"000tocolor(255255255255), false)
end

function renderstop()
    removeEventHandler("onClientRender",root,render)
end

function renderstop2()
    removeEventHandler("onClientRender",root,render2)
end 


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
killercycDDS
Wysłany: 2019-02-06, 16:41


killercycDDS

Migacz






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

Piwa: 1659

Respekt: 22

dzi?ki za pomoc temat rozwi?zany i do zamkni?cia

Postaw piwo autorowi tego posta
 

 
Tagi: odczyt :: pozycji :: markera
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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