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

Wysłany: 2020-01-18, 11:56


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Witam posiadam stacje z westrpg i chcia? bym zeby p?aci?o si? w interiorze , zrobi?em wszystko okej ale gdy wchodze do int. zeby zap?acic nie ma tam cuboidu i zakancza tankowanie :( (Chce zrobic jak bylo na west rpg).
Skrypt s.lua
--[[
Skrypt zostawykonany przez:
   -Asper (nezymr69@gmail.com).

Na potrzeby serwera:
   -WestRPG (2018).

Jedyne i wy??czone prawo do u?ywania kodu ma serwer WestRPG oraz autor skryptu. (Asper)
]]

local markers = {
    ['fortcarson'] = {
        markers = {
            {73.451172.1818.66,'Benzyna'},
            {75.331172.0918.66,'Benzyna'},
            {75.141165.0018.66,'Benzyna'},
            {73.251165.0818.66,'Benzyna'},
        },
        cs = {76.621168.6918.6628},
        csTo = {76.621168.6918.6616},
    },
}

local tick getTickCount()

addEventHandler('onMarkerHit'resourceRoot, function(hitdim)
    if not hit or hit and not isElement(hit) or hit and isElement(hit) and getElementType(hit) ~= 'player' or hit and isElement(hit) and getElementType(hit) == 'player' and isPedInVehicle(hit) or not dim then return end

    if (getTickCount()-tick) < 500 then return end -- server sideladuje sie wczesniej niz client side

    local type getElementData(source'type') or 'Benzyna'
    if not getElementData(hit'user:line'then
        if getElementData(hit'tank:vehicle'then
            triggerClientEvent(hit'onClientAddNotification'hit'Najpierw zap?a? za poprzednie zam?wienie.''error')
            return
        end

        local x,y,getElementPosition(source)
        exports['3dline']:create3DLine(hitxyz)

        giveWeapon(hit41)
        setPedWeaponSlot(hit4)
        triggerClientEvent(hit'start:weapon'resourceRoottype)
    else
        exports['3dline']:destroy3DLine(hit)
        triggerClientEvent(hit'stop:weapon'resourceRoot)
        takeWeapon(hit,41)

        if not getElementData(hit'player:admin'then
            takeWeapon(hit32)
        end
    end
end)

addEventHandler('onPlayerWeaponSwitch'root, function(prevcurr)
    if getElementData(source'user:line') and prev == 23 then
        setPedWeaponSlot(source4)
    end
end)

addEventHandler('onColShapeLeave'resourceRoot, function(hit)
    if not hit or hit and not isElement(hit) or hit and isElement(hit) and getElementType(hit) ~= 'player' then return end
    
    if getElementData(source'cs')  and getElementData(hit'tank:vehicle'then
        setElementData(hit'tank:vehicle'false)
        triggerClientEvent(hit'onClientAddNotification'hit'Twoje zam?wienie zosta?o anulowane.''info')
        return
    end

    if getElementData(hit'user:line'then
        exports['3dline']:destroy3DLine(hit)
        triggerClientEvent(hit'stop:weapon'resourceRoot)

        if not getElementData(hit'player:admin'then
            takeWeapon(hit32)
        end
    end
end)

addEvent('tank:vehicle'true)
addEventHandler('tank:vehicle'resourceRoot, function(vehiclecostfueltype)
    if not vehicle or vehicle and not isElement(vehiclethen
        setElementData(client'tank:vehicle'false)
        triggerClientEvent(client'onClientAddNotification'client'Twoje zam?wienie jest ju? przedawnione.''info')
    end

    local text 'paliwa'
    if type == 'LPG' then
        local gas getElementData(vehicle'vehicle:gas') or 0
        setElementData(vehicle'vehicle:gas'gas fuel)
        text 'gazu'
    else
        local fuel_ getElementData(vehicle'vehicle:fuel') or 0
        setElementData(vehicle'vehicle:fuel'fuel_ fuel)
    end

    takePlayerMoney(clientcost)
    exports['pystories-db']:dbSet('update pystories_users set money=? where login=? limit 1'getPlayerMoney(client), getPlayerName(client))
    triggerClientEvent(client'onClientAddNotification'client'Zap?aci?e? '..math.floor(cost)..' PLN \nza dolanie '..math.floor(fuel)..'L '..text..' do pojazdu '..getVehicleName(vehicle), 'success')
    setElementData(client'tank:vehicle'false)
end)

function getMarkerColorFromType(type)
    local r,g,b,255,255,255,'pb-95'
    if type == 'Benzyna' then
        r,g,b,0,0,255,'pb-95'
    elseif type == 'Diesel' then
        r,g,b,255,0,0,'on'
    elseif type == 'LPG' then
        r,g,b,0,255,0,'lpg'
    end

    return r,g,b,t
end

addEventHandler('onResourceStart'resourceRoot, function()
    for k,v in pairs(markers) do
        if #v['markers'] > 0 then
            for 1,#v['markers'] do
                local r,g,b,getMarkerColorFromType(v['markers'][i][4])
                local marker createMarker(v['markers'][i][1], v['markers'][i][2], v['markers'][i][3]-0.97'cylinder'1.100080)
                setElementData(marker'marker:icon't)
                setElementData(marker'type'v['markers'][i][4])
            end

            local cs createColSphere(v['cs'][1], v['cs'][2], v['cs'][3], v['cs'][4])
            setElementData(cs'cs'true)

            createColSphere(v['csTo'][1], v['csTo'][2], v['csTo'][3], v['csTo'][4])

            local blip createBlip(v['markers'][1][1], v['markers'][1][2], v['markers'][1][3], 40)
            setBlipVisibleDistance(blip500)
        end
    end
end)

local czas getTickCount()

isBike = {
    [509]=true, --Bike
    [481]=true, --BMX
    [510]=true, --Mountain bike
}

function odejmijPaliwo(pojazd)
    if getTickCount() - czas 150 then
        czas getTickCount()
        local paliwo getElementData(pojazd"vehicle:fuel") or 0
        local vx,vy,vz getElementVelocity(pojazd)
        local spd = ((vx^2+vy^2+vz^2)^(0.5)/150)
        if spd 0 then
            paliwo paliwo-spd*2
            setElementData(pojazd"vehicle:fuel"paliwo)
        end
    end
end

addEventHandler("onClientRender"root, function()
    local pojazd getPedOccupiedVehicle(localPlayer)
    if not pojazd then return end
    if isBike[getElementModel(pojazd)] then return end
    if not getVehicleEngineState(pojazdthen return end
    if getVehicleController(pojazd) ~= localPlayer then return end
    odejmijPaliwo(pojazd)
end)


function zgasSilnik()
    for i,v in ipairs(getElementsByType("vehicle")) do
    local data getElementData(v"vehicle:fuel")
        if data then
        if tonumber(data) < 0 then
            setVehicleEngineState(vfalse)
        end
end
    end
end
setTimer(zgasSilnik10000) 

function koniecpaliwa()
vehicle getPedOccupiedVehicle(localPlayer)
    if vehicle and (not getElementData(vehicle,"vehicle:fuel") == false ) and getElementData(vehicle,"vehicle:fuel") <= 0 then
        setElementData(vehicle,"vehicle:fuel",0)
        setElementData(vehicle,"koniecpaliwa",true)
        setVehicleEngineState(vehicle,false)
    end
end
addEventHandler("onClientRender",root,koniecpaliwa)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-18, 12:49


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

To normalne, ?e si? ko?czy bo masz event onColShapeLeave. Mo?esz to przerobi?, ?eby to gracz anulowa? zakup pod jakim? przyciskiem, a jak oddali si? od okre?lon? odleg?o?? to wtedy te? anulujesz.
Je?li cuboid jest du?y, to mo?esz spr?bowa? przenosi? gracza do innego dimensionu (albo interioru, wtedy znikn? obiekty chyba) i tam obudowa? przestrze? nie wychodz?c poza granice cuboidu.

Postaw piwo autorowi tego posta
 

 
Tagi: stacja
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Stacja Odpowiedz do tematu

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