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

Wysłany: 2019-01-24, 18:57


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?? mam pytanko czy kto? by zmieni?, ?e je?eli kupujemy pojazd to by nie teleportowa?o pojazdu do przecho tylko go respi?o go w danym miejscu a w poje?dzie gracza. Za pomoc daje RESPEKT i Piweczko <3


kod
--[[
    ResourceOur-Game
    Filename: [our]vehbuy/s_vehbuy.lua
    DevelopersSplit <split.programista@gmail.com>
    Copyright <split.programista@gmail.com2015
    Nie masz prawa u?ywatego kodu bez mojej zgody.
]]

local positionVehicles = {
    {'Flash'565math.random(0,0), math.random(65000,70000), -1956.11,257.54,40.67,359.6,0.0,276.2},
    {'Buffalo'402math.random(0,0), math.random(75000,80000), -1955.11,305.02,40.88,360.0,360.0,95.1},
    {'Sultan'560math.random(0,0), math.random(105000,110000), -1943.89,273.41,40.75,359.9,360.0,181.7},
    {'Savanna'567math.random(0,0), math.random(50000,70000), -1943.69,256.95,40.91,0.5,360.0,16.2},
    {'Burrito'482math.random(0,0), math.random(50000,60000), -1955.91,266.65,41.17,359.1,360.0,302.5},
    {'Jester'559math.random(0,0), math.random(120000,135000), -1953.47,296.04,40.70,359.9,359.6,109.5},
    --dol
    {'Clover'542math.random(0,0), math.random(15000,20000), -1945.60,266.42,35.22,0.0,360.0,87.9},
    {'Premier'426math.random(0,0), math.random(20000,25000), -1962.04,272.60,35.21,359.9,0.0,293.0},
    {'Sabre'475math.random(0,0), math.random(30000,35000), -1945.15,273.97,35.28,359.7,0.0,121.7},
    {'Tahoma'566math.random(0,0), math.random(10000,15000), -1961.79,258.78,35.25,0.3,360.0,330.4},
    {'Glendale'466math.random(0,0), math.random(40000,50000), -1945.80,255.77,35.21,0.0,0.0,66.4},
    {'Club'589math.random(0,0), math.random(40000,50000), -1957.04,305.72,35.13,0.0,360.0,160.6},
    -- salon2
    {'ZR-350'477math.random(0,0), math.random(100000,120000), -1667.28,1215.85,7.01,359.8,0.0,254.1},
    {'Cheetah'415math.random(0,0), math.random(300000,350000), -1658.35,1214.79,13.44,0.3,0.0,213.4},
    {'Turismo'451math.random(0,0), math.random(700000,800000), -1647.76,1207.18,20.86,359.5,359.9,47.4},
    {'Infernus'411math.random(0,0), math.random(1200000,1300000), -1663.27,1222.54,20.88,0.0,0.0,189.3},
    {'Bullet'541math.random(0,0), math.random(800000,900000), -1671.92,1205.50,20.78,359.5,360.0,309.0},
    {'Banshee'429math.random(0,0), math.random(500000,550000), -1653.78,1213.42,20.84,360.0,360.0,79.5},


}

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,'pojazd_opis','Pojazd: '..v[1]..'\nCena: '..v[4]..' $\nPrzebieg: '..v[3]..' km\nAby kupi? pojazd wsi?d? na F i wpisz /zakup')
    setVehicleOverrideLights(veh1)
    setElementFrozen(veh,true)
    setVehicleColor(veh255500)
    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
        plr:outputChat('* Pojazd nie jest dost?pny w sprzeda?y.'25500)
        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)

    plr:outputChat('* Aby zakupi? ten pojazd wpisz /zakup')
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
        outputChatBox('* Nie posiadasz wystarczaj?cej ilo?ci PLN.'plr25500)
        return
    end

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

    local cost=data.cost
    local model=data.model
    local mileage=data.mileage
    local uid=getElementData(plr,'player:uid') or 0
    takePlayerMoney(plrcost)
    
    exports['ogrpg-db']:dbSet('INSERT INTO ogrpg_vehicles (model, frozen, ownedPlayer, parking, fuel) VALUES (?, ?, ?, ?, ?)'model0getElementData(plr,'player:uid'), 115)
    outputChatBox('* Zakupiles swoj pojazd! Znajdziesz go w przechowywalni'plr,255,255,255,true)
    
    Timer(function() 
        destroyElement(blip) 
    end60000*21)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-24, 19:24


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Z kodu usu? to:
if vehicle then
        removePedFromVehicle(vehicle)
        destroyElement(vehicle)
