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

Wysłany: 2017-02-02, 17:17


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

przecho_s


--SQL LITE
handler = dbConnect("sqlite", "przechowywalnia.db")
dbExec(handler, "CREATE TABLE IF NOT EXISTS `przechowywalnia` (`id` INTEGER, `model` INTEGER, `wlasciciel` INTEGER)")

function onStartPrzechowywalnia()
--marker
local maly = createMarker( 1937.04,2344.98,9.9, "cylinder", 1, 255, 0, 0, 45)
--local maly2 = createMarker( 1937.04,2344.98,10.82-0.9, "cylinder", 1, 255, 0, 0, 45)
addEventHandler("onMarkerHit", maly, onPrzechowywalniaHit)
--addEventHandler("onMarkerHit", maly2, onPrzechowywalniaHit2)

duzy = createMarker( 1936.03,2338.09,9.5, "cylinder", 8, 0, 71, 255, 75)
--duzy2 = createMarker( 1937.04,2344.98,10.82-0.8, "cylinder", 9.5, 0, 71, 255, 75)
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartPrzechowywalnia)

function onPrzechowywalniaHit(hitElement)
    if getElementType(hitElement) == "player" then
    local acc = getPlayerAccount(hitElement)
        if acc then
        local veh = getPedOccupiedVehicle(hitElement)
            if not veh then
            local login = getAccountName(acc)
            local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE wlasciciel='"..login.."'")
            local result, rows = dbPoll (query, -1)
            triggerClientEvent(hitElement, "showPrzechowywalniaGUI", root, result or {})
            end
        end
    end
end


--[[function onPrzechowywalniaHit2(hitElement)
    if getElementType(hitElement) == "player" then
    local acc = getPlayerAccount(hitElement)
        if acc then
        local veh = getPedOccupiedVehicle(hitElement)
            if not veh then
            local login = getAccountName(acc)
            local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE wlasciciel='"..login.."'")
            local result, rows = dbPoll (query, -1)
            triggerClientEvent(hitElement, "showPrzechowywalniaGUI2", root, result or {})
            end
        end
    end
end]]--


addEvent("onPrzywrocPojazdZPrzechowywalni", true)
addEventHandler("onPrzywrocPojazdZPrzechowywalni", getRootElement(),
function(id)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE id='"..id.."'")
local result, rows = dbPoll (query, -1)
local hajs = getPlayerMoney(source)   
koszt = 200
    if #result > 0 then
    dbExec(handler, "DELETE FROM przechowywalnia WHERE id='"..id.."'")
    
    local x, y, z = getElementPosition(duzy)
    local zrob = exports.salon:stworzPojazd(id, x, y, z)
        if zrob then
        takePlayerMoney ( source, tonumber(koszt) )
        outputChatBox("Z twojego konta pobrano "..koszt.."$ za przechowywanie pojazdu, ?yczymy mi?ej jazdy!", source)
        warpPedIntoVehicle(source, zrob)
        setVehiclePlateText( zrob, id )
        else
        outputChatBox("Podane auto nie istnieje.", source, 255, 255, 255, true)
        end
    end
end)

--[[addEvent("onPrzywrocPojazdZPrzechowywalni2", true)
addEventHandler("onPrzywrocPojazdZPrzechowywalni2", getRootElement(),
function(id)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE id='"..id.."'")
local result, rows = dbPoll (query, -1)
local hajs = getPlayerMoney(source)   
koszt = 200
    if #result > 0 then
    dbExec(handler, "DELETE FROM przechowywalnia WHERE id='"..id.."'")
    
    local x, y, z = getElementPosition(duzy2)
    local zrob = exports.YNLSystemPojazdow:stworzPojazd(id, x, y, z)
        if zrob then
        takePlayerMoney ( source, tonumber(koszt) )
        outputChatBox("Z twojego konta pobrano "..koszt.."$ za przechowywanie pojazdu, ?yczymy mi?ej jazdy!", source)
        warpPedIntoVehicle(source, zrob)
        setVehiclePlateText( zrob, id )
        else
        outputChatBox("Podane auto nie istnieje.", source, 255, 255, 255, true)
        end
    end
end)]]--


function czyPojazdJestWPrzechowywalni(id)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE id='"..id.."'")
local result, rows = dbPoll (query, -1)
    if #result > 0 then
    return true
    else
    return false
    end
end
--##
timery = {}

function onPrzechoVehExit(player, seat)
    if isElementWithinMarker(source, duzy) then
    if seat == 0 then
    local id = getElementData(source, "car_id")
        if id then
            timery[id] = setTimer(oddajPojazdDoPrzechowywalni, 5000, 1, source, player, id, true)
            end
        end
    end
end
addEventHandler("onVehicleExit", getRootElement(), onPrzechoVehExit)

