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

Wysłany: 2016-10-22, 13:16


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

Witam chcia?bym si? dowiedzie? jak zrobi? ?eby gracz kt?ry ma np 100rp m?g? pracowa? na busach a gracz kt?ry ma mniej nie m?g?.

Przyk?ad pracy:
local m1 createMarker(1799.74,-1934.21,13.49-0.9"cylinder",1,0,255,0)
vehs = {}


function removePreviousVehicles(plr)
    for i,v in ipairs(getElementsByType("vehicle"resourceRoot)) do
        local sby getElementData(v"zrespilGracz")
        if sby and sby == plr and getPedOccupiedVehicle(plr) ~= v then
            destroyElement(v)
        end
    end
end

addEventHandler("onMarkerHit"m1, function(elmd)
    if getElementData(el"zrespilGracz"then
        outputChatBox("praca w trakcie poprawek"el)
        return
    end
    
    if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(elthen return end
    
    local x,y,getElementPosition(el)
    local bus createVehicle(4311795.26,-1930.91,13.49,359.5,360.0,0.5)
    
    setElementData(bus"zrespilGracz"el)
    setElementData(bus"vehicle:fuel"100)
    setElementData(bus"vehicle:mileage"69000)
    setElementData(bus"vehicle:desc""Praca Dorywcza\nKierowca Autobusu\nCel:Gie?da")    
    
    warpPedIntoVehicle(elbus)
    removePreviousVehicles(el)
    triggerClientEvent(el"STARTJobBus"resourceRootbus)

    vehs[el] = bus
end)

addEvent("STOPJobBus"true)
addEventHandler("STOPJobBus"resourceRoot, function()
    local pojazd getPedOccupiedVehicle(localPlayer)
    if pojazd then
        destroyElement(pojazd)
    end
end)

addEvent("destroyVeh"true)
addEventHandler("destroyVeh"getRootElement(),
function()
     if vehs[sourcethen
          if isElement(vehs[source]) then destroyElement(vehs[source]) end
     end
end)

addEvent("STOPJobBus"true)
addEventHandler("STOPJobBus"resourceRoot, function()
    local pojazd getPedOccupiedVehicle(localPlayer)
    if pojazd then
        destroyElement(pojazd)
    end
end)

addEvent("destroyVeh"true)
addEventHandler("destroyVeh"getRootElement(),
function()
     if vehs[sourcethen
          if isElement(vehs[source]) then destroyElement(vehs[source]) end
     end
end)

addEvent("onPlayerQuit"true)
addEventHandler "onPlayerQuit"getRootElement(), function()
     if vehs[sourcethen
          if isElement(vehs[source]) then destroyElement(vehs[source]) end
    end
end)

local t=createElement("text")
setElementData(t"scale"1.2)
setElementData(t,"name","Praca Kierowcy Autobusu\n10PLN za przystanek!")
setElementPosition(t1799.74,-1934.21,13.49)

createBlip 1799.74,-1934.21,13.49,19,2,0,255,0255,099999)



local districtsBus = {
    {1817.91,-1917.31,13.38},
    {1916.32,-1936.04,13.38},
    {1985.46,-1936.26,13.38},
    {2085.96,-1915.64,13.38},
    {2085.63,-1852.60,13.38},
    {2085.70,-1806.89,13.38},
    {2114.49,-1693.73,13.38},
    {2116.98,-1581.85,25.96},
    {2116.56,-1442.89,23.83},
    {2086.14,-1380.24,23.83},
    {2076.03,-1281.49,23.83},
    {2075.67,-1172.02,23.66},
    {2019.02,-1131.67,24.79},
    {1927.82,-1131.63,25.01},
    {1862.59,-1157.71,23.69},
    {1795.70,-1170.01,23.65},
    {1607.47,-1156.67,23.91},
    {1514.15,-1156.63,23.91},
    {1450.54,-1265.07,13.38},
    {1450.02,-1418.88,13.38},
    {1425.29,-1573.70,13.36},
    {1425.43,-1671.88,13.38},
    {1429.87,-1736.51,13.38},
    {1629.79,-1736.56,13.38},
    {1781.05,-1736.39,13.38},
    {1817.39,-1788.47,13.38},
    {1817.38,-1870.58,13.41},

}

local jobTarget
local jobMarker
local jobVehicle
local maxTarget #districtsBus

function finishJob()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    if jobTarget and isElement(jobTargetthen
        destroyElement(jobTarget)
        jobTarget nil
        jobTarget 0
        
    end
    
triggerServerEvent("destroyVeh"localPlayer)

end


function busDriver(elmd)
    if el ~= localPlayer or not md then return end
    if jobTarget maxTarget and getPedOccupiedVehicle(elthen return end
    if jobTarget == maxTarget and not getPedOccupiedVehicle(elthen return end
    
    if jobTarget == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        outputChatBox("Rozpocz??e? Prace Kierowyc Autobusu.Zarobki 10 PLN Za Przystanek!")
    else
        showMarker()
        playSoundFrontEnd(12)
        triggerServerEvent("givePlayerMoney"localPlayer50)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    jobTarget jobTarget 1
    jobMarker createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint"4,128,255,0)
    
    if districtsBus[jobTarget+1then
        ile districtsBus[jobTarget+1]
        setMarkerTarget(jobMarkerile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit"jobMarkerbusDriver)
end

addEvent("STARTJobBus"true)
addEventHandler("STARTJobBus"resourceRoot, function(veh)
    outputChatBox("Rozpocz??e? Prace Kierowyc Autobusu.Zarobki 10 PLN Za Przystanek!")
    jobVehicle veh
    jobTarget 0
    showMarker()
end)

addEventHandler("onClientResourceStop"resourceRoot, function()
    if jobVehicle and getElementData(localPlayer"gracz_praca"then
        setElementData(localPlayer"gracz_praca"false)
    end
end)

addEventHandler("onClientVehicleExit"resourceRoot, function(plrseat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            outputChatBox("Gratuluje Zako?czy?e? Prace Kierowcy Autobusu!")
        end
    end
end)


Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-22, 13:45


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
Sprawdzasz elementDate


Więcej informacji znajdziesz w Wikipedii MTA:

getElementData


Potem walisz ifa np


local rp getElementData(jakisgracz,"rp")
if rp => 100 then
--reszta kodu



Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-10-22, 14:09


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

o to mi chodzi?o dzi?ki za pomoc

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Tagi: ilośc :: rep
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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