end


i dodaj tam takie funkcje jak:

Więcej informacji znajdziesz w Wikipedii MTA:

createVehicle


Więcej informacji znajdziesz w Wikipedii MTA:

warpPedIntoVehicle

ustaw od razu w?a?ciciela pojazdu pod odpowiedni? elementDat? korzystaj?c z

Więcej informacji znajdziesz w Wikipedii MTA:

setElementData


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-26, 06:11


HeyLifeV2







Wiek: 24
Na forum: 3048 dni
Posty: 30
Nick w MP: Kakao

Piwa: 23

Respekt: 50

sluchaj ja ci podesle koncowke skryptu a ty sobie dokleisz oke ?
i tak jak wsylalem tak wklej koncowke i powinno dzialac tylko usun to swoje zakupiles pojazd znajdziesz go w przecho , liczne na piwko :mrgreen:


    end
    removePedFromVehicle(plr)
    fadeCamera(plr,false,1)
            setTimer(fadeCamera,1000,1,plr,true,1)
            setTimer(setElementPosition,1001,1,plr,-1931.92,271.13,41.05)
    triggerClientEvent(plr,"addNotification",root,string.format("Zakupiles swoj pojazd "..getVehicleNameFromModel(model)..", znajdziesz go w przechowywalni."),"info")
end)


Komentarz DsJ3 dodany 2019-01-26, 10:35Następnym razem dodaj załącznik[BBCode] [lua]Kod[./lua] bez kropki
Ostatnio zmieniony przez DsJ3 2019-01-26, 10:35, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-26, 18:33


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Twoja wypowied? HeyLifeV2 jest zb?dna, poniewa?:
- sk?d wiesz, ?e autor postu posiada event "addNotification"?
- wklejaj?c Tw?j kod nadal nie b?dzie respi? si? w poje?dzie, ten pojazd nawet nie b?dzie si? tworzy?
- Tw?j kod nic nie wnosi do skryptu, nawet dodaje zb?dne przyciemnianie ekranu, nadal gracz otrzyma notyfikacj? i r?wnie? wyteleportuje go z pojazdu (co w poprzednim kodzie dzia?o si? jeszcze wcze?niej ni? ty wys?a?e?), jeszcze przenosisz gdzie? gracza, o co autor postu nie prosi?.

Naucz si??czyta? czy co?:
Cytat:

[...] je?eli kupujemy pojazd to by nie teleportowa?o pojazdu do przecho tylko go respi?o go w danym miejscu a w poje?dzie gracza


Je?eli oczekujesz gotowe kodu, wykonaj co? na wz?r tego (albo po prostu ctrl+c ctrl+v):
--[[
    ResourceOur-Game
    Filename: [our]vehbuy/s_vehbuy.lua
    DevelopersSplit <split.programista@gmail.com>
    Copyright <split.programista@gmail.com2015
    Nie masz prawa u?ywatego kodu bez mojej zgody.
]]

