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

Wysłany: 2017-06-20, 22:42


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Siemka . Chcia?bym aby auta po kupnie respi?y sie w wybranym miejscu i oczywiscie zeby all sie zapisywa?o w bazie danych ( w?a?ciciel,id itp.)
Kod :

--salon_s
createBlip(1896.49, 2145.48, 10.50, 55,2,255,0,0,255,0,100)
createBlip(1999.33, 2469.13, 10.90, 55,2,255,0,0,255,0,100)
--createBlip(173.23, 618.22, 5.56, 55,2,255,0,0,255,0,100)
--createBlip(2119.67, 1397.23, 10.81, 55,2,255,0,0,255,0,100)
--createBlip(2872.42, 2264.65, 10.81, 55,2,255,0,0,255,0,100)
--createBlip(2560.42, 739.65, 10.81, 55,2,255,0,0,255,0,100)

local positionVehicles = {

      --{'NAZWA',ID, math.random(0,10), CENA, 2886.20, 2257.11, 10.75, 359.36, 359.93, 43.58},

--      CYGAN
      {'Moonbeam', 418, math.random(51718,82719), math.random(3800,4000), 2235.03, 2050.32, 10.91, 0.1, 0.0, 89.5},
      {'Walton', 478, math.random(51718,82719), math.random(3800,4000), 2235.07, 2042.38, 10.81, 359.2, 360.0, 89.9},
      {'Sadler', 543, math.random(51718,82719), math.random(8800,9000), 2246.52, 2042.51, 10.64, 359.0, 0.0, 269.8},
      {'Perennial', 404, math.random(51718,82719), math.random(3800,4000), 2235.24, 2034.73, 10.56, 359.7, 0.0, 90.1},
      {'Manana', 410, math.random(51718,82719), math.random(4800,5000), 2246.01, 2050.19, 10.47, 359.4, 0.0, 269.5}, 
      {'Nebula', 516, math.random(51718,82719), math.random(10000,10200), 2246.58, 2034.83, 10.65, 360.0, 0.0, 269.9},
      {'Oceanic', 467, math.random(51718,82719), math.random(14800,15000), 2233.08, 2063.76, 10.56, 0.0, 0.0, 179.9},
      {'Glendale', 466, math.random(51718,82719), math.random(11800,12000), 2241.49, 2063.93, 10.56, 0.0, 360.0, 180.1},
      {'Bobcat', 422, math.random(51718,82719), math.random(13800,14000), 2249.84, 2063.91, 10.80, 359.1, 360.0, 179.5},
      {'Picador', 600, math.random(31718,52719), math.random(19800,20000), 2258.31, 2063.99, 10.53, 359.1, 360.0, 180.7},
      {'Vincent', 540, math.random(31718,52719), math.random(23000,23200), 2217.24, 2059.46, 10.68, 359.72, 360.00, 270.37},
      {'Clover', 542, math.random(31718,52719), math.random(15000,15200), 2217.64, 2052.34, 10.56, 0.04, 360.00, 269.17},    
      {'Tampa', 549, math.random(31718,52719), math.random(16000,16200), 2217.35, 2045.34, 10.52, 359.97, 359.96, 270.44},          
      
--      SALON TERENOWY
      {'Huntley',579, math.random(0,10), 250000, 1999.33, 2469.13, 10.90, 0.0, 0.0, 301.8},
      {'Mesa', 500, math.random(0,10), 60000, 1999.33, 2469.13-5, 10.90, 0.0, 0.0, 301.8},
      {'Journey', 508, math.random(0,10), 500000,  1999.33, 2469.13-10, 10.90, 0.0, 0.0, 301.8},
      {'Sandking', 495, math.random(0,10), 400000,  1999.33, 2469.13-15, 10.90, 0.0, 0.0, 301.8},        
      {'Rancher', 505, math.random(0,10), 200000,  1999.33, 2469.13-20, 10.90, 0.0, 0.0, 301.8},
      {'Yosemite', 554, math.random(0,10), 150000, 1999.33, 2469.13-25, 10.90, 0.0, 0.0, 301.8 },
      {'BF Injection', 424, math.random(0,10), 300000,  2004.65, 2442.80, 10.49, 360.0, 0.0, 5.4, 0.0, 0.0, 301.8},
      {'Landstalker', 400, math.random(0,10), 50000,  2008.88, 2490.68, 10.49, 360.0, 0.0, 153.8},
      
--       SALON LOWRIDER?W
      {'Savanna', 567, math.random(0,10), 320000,  1990.48, 2492.58-5, 10.50, 359.9, 0.1, 260.0},
      {'Voodoo', 412, math.random(0,10), 180000,  1990.48, 2487.58-8, 10.49, 359.9, 0.1, 260.0},
      {'Blade', 536, math.random(0,10), 350000, 1990.48, 2487.58+5, 10.49, 359.9, 0.1, 260.0},
      {'Tornado', 576, math.random(0,10), 100000, 1990.48, 2487.58+10, 10.49, 359.9, 0.1, 260.0},
      {'Broadway', 575, math.random(0,10), 200000, 1990.48, 2487.58+15, 10.49, 359.9, 0.1, 260.0},
      {'Remington', 534, math.random(0,10), 400000,  1990.48, 2487.58+20, 10.49, 359.9, 0.1, 260.0},
      {'Esperanto', 419, math.random(0,10), 150000,  1996.03, 2472.80, 10.47, 360.0, 0.0, 337.4},



--      SALON NORMALNY
      {'Premier', 426, math.random(0,10), 55000, 1986.40, 2473.71, 10.55, 360.0, 0.1, 299.0},
      {'Blista Compact', 496, math.random(0,10), 80000,1985.97, 2478.03, 10.56, 360.0, 0.1, 299.4},
      {'Sunrise', 550, math.random(0,10), 30000, 1985.97, 2478.03+5, 10.56, 360.0, 0.1, 299.4},
      {'Buffalo', 402, math.random(0,10), 150000,1985.97, 2478.03+10, 10.56, 360.0, 0.1, 299.4 },
      {'Sabre', 475, math.random(0,10), 60000, 1985.97, 2478.03+15, 10.56, 360.0, 0.1, 299.4},
      {'Admiral', 445, math.random(0,10), 50000, 2008.07, 2460.70, 10.52, 360.0, 0.0, 100.0},
      {'Sentinel', 405, math.random(0,10), 50000, 2008.18, 2464.38, 10.51, 360.0, 0.0, 100.0},
      {'Phoenix', 603, math.random(0,10), 120000, 2008.30, 2468.46, 10.48, 360.0, 0.0, 100.0},  
      {'Tahoma', 566, math.random(0,10), 45000,2008.90, 2473.50, 10.47, 360.0, 0.0, 100.0},
      {'Majestic', 517, math.random(0,10), 25000, 2009.17, 2478.59, 10.48, 360.0, 0.0, 100.0},
      --{'Cadrona', 527, math.random(0,10), 40000, },       
      
      
--     SALON MOTOCYKLI
      {'Freeway', 463, math.random(0,10), 90000, 1847.03, 2156.65, 10.41, 359.3, 0.0, 200.0 },
      {'Wayfarer', 586, math.random(0,10), 120000,1849.42, 2156.96, 10.42, 359.4, 0.0, 200.0 },
      {'Sanchez', 468, math.random(0,10), 60000, 1852.05, 2157.05, 10.41, 359.3, 0.0, 200.0},
      {'BF-400', 581, math.random(0,10), 80000,  1854.67, 2157.06, 10.41, 359.3, 0.0, 200.0},      
      {'PCJ-600', 461, math.random(0,10), 80000, 1858.12, 2157.06, 10.41, 359.3, 0.0, 200.0},
      {'Faggio', 462, math.random(0,10), 20000, 1860.78, 2157.03, 10.41, 359.3, 0.0, 200.0},
      {'Quad', 471, math.random(0,10), 35000, 1863.46, 2156.87, 10.42, 359.4, 0.0, 200.0},
      {'FCR-900', 521, math.random(0,10), 110000, 1866.14, 2157.00, 10.41, 359.3, 0.0, 200.0},       
      
--     SALON DOWNTOWN
      {'Cheetah', 415, math.random(0,10), 450000, 1896.49, 2145.48, 10.50, 360.0, 0.0, 359.3},
      {'Elegy', 562, math.random(0,10), 350000, 1891.87, 2145.48, 10.48, 360.0, 0.0, 2.5},
      {'Sultan', 560, math.random(0,10), 400000, 1887.88, 2145.48, 10.49, 360.0, 0.0, 358.1},
      {'Bullet', 541, math.random(0,10), 650000, 1882.65, 2145.48, 10.49, 360.0, 0.0, 1.5},
      {'Infernus', 411, math.random(0,10), 1000000, 1877.98, 2145.48, 10.52, 360.0, 0.0, 5.9},
      {'Comet', 480, math.random(0,10), 300000, 1873.31, 2145.48, 10.52, 360.0, 0.0, 359.7},
      {'Jester', 559, math.random(0,10), 220000, 1868.88, 2145.48, 10.49, 0.0, 0.0, 356.4},
      {'Turismo', 451, math.random(0,10), 850000, 1866.73, 2135.75, 10.47, 360.0, 0.0, 5.3},
      {'Super GT', 506, math.random(0,10), 400000, 1863.10, 2135.76, 10.49, 360.0, 0.0, 4.6},
      {'ZR-350', 477, math.random(0,10), 200000, 1852.47, 2135.75, 10.48, 360.0, 0.0, 1.8},     
      {'Banshee', 429, math.random(0,10), 450000, 1846.67, 2135.81, 10.49, 360.0, 0.0, 356.8},      

}
for i,v in pairs(positionVehicles) do
    local veh=createVehicle(v[2], v[5], v[6], v[7], v[8], v[9], v[10], v[11])
    setElementData(veh,'vehicle:desc','Pojazd: '..v[1]..'\nCena: '..v[4]..' PLN\nPrzebieg: '..v[3]..' km')
    setVehicleOverrideLights(veh, 1)
    setElementFrozen(veh,true)
    setVehicleColor(veh, 255,255,255)
    setVehicleDamageProof(veh, true)
    setElementData(veh,'vehicle.selling', true)

    veh:setData('vehsell:info', {
        ['cost']=(v[4]),
        ['model']=v[2],
        ['mileage']=v[3],
        ['selling']=v[12]
    }, false)
