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

Wysłany: 2018-09-20, 13:20


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Witam mam problem jak wsiadam to pojazdu nie pokazuje si? licznik za pomoc postawie :piwo:

Client:
destinationMarker = nil
destBlip = nil
reloadMarker = createMarker(1361.59,-1658.41,12.33, "cylinder", 5.0, 255, 0, 0, 130)
local Blip = createBlip(1361.59,-1658.41,13.38, 52)
local text = createElement("text")
setElementData(text, "name", "Praca dorywcza\nGĂłrnik")
setElementPosition(text, 1361.59, -1658.41, 12.33)

unloadingPos = {
{1678.28,-1652.64,13.54},
{1694.05,-1520.45,13.55},
{1973.20,-1708.96,15.97},
{2072.35,-1731.97,13.55},
{2070.75,-1654.92,13.55},
{2101.90,-1805.95,13.55},
}

function endOfWork()
if destinationMarker and isElement(destinationMarker) then
destroyElement(destinationMarker)
destinationMarker = nil
end
if destBlip and isElement(destBlip) then
destroyElement(destBlip)
destBlip = nil
end
end


function takeFurniture(he, md, plr)
if he ~= localPlayer then return end
if not getPedOccupiedVehicle(he) then return end

local car = getPedOccupiedVehicle(he)

if getElementData(car, "pojazd_opis") == "Dostawca Gazu - Firma GAZOL" then
     if getElementData(he, "zaladowany") == false then  
        setElementFrozen(car,true)
        outputChatBox("* Ladujesz Butle z gazem na pake. Prosze Czekac!", 255, 255, 255)
        setTimer(function()
    setElementData(car, "pojazd_opis", "Dostawca Gazu - Firma GAZOL")
        setElementFrozen(car,false)
    outputChatBox("* Zaladowales Pojazd Butlami z Gazem, Jedz Do klienta, punkt jest oznaczony Blipem 'C' na mapie", 255, 255, 255)
    setElementData(he, "zaladowany", true)
        showDestination()
        end, 5000, 1)
    else
    outputChatBox("Nie moĹĽesz kilka razy ?‚adowa?‡ pojazdu", plr)
    end
end
end
addEventHandler("onClientMarkerHit", reloadMarker, takeFurniture)

function showDestination()
local rand = math.random(1, #unloadingPos)
local destMarker = unloadingPos[rand]
destinationMarker = createMarker(destMarker[1], destMarker[2], destMarker[3], "checkpoint", 2.7, 255, 0, 0, 130)
destBlip = createBlipAttachedTo(destinationMarker, 12)
addEventHandler("onClientMarkerHit", destinationMarker, unloadFurniture)
end

function unloadFurniture(he, md)
if he ~= localPlayer then return end
if not getPedOccupiedVehicle(he) then return end

local carr = getPedOccupiedVehicle(he)

if getElementData(carr, "pojazd_opis") == "Dostawca Gazu - Firma GAZOL" then
if getElementData(he, "zaladowany") == true then
    outputChatBox("* Dojechales Do klienta i zainstalowales mu butle z gazem w kuchni! Wroc Do pracodawcy Po kolejne butle!", 255, 255, 255)
    setElementData(he, "zaladowany", false)
    setElementData(carr, "pojazd_opis", "Dostawca Gazu - Firma GAZOL")
    triggerServerEvent("givePlayerMoney", localPlayer, 65)
        outputChatBox("* Dostajesz 65.00 PLN za dostarczenie butli dla klientow.", 55, 146, 0)
    endOfWork()
else
    outputChatBox("* Brak butli na pace, twoje auto nie jest zaladowane butlami!", 255, 0, 0)
end
end
end


addEvent("kurier_praca", true)
addEventHandler("kurier_praca", resourceRoot, function()
takeFurniture(he, md)
end)

addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
    if seat == 0 then
        if plr == localPlayer then
            setElementData(plr, "graczPraca", false)
            setElementData(plr, "zaladowany", false)
            outputChatBox("* Zakonczyles/as Prace Dostawcy Gazu firmy GAZOL!", 255, 255, 255)
            endOfWork()
        end
    end
end)