--[[function onPrzechoVehExit(player, seat)
    if isElementWithinMarker(source, duzy2) then
    if seat == 0 then
    local id = getElementData(source, "car_id")
        if id then
            timery[id] = setTimer(oddajPojazdDoPrzechowywalni, 5000, 1, source, player, id, true)
            end
        end
    end
end
addEventHandler("onVehicleExit", getRootElement(), onPrzechoVehExit)]]--

function oddajPojazdDoPrzechowywalni(veh, player, id, bool)
    if isElement(veh) then
    local acc = getPlayerAccount(player)
        if acc or source then
        local wlasciciel = getElementData(veh, "car_owner")
        local model = getElementModel(veh)
        dbExec(handler, "INSERT INTO przechowywalnia VALUES('"..id.."', '"..model.."', '"..wlasciciel.."')")
        
        if isElement(player) then
            if bool then
            outputChatBox("Tw?j pojazd "..getVehicleName(veh).." zosta? umieszczony w przechowywalni.", player, 255, 255, 255, true)
            else
            outputChatBox("Odda?e? pojazd "..getVehicleName(veh).." do przechowywalni.", player, 255, 255, 255, true)
            end
        end

        destroyElement(veh)
        end
    end
end

function komendaDlaAdmina(player)
local acc = getPlayerAccount(player)
    if acc then
    local login = getAccountName(acc)
    if ( hasObjectPermissionTo ( player, "function.kickPlayer", true ) ) then
        local veh = getPedOccupiedVehicle(player)
            if veh then
            local id = getElementData(veh, "car_id")
                if id then
                oddajPojazdDoPrzechowywalni(veh, player, id)
                end
            end
        end
    end
end
addCommandHandler("oddajauto", komendaDlaAdmina)



function notifyAboutExplosion(player)
local acc = getElementData(source, "car_owner")
local id = getElementData(source, "car_id")
    if acc then
    if id then
    oddajPojazdDoPrzechowywalni(source, player, id)
    outputChatBox("Tw?j pojazd wybuch?, znajdziesz go w przechowywalni.", source)
end
end
end
addEventHandler("onVehicleExplode", getRootElement(), notifyAboutExplosion)


function onPrzechoVehEnter(player, seat)
    if seat == 0 then
    local id = getElementData(source, "car_id")
        if id then
            if isTimer(timery[id]) then
            killTimer(timery[id])
            end
        end
    end
end
addEventHandler("onVehicleEnter", getRootElement(), onPrzechoVehEnter)


DB3


prosz? o pomoc

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 17:26


R3fr3Sh







Wiek: 28
Na forum: 4941 dni
Posty: 70

Piwa: 60

Respekt: 150
Respekt: 150Respekt: 150

Czy zas?b o nazwie salon dzia?a? Czy posiada on wyeksportowan? funkcj? stworzPojazd? Czy id to warto?? numeryczna Je?li tak to jeszcze mo?esz spr?bowa? tego.


exports["salon"]:stworzPojazd(id, x, y, z)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 18:12


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

nie posiadam stworzPojazd jak to napisa? jak mozna jaki? przyk?ad

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 18:25


_Haze

Peace Yo!






Wiek: 25
Na forum: 4325 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

polaczkos, musisz mie? w??czony skrypt na tworzenie pojazd?w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 18:29


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

ale jak go zrobi? ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 18:54


_Haze

Peace Yo!






Wiek: 25
Na forum: 4325 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

polaczkos, musisz wlaczyc gotowy skrypt. Raczej sam nie napiszesz systemu pojazdow bez znajomosci lua. Podpinanie pod inny skrypt tez nie wchodzi w gre bo tu jest podana funkcja.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 19:40


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

prosz? o pomoc

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-02, 21:50


mixLoLmix2

Programista






Wiek: 35
Na forum: 4254 dni
Posty: 454
Nick w MP: TomeQmix

Piwa: 1915

Respekt: 47,3