end

addEventHandler('onVehicleEnter', resourceRoot, function(plr, seat, jacked)
    if seat~=0 then return end
    if source:getData('vehsell:info') and source:getData('vehsell:info').selling==1 then
        triggerClientEvent(plr,"addNotification",root,"#cc0000Pojazd nie jest dost?pny w sprzeda?y!","error")
        return
    end

    local data=source:getData('vehsell:info')
    if not data then return end

    plr:setData('vehsell:info', {
        ['cost']=data.cost,
        ['model']=data.model,
        ['mileage']=data.mileage,
    }, false)
    
    triggerClientEvent(plr,"addNotification",root,"#00cc00Aby zakupi? ten pojazd wpisz #00cccc/zakup","error")
end)

addEventHandler('onVehicleExit', resourceRoot, function(plr, seat, jacked)
    if seat~=0 then return end

    local data=plr:getData('vehsell:info')
    if not data then return end

    plr:removeData('vehsell:info')
end)

addCommandHandler('zakup', function(plr, cmd)
    local data=plr:getData('vehsell:info')
    if not data then return end

    if getPlayerMoney(plr) < data.cost then
        triggerClientEvent(plr,"addNotification",root,"#cc0000Nie posiadasz wystarczajacej kwoty pieni?dzy!","error")
        return
    end

    local vehicle=plr:getOccupiedVehicle()
    if vehicle then
        removePedFromVehicle(vehicle)
    end

    local cost=data.cost
    local model=data.model
    local mileage=data.mileage
    local uid=getElementData(plr,'player:uid') or 0
    takePlayerMoney(plr, cost)
    if mileage <= 100 then
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,1)", model, getElementData(plr,"player:uid"),mileage,"false")
    else
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,1)", model, getElementData(plr,"player:uid"),mileage,"true")
    end
    triggerClientEvent(plr,"addNotification",root,string.format("#00cc00Zakupi?e? sw?j pojazd "..getVehicleNameFromModel(model)..", znajdziesz go w przechowywalni."),"info")