addEventHandler("onClientPlayerQuit", resourceRoot, function(plr)
setElementData(source, "graczPraca", false)
setElementData(plr, "zaladowany" ,false)
end)

addEventHandler("onClientPlayerWasted", resourceRoot, function(plr)
setElementData(source, "graczPraca", false)
setElementData(plr, "zaladowany", false)
outputChatBox("* Zginales podczas dorywczej pracy! Musisz zaczac od nowa!", 255, 0, 0)
end)

addEventHandler("onClientResourceStop", resourceRoot, function()
setElementData(localPlayer, "graczPraca", false)
setElementData(plr, "zaladowany", false)
end)
[/code]

Serwer:
Pojazdy = {
{1361.71,-1651.20,13.37,359.2,360.0,270.1},
{1361.23,-1643.24,13.39,358.7,0.1,270.9},
{1361.22,-1635.37,13.39,358.7,360.0,269.9},
}

for i,v in ipairs(Pojazdy) do
    local Pojazd = createVehicle(482, v[1], v[2], v[3]+0.3, v[4], v[5], v[6])
    setElementData(Pojazd, "pojazd_opis", "Dostawca Gazu - Firma GAZOL")
    setVehicleColor (Pojazd, 0, 255, 84 )
    setVehicleHandling(Pojazd,"maxVelocity",60)
    setElementData(Pojazd, "pojazdy_przebieg", math.random(500, 1000))
    setElementData(Pojazd, "pojazdy_paliwo", 50)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        if getElementData(plr, "graczPraca") == false then
            setElementData(plr, "graczPraca", true)
            setElementFrozen(source, false)
            outputChatBox("* Rozpoczales Prace Jako Dostawca Butli z Gazem, Jedz Zaladowac butle z gazem na pake!", plr, 255, 255, 255)
            triggerClientEvent(plr, "kurier_praca", resourceRoot)
        else
            outputChatBox("* Posiadasz Juz Aktywna Prace!", plr, 255, 0, 0)
        end
    end
end)



function respawnVehicles()
    for i,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
        if not getVehicleOccupant(v) then
            respawnVehicle(v)
            setElementFrozen(v, true)
            setElementData(v, "pojazd_opis", "Dostawca Gazu - Firma GAZOL")
            setVehicleColor (v, 0, 255, 84 )
            setVehicleHandling(v,"maxVelocity",100)
            setElementData(v, "pojazdy_przebieg", math.random(500, 1000))
            setElementData(v, "pojazd_paliwo", 50)
            setVehicleEngineState(v, false)
        end
    end
end
setTimer(respawnVehicles, 5000, 0)
addEvent("checkCars", true)
addEventHandler("checkCars", resourceRoot, respawnVehicles)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 15:48


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

Poka? kod od licznika

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 15:55


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kalizman, Masz tutaj skrypt na licznik

limit = true

allowedTypes = { "Automobile" }

function getElementSpeed(element,unit)
    if (unit == nil) then unit = 0 end
    if (isElement(element)) then
        local x,y,z = getElementVelocity(element)
        if (unit=="mph" or unit==1 or unit =='1') then
            return (x^2 + y^2 + z^2) ^ 0.5 * 100
        else
            return (x^2 + y^2 + z^2) ^ 0.5 * 180
        end
    else
        return false
    end
end

function setElementSpeed(element, unit, speed)
    if (unit == nil) then unit = 0 end
    if (speed == nil) then speed = 0 end
    speed = tonumber(speed)
    local acSpeed = getElementSpeed(element, unit)
    if (acSpeed~=false) then 
        local diff = speed/acSpeed
        local x,y,z = getElementVelocity(element)
        setElementVelocity(element,x*diff,y*diff,z*diff)
        return true
    else
        return false
    end
end