addEvent("salon:stworzpojazd", true
addEventHandler("salon:stworzpojazd", root, function(id)
    local spawn=exports["salon"]:stworzPojazd(id, x, y, z) -- Tu Wpisz Kordy Gdzie ma sie respic Pojazd Np. (id, 100, 200, 300, 0, 0, 150)
    if spawn then
    addEventHandler("onClientRender",root,render1)  
end
end)


Podpis
Zajmuję się pisaniem zaawansowanych skryptów lua na zamówienie za bardzo niską cene.
Oraz pomoc przy serwerze mta/forum i tym podobnych.
Discord: TomeQmix#7106
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 13:18


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

to mam zamieni? zamiast tego

       local zrob = exports.salon:stworzPojazd(id, x, y, z)
        if zrob then
        takePlayerMoney ( source, tonumber(koszt) )
        outputChatBox("Z twojego konta pobrano "..koszt.."$ za przechowywanie pojazdu, ?yczymy mi?ej jazdy!", source)
        warpPedIntoVehicle(source, zrob)
        setVehiclePlateText( zrob, id )
        else
        outputChatBox("Podane auto nie istnieje.", source, 255, 255, 255, true)
        end


czy jak ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 14:44


amited







Wiek: 26
Na forum: 3855 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

mixLoLmix2, ... samo "stworzPojazd" go nie stworzy bo to jest osobna funkcja...
polaczkos, Musisz napisac sw?j system pojazd?w: zapis, wczyt itp. i wtedy tam dajesz funkcj? kt?ra tworzy pojazd.

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 14:48


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

mam sw?j w?asny system pojazd?w prywatnych

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 14:49


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3950 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2322

Respekt: 240
Respekt: 240Respekt: 240

polaczkos, poka? plik meta.xml skryptu z funkcj? stworzPojazd

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 14:50


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

To jest zapis pojazd?w


handler = dbConnect("sqlite", "pojazdy.db") 

--pojazdy
dbExec(handler, "CREATE TABLE IF NOT EXISTS pojazdy (id INTEGER PRIMARY KEY AUTOINCREMENT, wlasciciel TEXT, model INTEGER, x FLOAT, y FLOAT, z FLOAT, rot FLOAT,  r1 INTEGER, g1 INTEGER, b1 INTEGER, r2 INTEGER, g2 INTEGER, b2 INTEGER, r3 INTEGER, g3 INTEGER, b3 INTEGER, r4 INTEGER, g4 INTEGER, b4 INTEGER, przebieg FLOAT, paliwo FLOAT)")
dbExec(handler, "CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on pojazdy(id)")

--tuning
dbExec(handler, "CREATE TABLE IF NOT EXISTS tuning (id INTEGER, t0 INTEGER, t1 INTEGER, t2 INTEGER, t3 INTEGER, t4 INTEGER, t5 INTEGER, t6 INTEGER, t7 INTEGER, t8 INTEGER, t9 INTEGER, t10 INTEGER, t11 INTEGER, t12 INTEGER, t13 INTEGER, t14 INTEGER, t15 INTEGER, t16 INTEGER, paintjob INTEGER, hr INTEGER, hg INTEGER, hb INTEGER)")
dbExec(handler, "CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on tuning(id)")


function onStartLoadVehicles()
local query = dbQuery(handler, "SELECT * FROM pojazdy")
local result, num_rows, errormsg = dbPoll (query, -1)
    for i,v in pairs(result) do
    local veh = createVehicle(v["model"], v["x"], v["y"], v["z"])
    setElementRotation(veh, 0, 0, v["rot"])
    setVehicleColor(veh, v["ca"], v["cb"], v["cc"])
    ustawDanePojazdu(veh, v["id"], v["wlasciciel"])
    setVehiclePlateText(veh, "SA "..v["id"])
    
    --ustawiam paliwo i przebieg
    setElementData(veh, "pojazd_paliwo", v["paliwo"] or 50)
    setElementData(veh, "pojazd_przebieg", v["przebieg"] or 0)
    --<< na koncu -->>
    local query = dbQuery(handler, "SELECT * FROM tuning WHERE id='"..v["id"].."'")
    local result, num_rows, errormsg = dbPoll (query, -1)
    setVehiclePaintjob(veh, result[1].paintjob)
    setVehicleHeadLightColor(veh, result[1].hr, result[1].hg, result[1].hb)
        for i,v in pairs(result) do
            for ii, vv in pairs(v) do
                if (ii ~= "id" and ii ~= "paintjob" and ii ~= "hr" and ii ~= "hg" and ii ~= "hb") then
                local vv = tonumber(vv)
                    if vv ~= 0 then
                    addVehicleUpgrade(veh, vv)
                    end
                end
            end
        end
    end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartLoadVehicles)

function ustawDanePojazdu(veh, id, wlasciciel) --id = INT, wlasciciel = STRING
setElementData(veh, "car_id", id)
setElementData(veh, "car_owner", wlasciciel)
end

function onVehicleStartEnter(player, seat, jacked)
  if seat == 0 then
  local car_owner = getElementData(source, "car_owner")
    if car_owner then
    local account = getPlayerAccount(player)
        if account then
        local name = getAccountName(account)
            if car_owner == name then
            --mamy prawo wejscia do auta
            prawo_ = true
            end
        end
    
        if prawo_ then
        --wchodzim
        prawo_ = false
        else
        --sio
        cancelEvent()
        end
    end
  end
end
addEventHandler ("onVehicleStartEnter", resourceRoot, onVehicleStartEnter)