end)

Za pomoc :piwo:

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
AviX69
Wysłany: 2017-06-21, 03:11


.RiV







Wiek: 26
Na forum: 3729 dni
Posty: 554
Nick w MP: Split

Piwa: 2598

Respekt: 597,8
Respekt: 597,8

Z tego co widz? w kodzie jest dodawanie do bazy danych rekordu na temat pojazdu. Wystarczy teraz odpowiednio u?y? odwo?ania do zasobu czyli "export". We?my sobie kawa?ek kodu z przechowywalni.

local spawn=exports["ogrpg-vehicles"]:onRespawnVehicles(_,id,{-2050.06, 466.38, 34.93, 359.97, 0.26, 269.81})


Jest to odwo?anie do systemu pojazd?w w kt?rym respisz pojazd w danym miejscu, oczywi?cie gdy jest ten pojazd dodany do bazy danych.

Podpis

Autor OGRPG, na scenie MTA od 2012 roku.




Użytkownik: 08.08.2016
GTAO Member: 06.02.2017
Support-Team: 17.06.2017 & 01.06.2019 - 18.11.2019
Moderator: 14.01.2018 - 09.08.2018

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-22, 11:42


psychol.







Wiek: 23
Na forum: 3643 dni
Posty: 225
Nick w MP: psychol.

