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

Wysłany: 2016-06-12, 10:57


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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

Witam.

Mam pytanie. Co dorobi? w skrypcie (tzn pracy dorywczej) ?eby dla danej grupy ACL dostawa?a wi?cej?
Za???my, i? ?eby grupa ACL 'Premium' dostawa?a wi?cej za dojechanie do punktu (np. praca autobus?w) np. 19 PLN, a zwyk?y gracz 9 PLN. Moje pytanie skierowa?em do Was bo sie sam zastanawiam jak to zrobi?.
Dam tutaj przyk?adowy kod np. niech b?dzie to praca bus?w z YWG (czy tam YNL).

Oto kod strony clienta:

local districtsBus = {
    {-1735.86935.6024.74},
    {-1856.70934.1535.02},
    {-1976.56929.9445.30},
    {-2010.05889.2145.30},
    {-2007.90687.8345.49},
    {-2009.29164.4127.73},
    {-2008.72, -47.6735.36},
    {-2024.01, -311.1435.52},
    {-2181.06, -314.1535.43},
    {-2205.83, -200.0935.47},
    {-2338.28, -188.6535.36},
    {-2371.03, -75.4835.44},
    {-2017.15, -72.0435.36},
    {-2005.1248.9831.51},
    {-1991.66138.8027.73},
    {-2001.05313.7235.21},
    {-2000.35594.8735.22},
    {-2000.49844.6145.49},
    {-1902.01842.0935.21},
    {-1897.27916.3735.21},
    {-1795.58921.1724.93},
    {-1766.85950.4624.93},

}

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("#919191Zako?czy?e?/a? prac?.",255,255,255,true)
    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"400255)
    
    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("#919191Rozpocz??e?/a? prac?.",255,255,255,true)
    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("#919191Zako?czy?e?/a? prac?.",255,255,255,true)
        end
    end
end)




...a oto kod strony serwera:

createBlip(-1755.05951.7323.74522255,0,0,255,0,400)
local m1 createMarker(-1755.05951.7323.74"cylinder"4.025500)
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("error"el)
        return
    end
    
    if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(elthen return end
    
    local x,y,getElementPosition(el)
    local bus createVehicle(437x,y,z,0.0360.0269.9)
    
    setElementData(bus"zrespilGracz"el)
    setElementData(bus"pojazd_paliwo"50)
    setElementData(bus"pojazd_przebieg"1)
    
    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)


Za ch?tn? pomoc stawiam zimne piwo oraz respekt. :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-12, 11:07


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Premium")) then -- jezeli gracz jest w ACL Premium
    givePlayerMoney(player,19)
else -- jezeli gracz nie jest w ACL Premium
    givePlayerMoney(player,9)
end


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Tagi: więcej :: pieniędzy :: dla :: grupy :: acl :: premium
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Więcej pieniędzy dla grupy ACL 'Premium' 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