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: 26
Na forum: 3763 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.492145.4810.5055,2,255,0,0,255,0,100)
createBlip(1999.332469.1310.9055,2,255,0,0,255,0,100)
--createBlip(173.23618.225.5655,2,255,0,0,255,0,100)
--createBlip(2119.671397.2310.8155,2,255,0,0,255,0,100)
--createBlip(2872.422264.6510.8155,2,255,0,0,255,0,100)
--createBlip(2560.42739.6510.8155,2,255,0,0,255,0,100)

local positionVehicles = {

      --{'NAZWA',IDmath.random(0,10), CENA2886.202257.1110.75359.36359.9343.58},

--      CYGAN
      {'Moonbeam'418math.random(51718,82719), math.random(3800,4000), 2235.032050.3210.910.10.089.5},
      {'Walton'478math.random(51718,82719), math.random(3800,4000), 2235.072042.3810.81359.2360.089.9},
      {'Sadler'543math.random(51718,82719), math.random(8800,9000), 2246.522042.5110.64359.00.0269.8},
      {'Perennial'404math.random(51718,82719), math.random(3800,4000), 2235.242034.7310.56359.70.090.1},
      {'Manana'410math.random(51718,82719), math.random(4800,5000), 2246.012050.1910.47359.40.0269.5}, 
      {'Nebula'516math.random(51718,82719), math.random(10000,10200), 2246.582034.8310.65360.00.0269.9},
      {'Oceanic'467math.random(51718,82719), math.random(14800,15000), 2233.082063.7610.560.00.0179.9},
      {'Glendale'466math.random(51718,82719), math.random(11800,12000), 2241.492063.9310.560.0360.0180.1},
      {'Bobcat'422math.random(51718,82719), math.random(13800,14000), 2249.842063.9110.80359.1360.0179.5},
      {'Picador'600math.random(31718,52719), math.random(19800,20000), 2258.312063.9910.53359.1360.0180.7},
      {'Vincent'540math.random(31718,52719), math.random(23000,23200), 2217.242059.4610.68359.72360.00270.37},
      {'Clover'542math.random(31718,52719), math.random(15000,15200), 2217.642052.3410.560.04360.00269.17},    
      {'Tampa'549math.random(31718,52719), math.random(16000,16200), 2217.352045.3410.52359.97359.96270.44},          
      
--      SALON TERENOWY
      {'Huntley',579math.random(0,10), 2500001999.332469.1310.900.00.0301.8},
      {'Mesa'500math.random(0,10), 600001999.332469.13-510.900.00.0301.8},
      {'Journey'508math.random(0,10), 500000,  1999.332469.13-1010.900.00.0301.8},
      {'Sandking'495math.random(0,10), 400000,  1999.332469.13-1510.900.00.0301.8},        
      {'Rancher'505math.random(0,10), 200000,  1999.332469.13-2010.900.00.0301.8},
      {'Yosemite'554math.random(0,10), 1500001999.332469.13-2510.900.00.0301.8 },
      {'BF Injection'424math.random(0,10), 300000,  2004.652442.8010.49360.00.05.40.00.0301.8},
      {'Landstalker'400math.random(0,10), 50000,  2008.882490.6810.49360.00.0153.8},
      
--       SALON LOWRIDER?W
      {'Savanna'567math.random(0,10), 320000,  1990.482492.58-510.50359.90.1260.0},
      {'Voodoo'412math.random(0,10), 180000,  1990.482487.58-810.49359.90.1260.0},
      {'Blade'536math.random(0,10), 3500001990.482487.58+510.49359.90.1260.0},
      {'Tornado'576math.random(0,10), 1000001990.482487.58+1010.49359.90.1260.0},
      {'Broadway'575math.random(0,10), 2000001990.482487.58+1510.49359.90.1260.0},
      {'Remington'534math.random(0,10), 400000,  1990.482487.58+2010.49359.90.1260.0},
      {'Esperanto'419math.random(0,10), 150000,  1996.032472.8010.47360.00.0337.4},



--      SALON NORMALNY
      {'Premier'426math.random(0,10), 550001986.402473.7110.55360.00.1299.0},
      {'Blista Compact'496math.random(0,10), 80000,1985.972478.0310.56360.00.1299.4},
      {'Sunrise'550math.random(0,10), 300001985.972478.03+510.56360.00.1299.4},
      {'Buffalo'402math.random(0,10), 150000,1985.972478.03+1010.56360.00.1299.4 },
      {'Sabre'475math.random(0,10), 600001985.972478.03+1510.56360.00.1299.4},
      {'Admiral'445math.random(0,10), 500002008.072460.7010.52360.00.0100.0},
      {'Sentinel'405math.random(0,10), 500002008.182464.3810.51360.00.0100.0},
      {'Phoenix'603math.random(0,10), 1200002008.302468.4610.48360.00.0100.0},  
      {'Tahoma'566math.random(0,10), 45000,2008.902473.5010.47360.00.0100.0},
      {'Majestic'517math.random(0,10), 250002009.172478.5910.48360.00.0100.0},
      --{'Cadrona'527math.random(0,10), 40000, },       
      
      
--     SALON MOTOCYKLI
      {'Freeway'463math.random(0,10), 900001847.032156.6510.41359.30.0200.0 },
      {'Wayfarer'586math.random(0,10), 120000,1849.422156.9610.42359.40.0200.0 },
      {'Sanchez'468math.random(0,10), 600001852.052157.0510.41359.30.0200.0},
      {'BF-400'581math.random(0,10), 80000,  1854.672157.0610.41359.30.0200.0},      
      {'PCJ-600'461math.random(0,10), 800001858.122157.0610.41359.30.0200.0},
      {'Faggio'462math.random(0,10), 200001860.782157.0310.41359.30.0200.0},
      {'Quad'471math.random(0,10), 350001863.462156.8710.42359.40.0200.0},
      {'FCR-900'521math.random(0,10), 1100001866.142157.0010.41359.30.0200.0},       
      
--     SALON DOWNTOWN
      {'Cheetah'415math.random(0,10), 4500001896.492145.4810.50360.00.0359.3},
      {'Elegy'562math.random(0,10), 3500001891.872145.4810.48360.00.02.5},
      {'Sultan'560math.random(0,10), 4000001887.882145.4810.49360.00.0358.1},
      {'Bullet'541math.random(0,10), 6500001882.652145.4810.49360.00.01.5},
      {'Infernus'411math.random(0,10), 10000001877.982145.4810.52360.00.05.9},
      {'Comet'480math.random(0,10), 3000001873.312145.4810.52360.00.0359.7},
      {'Jester'559math.random(0,10), 2200001868.882145.4810.490.00.0356.4},
      {'Turismo'451math.random(0,10), 8500001866.732135.7510.47360.00.05.3},
      {'Super GT'506math.random(0,10), 4000001863.102135.7610.49360.00.04.6},
      {'ZR-350'477math.random(0,10), 2000001852.472135.7510.48360.00.01.8},     
      {'Banshee'429math.random(0,10), 4500001846.672135.8110.49360.00.0356.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(veh1)
    setElementFrozen(veh,true)
    setVehicleColor(veh255,255,255)
    setVehicleDamageProof(vehtrue)
    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(plrseatjacked)
    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(plrseatjacked)
    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(plrcmd)
    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(plrcost)
    if mileage <= 100 then
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,1)"modelgetElementData(plr,"player:uid"),mileage,"false")
    else
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,1)"modelgetElementData(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: 25
Na forum: 3587 dni
Posty: 554
Nick w MP: Split

Piwa: 2596

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.06466.3834.93359.970.26269.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: 3502 dni
Posty: 225
Nick w MP: psychol.

Piwa: 2998

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: 26
Na forum: 3763 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: 26
Na forum: 3763 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: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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: 26
Na forum: 3763 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: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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: 26
Na forum: 3763 dni
Posty: 182

Piwa: 7

Respekt: 60

Zrobi?em co? takiego :

addCommandHandler('zakup', function(plrcmd)
    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(plrcost)
    if mileage <= 100 then
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,0)"modelgetElementData(plr,"player:uid"),mileage,"false")
    else
    exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,parking) VALUES (?,?,?,?,0)"modelgetElementData(plr,"player:uid"),mileage,"true")
    end
    setElementPostion(model,1893.862166.2610.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: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

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 » ogrpg-salon 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