Piwa: 3003

Respekt: 244,5
Respekt: 244,5Respekt: 244,5

Nie zrobisz tego, b?dziesz zmuszony do przer?bki pliku 'ogrpg-db' poniewa? trzeba pobra? ID pojazdu lecz przez funkcje dodawania do bazy danych tego nie pobierzesz, je?li chcesz mog? ci da? kawa?ek kodu kt?ry ma w sobie wszystkie funkcje - mo?e on pobiera? dane od razu z dodawaniem do bazy danych.

Podpis


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-14, 08:22


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Jak kto? mo?e to niech to zrobi , bo ja tego nie ogarne ;x

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-14, 16:17


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

To wyt?umaczcie "krok po kroku" jak to zrobi? , oczywi?cie je?eli to nie sprawia wam problemu :)

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-14, 20:09


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

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

Pierwsza opcja:

Nie wiem czy to co? zmieni, ale proponowa?bym usuni?cie na dole kodu export?w i zast?pienie nimi funkcji setElementPosition - wtedy b?dzie teleportowa? w wyznaczone miejsce.

Druga opcja:

Usu? w kodzie ?eby nie wyrzuca?o z pojazdu, zmie? 'parking' w export na 0 wtedy pojazd nie b?dzie w przechowalni i dodaj do kodu setElementPosition.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-14, 20:24


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

W jakim sensie nie wyrzuca?o z pojazdu ?

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-15, 11:12


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

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

Po zakupie auta wywala cie z auta to usun to

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-22, 15:00


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Zrobi?em co? takiego :

addCommandHandler('zakup', function(plr, cmd)
    local data=plr:getData('vehsell:info')
    if not data then return end

    if getPlayerMoney(plr) < data.cost then
        triggerClientEvent(plr,"addNotification",root,"#cc0000Nie posiadasz wystarczajacej kwoty pieni?&#8482;dzy!","error")
        return
    end

    local vehicle=plr:getOccupiedVehicle()
    if vehicle then
        removePedFromVehicle(vehicle)
    end

    local cost=data.cost
    local model=data.model
    local mileage=data.mileage
    local uid=getElementData(plr,'player:uid') or 0
    takePlayerMoney(plr, cost)
    if mileage <= 100 then
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,0)", model, getElementData(plr,"player:uid"),mileage,"false")
    else
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,0)", model, getElementData(plr,"player:uid"),mileage,"true")
    end
    setElementPostion(model,1893.86, 2166.26, 10.82)
    triggerClientEvent(plr,"addNotification",root,string.format("#00cc00Zakupi?&#8218;e?&#8250; swĂłj pojazd "..getVehicleNameFromModel(model)..", znajdziesz go w przechowywalni."),"info")
end)


A taki mam b??d :
http://www120.zippyshare.com/v/Cq1YfbIr/file.html

[ Dodano: 2017-07-22, 16:14 ]
Zrobilem przed end setElementPostion i nic sie nie dzieje , b??d?w niema

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-22, 16:33


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

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

nie ma funkcji setElementPostion, tylko setElementPosition a i dodaj zeby gracza teleportowalo bo siedzi w aucie, zmien na zmienna gracza w komendzie 'zakup'

Postaw piwo autorowi tego posta
 

 
Tagi: ogrpg-salon
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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