function in_array(e, t)
    for _,v in pairs(t) do
        if (v==e) then return true end
    end
    return false
end

function round2(num, idp)
  return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end


function angle(vehicle)
    local vx,vy,vz = getElementVelocity(vehicle)
    local modV = math.sqrt(vx*vx + vy*vy)
    
    if not isVehicleOnGround(vehicle) then return 0,modV end
    
    local rx,ry,rz = getElementRotation(vehicle)
    local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz))
    
    local cosX = (sn*vx + cs*vy)/modV
    return math.deg(math.acos(cosX))*0.5, modV
end

lp = getLocalPlayer()
ccEnabled = false

myveh = false
targetSpeed = 1
multiplier = 1

function cc()
    if (not isElement(myveh)) then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
        return false
    end
    if getVehicleEngineState(myveh) == false then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
        return false
    end
    local x,y = angle(myveh)
    if (x<15) then
        local speed = getElementSpeed(myveh)
        local targetSpeedTmp = speed + multiplier
        if (targetSpeedTmp > targetSpeed) then
            targetSpeedTmp = targetSpeed
        end
        if (targetSpeedTmp > 3) then
            setElementSpeed(myveh, "k", targetSpeedTmp)
        end
    end
end

bindKey("j", "up", function()
    local veh = getPedOccupiedVehicle(lp)
    if (veh) then
        if (lp==getVehicleOccupant(veh)) then
            myveh = veh
            if (ccEnabled) then
                removeEventHandler("onClientRender", getRootElement(), cc)
                ccEnabled=false
            else
                targetSpeed = getElementSpeed(veh)
                if targetSpeed > 4 then
                    if (limit) then
                        if in_array(getVehicleType(veh), allowedTypes) then
                            targetSpeed = round2(targetSpeed)
                            addEventHandler("onClientRender", getRootElement(), cc)
                            ccEnabled=true                
                        end
                    else
                        targetSpeed = round2(targetSpeed)
                        addEventHandler("onClientRender", getRootElement(), cc)
                        ccEnabled=true
                    end
                end
            end
        end
    end
end)

bindKey("brake_reverse","down",function()
    if ccEnabled then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
    end
end)

bindKey("handbrake","down",function()
    if ccEnabled then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
    end
end)

addEventHandler("onClientPlayerVehicleExit", getLocalPlayer(), function(veh, seat)
    if (seat==0) then
        if (ccEnabled) then
            removeEventHandler("onClientRender", getRootElement(), cc)
            ccEnabled=false
        end
    end
end)


function triggerVehicleSystem(sys)
    local veh = getPedOccupiedVehicle(source)
    if veh and getVehicleController(veh) == source then
        if sys == "engine" then
            if not getElementData(veh,"fuel") then setVehicleEngineState(veh, not getVehicleEngineState(veh))  return end
            if getElementData(veh,"fuel") > 0 then
                setVehicleEngineState(veh, not getVehicleEngineState(veh))
            else
                outputChatBox("&#1053;&#1077;&#1090; &#1073;&#1077;&#1085;&#1079;&#1080;&#1085;&#1072;!",source,200,0,0)
            end
        elseif sys == "lights" then
            if getVehicleOverrideLights( veh ) ~= 2 then
                setVehicleOverrideLights( veh, 2 )
            else
                setVehicleOverrideLights( veh, 1 )
            end
        elseif sys == "lock" then
            setVehicleLocked(veh,not isVehicleLocked(veh))
        end
    end
end
addEvent("triggerVehicleSystem",true)
addEventHandler("triggerVehicleSystem",root,triggerVehicleSystem)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 15:57


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

Nie widz? tutaj kodu od licznika, wska? gdzie jest.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 16:53


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kalizman, To co masz na g?rze

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 18:33


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

To kod od interakcji (moim okiem).

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 18:50


AkossPL







Wiek: 25
Na forum: 4220 dni
Posty: 140
Nick w MP: AkossPL

Piwa: 3

Respekt: 50