--<<ZAPIS POJAZDU-->>

function zapiszPojazdy()
    for i,v in pairs(getElementsByType("vehicle")) do
    local id = getElementData(v, "car_id")
        if id then
        local owner = getElementData(v, "car_owner")
        local x, y, z = getElementPosition(v)
        local _, _, rot = getElementRotation(v)
        local r1,g1,b1,r2,g2,b2,r3,g3,b3,r4,g4,b4 = getVehicleColor(v,true)
        --local paliwo = getElementData(v, "pojazd_paliwo")
        --local przebieg = getElementData(v, "pojazd_przebieg")
        dbExec(handler, "UPDATE pojazdy SET x='"..x.."', y='"..y.."', z='"..z.."', rot='"..rot.."', r1='"..r1.."', g1='"..g1.."', b1='"..b1.."', r2='"..r2.."', g2='"..g2.."', b2='"..b2.."', r3='"..r3.."', g3='"..g3.."', b4='"..b3.."', r4='"..r4.."', g4='"..g4.."', b4='"..b4.."' WHERE id='"..id.."'")
        
        local paintjob = getVehiclePaintjob(v)
        local r, g, b = getVehicleHeadLightColor(v)
        sav = {}
            for i=0, 16 do
            local upgrade = getVehicleUpgradeOnSlot(v, i)
            sav[i] = upgrade or 0
            end
        dbExec(handler, "UPDATE tuning SET t0='"..sav[0].."', t1='"..sav[1].."', t2='"..sav[2].."', t3='"..sav[3].."', t4='"..sav[4].."', t5='"..sav[5].."', t6='"..sav[6].."', t7='"..sav[7].."', t8='"..sav[8].."', t9='"..sav[9].."', t10='"..sav[10].."', t11='"..sav[11].."', t12='"..sav[12].."', t13='"..sav[13].."', t14='"..sav[14].."', t15='"..sav[15].."', t16='"..sav[16].."', paintjob='"..paintjob.."', hr='"..r.."', hg='"..g.."', hb='"..b.."' WHERE id="..id.."")
        sav = nil
        end
    end
end
setTimer(zapiszPojazdy, 900000, 0)

function zapiszKomenda(player)
local acc = getAccountName (getPlayerAccount(player))
    if isObjectInACLGroup ("user."..acc, aclGetGroup ("Admin")) then
    zapiszPojazdy()
    outputChatBox("** Zapisano pojazdy.", player, 255, 255, 255, true)
    end
end
addCommandHandler("zp", zapiszKomenda)

-- mapa, f11
addEvent("pobierzPojazdyGracza", true)
addEventHandler("pobierzPojazdyGracza", getRootElement(),
function()
local account = getPlayerAccount(source)
    if account then
    local name = getAccountName(account)
    local vehs = getVehiclesByOwner(name)
    triggerClientEvent(source, "zwrocPojazdyGracza", root, vehs)
    end
end)

--
--zwraca pojazd o danym ID
function getVehicleByID(poszukiwane_id)
    for i,v in pairs(getElementsByType("vehicle")) do
    local id = getElementData(v, "car_id")
        if id then
        local id = tonumber(id)
        local poszukiwane_id = tonumber(poszukiwane_id)
            if id == poszukiwane_id then
            return v
            end
        end
    end
    return false
end

--zwraca pojazdy ktore posiada dany login
function getVehiclesByOwner(szukany)
tab = {}
    for i,v in pairs(getElementsByType("vehicle")) do
    local owner = getElementData(v, "car_owner")
        if owner then
            if owner == szukany then
            table.insert(tab, v)
            end
        end
    end
    return tab
end

--zwraca liczbe pojazdow jaka ma dany login
function getYourVehicleCount(login)
local vehs = getVehiclesByOwner(login)
return #vehs
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 14:51


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3950 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2322

Respekt: 240
Respekt: 240Respekt: 240

polaczkos, ale ja chce plik meta.xml zasobu salon

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 15:50


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

Tu masz mete


<meta>
    <info author="polaczkos"/>
    <script src="salon_c.lua" type="client"/>
    <script src="salon_s.lua" type="server"/>
    <script src="sprzedaz_s.lua" type="server"/>
    <script src="sprzedaz_c.lua" type="client"/>
    <script src="zapis_aut_s.lua" type="server"/>
    <script src="mapa_c.lua" type="client"/>  
    <script src="salon_r.lua" type="server"/>  
    <script src="salon_a.lua" type="server"/> 
    <script src="salon_l.lua" type="server"/>  
    <script src="salon_mot.lua" type="server"/>  
    <script src="stworzpojazd.lua" type="client"/>  
</meta>


Ostatnio zmieniony przez polaczkos 2017-02-04, 16:32, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Tagi: wyciaganie :: przecho
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