local positionVehicles = {
    {'Flash'565math.random(0,0), math.random(65000,70000), -1956.11,257.54,40.67,359.6,0.0,276.2},
    {'Buffalo'402math.random(0,0), math.random(75000,80000), -1955.11,305.02,40.88,360.0,360.0,95.1},
    {'Sultan'560math.random(0,0), math.random(105000,110000), -1943.89,273.41,40.75,359.9,360.0,181.7},
    {'Savanna'567math.random(0,0), math.random(50000,70000), -1943.69,256.95,40.91,0.5,360.0,16.2},
    {'Burrito'482math.random(0,0), math.random(50000,60000), -1955.91,266.65,41.17,359.1,360.0,302.5},
    {'Jester'559math.random(0,0), math.random(120000,135000), -1953.47,296.04,40.70,359.9,359.6,109.5},
    --dol
    {'Clover'542math.random(0,0), math.random(15000,20000), -1945.60,266.42,35.22,0.0,360.0,87.9},
    {'Premier'426math.random(0,0), math.random(20000,25000), -1962.04,272.60,35.21,359.9,0.0,293.0},
    {'Sabre'475math.random(0,0), math.random(30000,35000), -1945.15,273.97,35.28,359.7,0.0,121.7},
    {'Tahoma'566math.random(0,0), math.random(10000,15000), -1961.79,258.78,35.25,0.3,360.0,330.4},
    {'Glendale'466math.random(0,0), math.random(40000,50000), -1945.80,255.77,35.21,0.0,0.0,66.4},
    {'Club'589math.random(0,0), math.random(40000,50000), -1957.04,305.72,35.13,0.0,360.0,160.6},
    -- salon2
    {'ZR-350'477math.random(0,0), math.random(100000,120000), -1667.28,1215.85,7.01,359.8,0.0,254.1},
    {'Cheetah'415math.random(0,0), math.random(300000,350000), -1658.35,1214.79,13.44,0.3,0.0,213.4},
    {'Turismo'451math.random(0,0), math.random(700000,800000), -1647.76,1207.18,20.86,359.5,359.9,47.4},
    {'Infernus'411math.random(0,0), math.random(1200000,1300000), -1663.27,1222.54,20.88,0.0,0.0,189.3},
    {'Bullet'541math.random(0,0), math.random(800000,900000), -1671.92,1205.50,20.78,359.5,360.0,309.0},
    {'Banshee'429math.random(0,0), math.random(500000,550000), -1653.78,1213.42,20.84,360.0,360.0,79.5},


}

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,'pojazd_opis','Pojazd: '..v[1]..'\nCena: '..v[4]..' $\nPrzebieg: '..v[3]..' km\nAby kupi? pojazd wsi?d? na F i wpisz /zakup')
    setVehicleOverrideLights(veh1)
    setElementFrozen(veh,true)
    setVehicleColor(veh255500)
    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
        plr:outputChat('* Pojazd nie jest dost?pny w sprzeda?y.'25500)
        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)

    plr:outputChat('* Aby zakupi? ten pojazd wpisz /zakup')
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
        outputChatBox('* Nie posiadasz wystarczaj?cej ilo?ci PLN.'plr25500)
        return
    end

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

    local cost=data.cost
    local model=data.model
    local mileage=data.mileage
    local uid=getElementData(plr,'player:uid') or 0
    takePlayerMoney(plrcost)
    
    exports['ogrpg-db']:dbSet('INSERT INTO ogrpg_vehicles (model, frozen, ownedPlayer, parking, fuel) VALUES (?, ?, ?, ?, ?)'model0getElementData(plr,'player:uid'), 015)
    outputChatBox('* Zakupiles swoj pojazd!'plr,255,255,255,true)

    local zakupiony_pojazd createVehicle(data.modelpozycjaXpozycjaYpozycjaZ)
    warpPedIntoVehicle(plrzakupiony_pojazd)
end)


Dodaj sobie ustawianie paliwa i wszystkiego, co posiadaj? auta wyci?gni?te z przechowalni tak aby nie by?o problem?w r?wnie? przy pr?bie wlo?enia pojazdu stworzonego przez powy?szy skrypt.

W linijce
    local zakupiony_pojazd createVehicle(data.modelpozycjaXpozycjaYpozycjaZ)

zamie? pozycjaX, Y, Z na koordynaty gdzie ma tworzy? si? zakupiony pojazd.

Warto w przysz?o?ci doda? sprawdzanie, czy w miejscu gdzie wydajesz zakupiony pojazd co? nie stoi.

Postaw piwo autorowi tego posta
 

 
Tagi: gdy :: kupi :: pojazd :: teleportuje :: niego
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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