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

Wysłany: 2015-07-08, 20:51


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Witam, chcia?bym zrobi? skrypt na teleportacje poprzez ID pojazdu.
Stawiam :piwo:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 20:54


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

No to robisz :

addCommandHandler("teleport", function(plrcmdparam)
if tonumber(paramthen
for _v in ipairs(getElementsByType("vehicle)) do
if param == getElementData(v, "car:id") then
local x, y, z = getElementPosition(plr)
setElementPosition(v, x, y, z + 5)
warpPedIntoVehicle(plr, v)
end
end
end)


Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 21:16


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

Iksdekowski, jeden cudzys??w zjda?e?.
addCommandHandler("teleport", function(plrcmdparam)
if tonumber(paramthen
for _v in ipairs(getElementsByType("vehicle")) do
if param == getElementData(v"car:id"then
local xygetElementPosition(plr)
setElementPosition(vxy5)
warpPedIntoVehicle(plrv)
end
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 21:19


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Oj racja, sorry

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 21:28


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

trochu nie dzia?a.
Mam pytanie do tego co mi dali?cie.
To ma teleportowa? pojazd do mnie
np. pojazd ma ID 1, i jest np w sf to piszemy tpc 1 i pojazd tepa si? do mnie.
Za pomoc daje :piwo: :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 21:29


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

Podaj elementDat? jak? nadajesz na pojazd jako jego ID.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 21:48


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

po stronie serwera :

addEvent("kupPojazdSalon"true)
addEventHandler("kupPojazdSalon"getRootElement(),
function(id)
local cena salonowePojazdy[id]
    if cena then
        if getPlayerMoney(source) >= cena then
        local account getPlayerAccount(source)
          if account then
          local wlasciciel getAccountName(account)
            if >= getYourVehicleCount(wlascicielthen
            takePlayerMoney(sourcecena)
            triggerClientEvent(source"potwierdzKupnoPojazduPrywatnego"root)
            fadeCamera(sourcefalse)
                setTimer(function(source)
                local xyzrot = -1987.46276.1834.86270
                local veh createVehicle(idxyz)
                setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                setElementData(veh"pojazd_przebieg"0)
                local rggetVehicleColor(vehtrue)
                fadeCamera(sourcetrue)
                --<<-->>
                local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                local rggetVehicleHeadLightColor(veh)
                dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb)
                --<<-->>
                setElementRotation(veh00rot)
                ustawDanePojazdu(vehlast_insert_idwlasciciel)
                warpPedIntoVehicle(sourceveh)
                end15001source)
            else
            outputChatBox("Mo?esz posiada? maksymalnie 5 pojazd?w."source255255255true)
            end
          end
        else
        outputChatBox("Potrzebujesz "..cena.."Euro by kupi? ten pojazd."source255255255true)
        end
    end
end)

--komenda tworzaca
function stworzPojazdCMD(playercmdidwlasciciel)
local acc getAccountName (getPlayerAccount(player))
    if acc then
    if isObjectInACLGroup ("user."..accaclGetGroup ("Admin")) then
        if id and wlasciciel then
        local id tonumber(id)
            if id then
                if getVehicleNameFromModel(idthen
                local xygetElementPosition(player)
                local __rot getElementRotation(player)
                
                local veh createVehicle(idxyz)
                    if veh then
                    setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                    setElementData(veh"pojazd_przebieg"0)
                    local rggetVehicleColor(vehtrue)
                    --<<-->>
                    local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                    local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                    local rggetVehicleHeadLightColor(veh)
                    dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb)
                    --<<-->>
                    setElementRotation(veh00rot)
                    ustawDanePojazdu(vehlast_insert_idwlasciciel)
                    else
                    outputChatBox("Podane ID jest niepoprawne."player255255255true)
                    end
                else
                outputChatBox("Podane ID jest niepoprawne."player255255255true)
                end
            end
        else
        outputChatBox("Wpisz /stworz [id-pojazdu] [wlasciciel]"player255255255true)
        end
    end
    end
end
addCommandHandler("stworz"stworzPojazdCMD)



dam jeszcze zapis jak b?dzie potrzebny:


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, ca INTEGER, cb INTEGER, cc 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 resultnum_rowserrormsg dbPoll (query, -1)
    for i,v in pairs(result) do
    local veh createVehicle(v["model"], v["x"], v["y"], v["z"])
    setElementRotation(veh00v["rot"])
    setVehicleColor(vehv["ca"], v["cb"], v["cc"])
    ustawDanePojazdu(vehv["id"], v["wlasciciel"])
    
    --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 resultnum_rowserrormsg dbPoll (query, -1)
    setVehiclePaintjob(vehresult[1].paintjob)
    setVehicleHeadLightColor(vehresult[1].hrresult[1].hgresult[1].hb)
        for i,v in pairs(result) do
            for iivv 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(vehvv)
                    end
                end
            end
        end
    end
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), onStartLoadVehicles)

function ustawDanePojazdu(vehidwlasciciel) --id INTwlasciciel STRING
setElementData(veh"car_id"id)
setElementData(veh"car_owner"wlasciciel)
end

function onVehicleStartEnter(playerseatjacked)
  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
        outputChatBox("Nie masz kluczyk?w do tego pojazdu."player255255255true)
        cancelEvent()
        end
    end
  end
end
addEventHandler ("onVehicleStartEnter"resourceRootonVehicleStartEnter)

--<<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 xygetElementPosition(v)
        local __rot getElementRotation(v)
        local color1color2color3color4 getVehicleColor(vtrue)
        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.."', ca='"..color1.."', cb='"..color2.."', cc='"..color3.."', przebieg='"..przebieg.."', paliwo='"..paliwo.."' WHERE id='"..id.."'")
        
        local paintjob getVehiclePaintjob(v)
        local rggetVehicleHeadLightColor(v)
        sav = {}
            for i=016 do
            local upgrade getVehicleUpgradeOnSlot(vi)
            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(zapiszPojazdy9000000)

function zapiszKomenda(player)
local acc getAccountName (getPlayerAccount(player))
    if isObjectInACLGroup ("user."..accaclGetGroup ("Admin")) then
    zapiszPojazdy()
    outputChatBox("** Zapisano pojazdy."player255255255true)
    end
end
addCommandHandler("zapiszpojazdy"zapiszKomenda)

-- mapaf11
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"rootvehs)
    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(tabv)
            end
        end
    end
    return tab
end

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

Za pomoc dam pare :piwo:

[ Dodano: 2015-07-08, 21:50 ]
dobra znalaz?em
setElementData(veh"car_id"id


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 21:54


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3


addCommandHandler("teleport", function(plrcmdparam)
if tonumber(paramthen
for _v in ipairs(getElementsByType("vehicle")) do
if param == getElementData(v"car_id"then
local xygetElementPosition(plr)
setElementPosition(vxy5)
warpPedIntoVehicle(plrv)
end
end
end)


Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-08, 22:04


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

nie dzia?a mi to

[ Dodano: 2015-07-08, 22:21 ]
aa i db jest co? z ) tam po end i nie mog? tego zwalczy? :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-09, 09:08


Fanciak

BOT






Wiek: 25
Na forum: 4446 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

Dodaj / usu? end. Pokombinuj

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-09, 10:07


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Ok dzi? b?d? kombinowa? :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-09, 11:02


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

Jednego endu zabrak?o.
addCommandHandler("teleport", function(plrcmdparam)
if tonumber(paramthen
for _v in ipairs(getElementsByType("vehicle")) do
if param == getElementData(v"car_id"then
local xygetElementPosition(plr)
setElementPosition(vxy5)
warpPedIntoVehicle(plrv)
end
end
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-09, 11:11


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

dalej nie dzia?a to :/ pokazuje db i? co? w 10 linijce z ) jest nie tak. pr?buj? zmieniaj?c, usuwaj?c i dalej to samo.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-09, 11:31


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

A robisz to jako jeden kod w osobnym pliku, czy w jednym pliku w kt?rym s? tez inne funkcje ?

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-09, 12:18


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

osobny plik, jak robi?em w tym samym co by?o z pojazdami pliku nie chcia? w og?le chodzi? skrypt.
Plik jest jako 1 skrypt z pojazdami.

Postaw piwo autorowi tego posta
 

 
Tagi: tepanie :: pojazdu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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