Kalizman, To jest to co jest na g?rze tylko nie da?em dx

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-09-20, 19:05


DomineQ

lua mejster






Wiek: 22
Na forum: 4101 dni
Posty: 309
Nick w MP: EZ3N

Piwa: 5189

Respekt: 85,8

Z kodu licznika wnioskuje, ?e pojazdy typu "Automobile" maj? tylko dost?p do tego licznika, lecz mog? si? myli?.

Spr?buj to:


limit = true

function getElementSpeed(element,unit)
    if (unit == nil) then unit = 0 end
    if (isElement(element)) then
        local x,y,z = getElementVelocity(element)
        if (unit=="mph" or unit==1 or unit =='1') then
            return (x^2 + y^2 + z^2) ^ 0.5 * 100
        else
            return (x^2 + y^2 + z^2) ^ 0.5 * 180
        end
    else
        return false
    end
end

function setElementSpeed(element, unit, speed)
    if (unit == nil) then unit = 0 end
    if (speed == nil) then speed = 0 end
    speed = tonumber(speed)
    local acSpeed = getElementSpeed(element, unit)
    if (acSpeed~=false) then 
        local diff = speed/acSpeed
        local x,y,z = getElementVelocity(element)
        setElementVelocity(element,x*diff,y*diff,z*diff)
        return true
    else
        return false
    end
end

function in_array(e, t)
    for _,v in pairs(t) do
        if (v==e) then return true end
    end
    return false
end

function round2(num, idp)
  return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end


function angle(vehicle)
    local vx,vy,vz = getElementVelocity(vehicle)
    local modV = math.sqrt(vx*vx + vy*vy)
    
    if not isVehicleOnGround(vehicle) then return 0,modV end
    
    local rx,ry,rz = getElementRotation(vehicle)
    local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz))
    
    local cosX = (sn*vx + cs*vy)/modV
    return math.deg(math.acos(cosX))*0.5, modV
end

lp = getLocalPlayer()
ccEnabled = false

myveh = false
targetSpeed = 1
multiplier = 1

function cc()
    if (not isElement(myveh)) then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
        return false
    end
    if getVehicleEngineState(myveh) == false then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
        return false
    end
    local x,y = angle(myveh)
    if (x<15) then
        local speed = getElementSpeed(myveh)
        local targetSpeedTmp = speed + multiplier
        if (targetSpeedTmp > targetSpeed) then
            targetSpeedTmp = targetSpeed
        end
        if (targetSpeedTmp > 3) then
            setElementSpeed(myveh, "k", targetSpeedTmp)
        end
    end
end

bindKey("j", "up", function()
    local veh = getPedOccupiedVehicle(lp)
    if (veh) then
        if (lp==getVehicleOccupant(veh)) then
            myveh = veh
            if (ccEnabled) then
                removeEventHandler("onClientRender", getRootElement(), cc)
                ccEnabled=false
            else
                targetSpeed = getElementSpeed(veh)
                if targetSpeed > 4 then
                    if (limit) then
                            targetSpeed = round2(targetSpeed)
                            addEventHandler("onClientRender", getRootElement(), cc)
                            ccEnabled=true  
                            end              
                    else
                        targetSpeed = round2(targetSpeed)
                        addEventHandler("onClientRender", getRootElement(), cc)
                        ccEnabled=true
                    end
                end
            end
        end
end)

bindKey("brake_reverse","down",function()
    if ccEnabled then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
    end
end)

bindKey("handbrake","down",function()
    if ccEnabled then
        removeEventHandler("onClientRender", getRootElement(), cc)
        ccEnabled=false
    end
end)

addEventHandler("onClientPlayerVehicleExit", getLocalPlayer(), function(veh, seat)
    if (seat==0) then
        if (ccEnabled) then
            removeEventHandler("onClientRender", getRootElement(), cc)
            ccEnabled=false
        end
    end
end)


Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: pokazuje :: się :: licznik :: jak :: rozpoczynam :: prace
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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