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: 4079 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.025500130)
local Blip createBlip(1361.59,-1658.41,13.3852)
local text createElement("text")
setElementData(text"name""Praca dorywcza\nGĂłrnik")
setElementPosition(text1361.59, -1658.4112.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(destinationMarkerthen
destroyElement(destinationMarker)
destinationMarker nil
end
if destBlip and isElement(destBlipthen
destroyElement(destBlip)
destBlip nil
end
end


function takeFurniture(hemdplr)
if he ~= localPlayer then return end
if not getPedOccupiedVehicle(hethen 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!"255255255)
        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"255255255)
    setElementData(he"zaladowany"true)
        showDestination()
        end50001)
    else
    outputChatBox("Nie moĹĽesz kilka razy ?‚adowa?‡ pojazdu"plr)
    end
end
end
addEventHandler("onClientMarkerHit"reloadMarkertakeFurniture)

function showDestination()
local rand math.random(1#unloadingPos)
local destMarker unloadingPos[rand]
destinationMarker createMarker(destMarker[1], destMarker[2], destMarker[3], "checkpoint"2.725500130)
destBlip createBlipAttachedTo(destinationMarker12)
addEventHandler("onClientMarkerHit"destinationMarkerunloadFurniture)
end

function unloadFurniture(hemd)
if he ~= localPlayer then return end
if not getPedOccupiedVehicle(hethen 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!"255255255)
    setElementData(he"zaladowany"false)
    setElementData(carr"pojazd_opis""Dostawca Gazu - Firma GAZOL")
    triggerServerEvent("givePlayerMoney"localPlayer65)
        outputChatBox("* Dostajesz 65.00 PLN za dostarczenie butli dla klientow."551460)
    endOfWork()
else
    outputChatBox("* Brak butli na pace, twoje auto nie jest zaladowane butlami!"25500)
end
end
end


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

addEventHandler("onClientVehicleExit"resourceRoot, function(plrseat)
    if seat == 0 then
        if plr == localPlayer then
            setElementData(plr"graczPraca"false)
            setElementData(plr"zaladowany"false)
            outputChatBox("* Zakonczyles/as Prace Dostawcy Gazu firmy GAZOL!"255255255)
            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!"25500)
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(482v[1], v[2], v[3]+0.3v[4], v[5], v[6])
    setElementData(Pojazd"pojazd_opis""Dostawca Gazu - Firma GAZOL")
    setVehicleColor (Pojazd025584 )
    setVehicleHandling(Pojazd,"maxVelocity",60)
    setElementData(Pojazd"pojazdy_przebieg"math.random(5001000))
    setElementData(Pojazd"pojazdy_paliwo"50)
end

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



function respawnVehicles()
    for i,v in ipairs(getElementsByType("vehicle"resourceRoot)) do
        if not getVehicleOccupant(vthen
            respawnVehicle(v)
            setElementFrozen(vtrue)
            setElementData(v"pojazd_opis""Dostawca Gazu - Firma GAZOL")
            setVehicleColor (v025584 )
            setVehicleHandling(v,"maxVelocity",100)
            setElementData(v"pojazdy_przebieg"math.random(5001000))
            setElementData(v"pojazd_paliwo"50)
            setVehicleEngineState(vfalse)
        end
    end
end
setTimer(respawnVehicles50000)
addEvent("checkCars"true)
addEventHandler("checkCars"resourceRootrespawnVehicles)


Postaw piwo autorowi tego posta
 

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


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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: 4079 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 == nilthen unit 0 end
    if (isElement(element)) then
        local x,y,getElementVelocity(element)
        if (unit=="mph" or unit==or unit =='1'then
            return (x^y^z^2) ^ 0.5 100
        else
            return (x^y^z^2) ^ 0.5 180
        end
    else
        return false
    end
end

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

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

function round2(numidp)
  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(vehiclethen 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.5modV
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,angle(myveh)
    if (x<15then
        local speed getElementSpeed(myveh)
        local targetSpeedTmp speed multiplier
        if (targetSpeedTmp targetSpeedthen
            targetSpeedTmp targetSpeed
        end
        if (targetSpeedTmp 3then
            setElementSpeed(myveh"k"targetSpeedTmp)
        end
    end
end

bindKey("j""up", function()
    local veh getPedOccupiedVehicle(lp)
    if (vehthen
        if (lp==getVehicleOccupant(veh)) then
            myveh veh
            if (ccEnabledthen
                removeEventHandler("onClientRender"getRootElement(), cc)
                ccEnabled=false
            else
                targetSpeed getElementSpeed(veh)
                if targetSpeed 4 then
                    if (limitthen
                        if in_array(getVehicleType(veh), allowedTypesthen
                            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(vehseat)
    if (seat==0then
        if (ccEnabledthen
            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(vehnot getVehicleEngineState(veh))  return end
            if getElementData(veh,"fuel") > 0 then
                setVehicleEngineState(vehnot getVehicleEngineState(veh))
            else
                outputChatBox("&#1053;&#1077;&#1090; &#1073;&#1077;&#1085;&#1079;&#1080;&#1085;&#1072;!",source,200,0,0)
            end
        elseif sys == "lights" then
            if getVehicleOverrideLightsveh ) ~= 2 then
                setVehicleOverrideLightsveh)
            else
                setVehicleOverrideLightsveh)
            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: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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: 4079 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: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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: 4079 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: 3960 dni
Posty: 309
Nick w MP: EZ3N

Piwa: 5186

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 == nilthen unit 0 end
    if (isElement(element)) then
        local x,y,getElementVelocity(element)
        if (unit=="mph" or unit==or unit =='1'then
            return (x^y^z^2) ^ 0.5 100
        else
            return (x^y^z^2) ^ 0.5 180
        end
    else
        return false
    end
end

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

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

function round2(numidp)
  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(vehiclethen 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.5modV
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,angle(myveh)
    if (x<15then
        local speed getElementSpeed(myveh)
        local targetSpeedTmp speed multiplier
        if (targetSpeedTmp targetSpeedthen
            targetSpeedTmp targetSpeed
        end
        if (targetSpeedTmp 3then
            setElementSpeed(myveh"k"targetSpeedTmp)
        end
    end
end

bindKey("j""up", function()
    local veh getPedOccupiedVehicle(lp)
    if (vehthen
        if (lp==getVehicleOccupant(veh)) then
            myveh veh
            if (ccEnabledthen
                removeEventHandler("onClientRender"getRootElement(), cc)
                ccEnabled=false
            else
                targetSpeed getElementSpeed(veh)
                if targetSpeed 4 then
                    if (limitthen
                            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(vehseat)
    if (seat==0then
        if (ccEnabledthen
            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