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

Wysłany: 2016-08-24, 16:14


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157



local urzednik createPed(17,359.71,173.84,1008.39,270)
setElementInterior(urzednik,3)
setElementDimension(urzednik,1)
setElementData(urzednik,"ped_opis","Urzednik")

local sprzedaz createMarker(361.83,173.71,1007.10,"cylinder",2.4,0,192,240,200)
setElementInterior(sprzedaz,3)
setElementDimension(sprzedaz,1)

timer=nil
sprzedazz={}

-- SKRYPT

addEventHandler("onMarkerHit",sprzedaz,
    function (plr)
        outputChatBox("Aby sprzeda? pojazd wpisz /sprzedaj <nick> <id pojazdu> <cena>",plr)
    end
)

addCommandHandler("sprzedaj",
    function (plrcmdtargetidkoszt)
    
    if not target and not id and not koszt then
        outputChatBox("Poprawne u?ycie /sprzedaj <nick> <id pojazdu> <cena>",plr)
        return
    end
    
    if not isElementWithinMarker(plr,sprzedazthen
        outputChatBox("Nie jeste? w odpowiednim miejscu.",plr)
        return
    end
    
    if not target then
        outputChatBox("Nie znaleziono gracza o podanym nicku.",plr)
        return
    end
    
    local koszt tonumber(koszt)
    if not koszt then
        outputChatBox("Nie poda?e? ceny pojazdu za jak? chcesz go sprzeda?",plr)
        return
    end
    
    if not tonumber(idthen
        outputChatBox("Nie poda?e? id pojazdu",plr)
        return
    end
    
    if tonumber(koszt) < 0 then
        outputChatBox("Poda?e? z?? cen?!",plr)
        return
    end
    
    local account getPlayerAccount(plr)
    local wlasciciel getAccountName(account)
    for _,veh in ipairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(veh,"car_id")) == tonumber(idthen
            if tonumber(getElementData(veh,"car_owner")) ~= tonumber(getElementData(veh,"car_id")) then
                outputChatBox("Nie jeste? w?a?cicielem tego pojazdu!",plr)
                return
            end
            sprzedazz[target]={plr,target,veh,koszt}
        end
    end
    
    pokazOfertePojazdu(target)
    outputChatBox("Oferta wys?ana pomy?lnie!",plr)
    end
)

function pokazOfertePojazdu(plr)
if not sprzedazz[plrthen return end
local vehi sprzedazz[plr][3]
outputChatBox("Otrzyma?e?/a? ofert? kupna pojazdu "..getVehicleNameFromModel(getVehicleModel(vehi))..", za cen? "..sprzedazz[plr][4].." EUR.",plr)
outputChatBox("ID Pojazdu: "..getElementData(vehi,"car_id")..", przebieg pojazdu: "..getElementData(vehi,"pojazd_przebieg").."",plr)
outputChatBox("Aby zaakceptowa? wpisz /akceptuje ( masz 30 sekund )",plr)
timer=setTimer(function()
    sprzedazz[plr] = nil
    outputChatBox("Oferta wygas?a.",plr)
    removeCommandHandler("akceptuje",transakcjaOK)
end,30000,1)
addCommandHandler("akceptuje",transakcjaOK)
end

function akceptujOK(plr,cmd)
    if not sprzedazPojazdu[plrthen return end
    local veh=sprzedazz[plr][3]
    local cost=sprzedazz[plr][4]
    local target=sprzedazz[plr][1]
    if cost 0 then
        outputChatBox("* Cena jest nieprawid?owa."plr)
        return
    end
    if tonumber(cost) > getPlayerMoney(plrthen
        outputChatBox("* Nie posiadasz tyle got?wki."plr)
        return
    end
    givePlayerMoney(targetcost)
    takePlayerMoney(plrcost)
    killTimer(timer)
    outputChatBox("* Sprzeda? przeprowadzona pomy?lnie."plr)
    outputChatBox("* Sprzeda? przeprowadzona pomy?lnie."target)
    removeCommandHandler("akceptuj"akceptujOK)
    wykonajZapytanie(veh,plr)
end

function wykonajZapytanie(veh,plr)
local account getPlayerAccount(plr)
local login getAccountName(account)
local id getElementData(veh,"car_id")
ustawDanePojazdu(vehidlogin)
dbExec(handler"UPDATE pojazdy SET wlasciciel='"..login.."' WHERE id="..id.."")
end


Jak sprzedam pojazd o dobrym ID pisze ze nie jestem wlascicielem ;(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-25, 11:52


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Jest napisane*


Wi?cej szczeg???w, co dok?adnie nie dzia?a? Wstaw cz??? niedzia?aj?cego kodu a nie ca?o??.

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-25, 19:22


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Zapewne to jest b??d:
    if tonumber(getElementData(veh,"car_owner")) ~= tonumber(getElementData(veh,"car_id")) then


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-28, 16:00


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Tak w tej linijce jest b??d, pomo?esz naprawi??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-28, 16:06


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
BlackTen, Kombinuj na wszelkie sposoby

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-28, 16:13


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Kombinuje ale co? mi nie wychodzi :(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-28, 16:37


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

BlackTen, to tak:
 if tostring(getElementData(veh,"car_owner")) == tostringwlasciciel )) then


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-28, 19:15


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Dobra dzia?a, ale teraz nie pokazuje komunikatu ze otrzymalem oferte i nie dodaje komendy

local urzednik createPed(17,359.71,173.84,1008.39,270)
setElementInterior(urzednik,3)
setElementDimension(urzednik,1)
setElementData(urzednik,"ped_opis","Urzednik")

local sprzedaz createMarker(361.83,173.71,1007.10,"cylinder",2.4,0,192,240,200)
setElementInterior(sprzedaz,3)
setElementDimension(sprzedaz,1)

timer=nil
sprzedazz={}

-- SKRYPT

addEventHandler("onMarkerHit",sprzedaz,
    function (plr)
        outputChatBox("Aby sprzeda? pojazd wpisz /sprzedaj <nick> <id pojazdu> <cena>",plr)
    end
)

addCommandHandler("sprzedaj",
    function (plrcmdtargetidkoszt)
    
    if not target and not id and not koszt then
        outputChatBox("Poprawne u?ycie /sprzedaj <nick> <id pojazdu> <cena>",plr)
        return
    end
    
    if not isElementWithinMarker(plr,sprzedazthen
        outputChatBox("Nie jeste? w odpowiednim miejscu.",plr)
        return
    end
    
    if not target then
        outputChatBox("Nie znaleziono gracza o podanym nicku.",plr)
        return
    end
    
    local koszt tonumber(koszt)
    if not koszt then
        outputChatBox("Nie poda?e? ceny pojazdu za jak? chcesz go sprzeda?",plr)
        return
    end
    
    if not tonumber(idthen
        outputChatBox("Nie poda?e? id pojazdu",plr)
        return
    end
    
    if tonumber(koszt) < 0 then
        outputChatBox("Poda?e? z?? cen?!",plr)
        return
    end
    
    local account getPlayerAccount(plr)
    local wlasciciel getAccountName(account)
    for _,veh in ipairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(veh,"car_id")) == tonumber(idthen
             if tostring(getElementData(veh,"car_owner")) ~= tostringwlasciciel then
                outputChatBox("Nie jeste? w?a?cicielem tego pojazdu!",plr)
                return
            end
            sprzedazz[target]={plr,target,veh,koszt}
        end
    end
    
    pokazOfertePojazdu(target)
    outputChatBox("Oferta wys?ana pomy?lnie!",plr)
    end
)

function pokazOfertePojazdu(plr)
if not sprzedazz[plrthen return end
local vehi sprzedazz[plr][3]
outputChatBox("Otrzyma?e?/a? ofert? kupna pojazdu "..getVehicleNameFromModel(getVehicleModel(vehi))..", za cen? "..sprzedazz[plr][4].." EUR.",plr)
outputChatBox("ID Pojazdu: "..getElementData(vehi,"car_id")..", przebieg pojazdu: "..getElementData(vehi,"pojazd_przebieg").."",plr)
outputChatBox("Aby zaakceptowa? wpisz /akceptuje ( masz 30 sekund )",plr)
timer=setTimer(function()
    sprzedazz[plr] = nil
    outputChatBox("Oferta wygas?a.",plr)
    removeCommandHandler("akceptuje",transakcjaOK)
end,30000,1)
addCommandHandler("akceptuje",transakcjaOK)
end

function akceptujOK(plr,cmd)
    if not sprzedazPojazdu[plrthen return end
    local veh=sprzedazz[plr][3]
    local cost=sprzedazz[plr][4]
    local target=sprzedazz[plr][1]
    if cost 0 then
        outputChatBox("* Cena jest nieprawid?owa."plr)
        return
    end
    if tonumber(cost) > getPlayerMoney(plrthen
        outputChatBox("* Nie posiadasz tyle got?wki."plr)
        return
    end
    givePlayerMoney(targetcost)
    takePlayerMoney(plrcost)
    killTimer(timer)
    outputChatBox("* Sprzeda? przeprowadzona pomy?lnie."plr)
    outputChatBox("* Sprzeda? przeprowadzona pomy?lnie."target)
    removeCommandHandler("akceptuj"akceptujOK)
    wykonajZapytanie(veh,plr)
end

function wykonajZapytanie(veh,plr)
local account getPlayerAccount(plr)
local login getAccountName(account)
local id getElementData(veh,"car_id")
ustawDanePojazdu(vehidlogin)
dbExec(handler"UPDATE pojazdy SET wlasciciel='"..login.."' WHERE id="..id.."")
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-28, 21:41


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

BlackTen, ja ci wszystkiego nie b?d? poprawia?. Poprawi?em ci jeden b??d bo wida? by?o jak byk ?e por?wnujesz ID pojazdu ( number ) z Loginem gracza ( stringem ) wi?c ci to poprawi?em.

Z tym problemem zbytnio nie wiem co ci wykonuje a co nie. Zobacz tak:
   for _,veh in ipairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(veh,"car_id")) == tonumber(idthen
                if tostring(getElementData(veh,"car_owner")) == tostringwlasciciel then
                    sprzedazz[target]={plr,target,veh,koszt}
                else 
                outputChatBox("Nie jeste? w?a?cicielem tego pojazdu!",plr)
                return
            end
        end
    end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-29, 10:11


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Dalej nie wida?...

DB3:


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-29, 12:14


dudeks







Wiek: 31
Na forum: 6576 dni
Posty: 171

Piwa: 89

Respekt: 105,3
Respekt: 105,3

Czy wy "PROGRAMI?CI LUA" w og?le potraficie w jakimkolwiek stopniu j. angielski? Przecie? macie pokazane b??dy w debugscripcie, jest jak byk napisane gdzie i jaki jest b??d...

1. outputChatBox - nie wysy?a Ci wiadomo?ci, bo nie ma elementu gracza. W
function pokazOfertePojazdu(plr)

- plr to nie jest gracz, tylko string z jego nickiem. Najpro?ciej w tym g?wnianym kodzie Ci b?dzie w outputChatBoxie jako celu u?y? getPlayerFromName(plr). Bo reszty to raczej nie poprawisz, skoro z takimi g?upotami 'programisto' masz problem.

2. Nie dodaje komendy.... Expected function, got nil. Te? jak byk napisane, ?e oczekuje funkcji, a dosta?o jedno wielkie nic.
addCommandHandler("akceptuje",transakcjaOK)

Si? zdecyduj, czy masz nazw? funkcji transakcjaOK czy akceptujOK

Poza tym, w Twoim przypadku jest to durne rozwi?zanie, bo je?eli w tym samym momencie wyjd? dwie oferty sprzeda?y i gdy jeden gracz zaakceptuje to ju? drugi nie b?dzie m?g?, bo komenda zostanie odpisana od funkcji.

Pozdrawiam, pewnie i tak nie zrozumiesz tego co Ci napisa?em.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-29, 13:39


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Teraz to nie dzia?a jak wpisze /akceptuje

local urzednik createPed(17,359.71,173.84,1008.39,270)
setElementInterior(urzednik,3)
setElementDimension(urzednik,1)
setElementData(urzednik,"ped_opis","Urzednik")

local sprzedaz createMarker(361.83,173.71,1007.10,"cylinder",2.4,0,192,240,200)
setElementInterior(sprzedaz,3)
setElementDimension(sprzedaz,1)

timer=nil
sprzedazz={}

-- SKRYPT

addEventHandler("onMarkerHit",sprzedaz,
    function (plr)
        outputChatBox("Aby sprzeda? pojazd wpisz /sprzedaj <nick> <id pojazdu> <cena>",plr)
    end
)

addCommandHandler("sprzedaj",
    function (plrcmdtargetidkoszt)
    
    if not target and not id and not koszt then
        outputChatBox("Poprawne u?ycie /sprzedaj <nick> <id pojazdu> <cena>",plr)
        return
    end
    
    if not isElementWithinMarker(plr,sprzedazthen
        outputChatBox("Nie jeste? w odpowiednim miejscu.",plr)
        return
    end
    
    if not target then
        outputChatBox("Nie znaleziono gracza o podanym nicku.",plr)
        return
    end
    
    local koszt tonumber(koszt)
    if not koszt then
        outputChatBox("Nie poda?e? ceny pojazdu za jak? chcesz go sprzeda?",plr)
        return
    end
    
    if not tonumber(idthen
        outputChatBox("Nie poda?e? id pojazdu",plr)
        return
    end
    
    if tonumber(koszt) < 0 then
        outputChatBox("Poda?e? z?? cen?!",plr)
        return
    end
    
    local account getPlayerAccount(plr)
    local wlasciciel getAccountName(account)
    for _,veh in ipairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(veh,"car_id")) == tonumber(idthen
                if tostring(getElementData(veh,"car_owner")) == tostringwlasciciel then
                    sprzedazz[target]={plr,target,veh,koszt}
                else 
                outputChatBox("Nie jeste? w?a?cicielem tego pojazdu!",plr)
                return
            end
        end
    end
    
    pokazOfertePojazdu(target)
    outputChatBox("Oferta wys?ana pomy?lnie!",plr)
    end
)

function pokazOfertePojazdu(plr)
if not sprzedazz[plrthen return end
local vehi sprzedazz[plr][3]
local gracz getPlayerFromName(plr)
outputChatBox("Otrzyma?e?/a? ofert? kupna pojazdu "..getVehicleNameFromModel(getVehicleModel(vehi))..", za cen? "..sprzedazz[plr][4].." EUR.",gracz,0,255,0)
outputChatBox("ID Pojazdu: "..getElementData(vehi,"car_id")..", przebieg pojazdu: "..math.floor(getElementData(vehi,"pojazd_przebieg")).."",gracz,0,255,0)
outputChatBox("Aby zaakceptowa? wpisz /akceptuje ( masz 30 sekund )",gracz,0,255,0)
timer=setTimer(function()
    sprzedazz[plr] = nil
    outputChatBox("Oferta wygas?a.",gracz)
    removeCommandHandler("akceptuje",akceptujOK)
end,30000,1)
addCommandHandler("akceptuje",akceptujOK)
end

function akceptujOK(plr,cmd)
    if not sprzedazz[plrthen return end
    local veh=sprzedazz[plr][3]
    local cost=sprzedazz[plr][4]
    local target=sprzedazz[plr][1]
    if cost 0 then
        outputChatBox("* Cena jest nieprawid?owa."plr)
        return
    end
    if tonumber(cost) > getPlayerMoney(plrthen
        outputChatBox("* Nie posiadasz tyle got?wki."plr)
        return
    end
    givePlayerMoney(targetcost)
    takePlayerMoney(plrcost)
    killTimer(timer)
    outputChatBox("* Sprzeda? przeprowadzona pomy?lnie."plr)
    outputChatBox("* Sprzeda? przeprowadzona pomy?lnie."target)
    removeCommandHandler("akceptuje"akceptujOK)
    wykonajZapytanie(veh,plr)
end

function wykonajZapytanie(veh,plr)
local account getPlayerAccount(plr)
local login getAccountName(account)
local id getElementData(veh,"car_id")
ustawDanePojazdu(vehidlogin)
dbExec(handler"UPDATE pojazdy SET wlasciciel='"..login.."' WHERE id="..id.."")
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-29, 15:50


dudeks







Wiek: 31
Na forum: 6576 dni
Posty: 171

Piwa: 89

Respekt: 105,3
Respekt: 105,3

Oczekujesz pomocy, wprowadzi?e? jakie? zmiany i napisa?e?, ?e nie dzia?a. NIE DZIA?A KT?RA CZĘŚ? KODU? MAMY SI? DOMYSLA?? LUUUUUUUUUUUUUUUUUUUDZIE, U?YJCIE CHOCIA? RAZ KIEDY? M?ZGU...

@edit:

local oferty_sprzedazy = { }

local marker_sprzedazy createMarker(361.83,173.71,1007.10,"cylinder",2.4,0,192,240,200)
setElementInterior(marker_sprzedazy3)
setElementDimension(marker_sprzedazy1)

function sprzedaj_cmdHandler(pckomuidcena)
    if not isElementWithinMarker(pmarker_sprzedazythen
        outputChatBox("Nie mo?esz w tym miejscu sprzeda? pojazdu!"p)
        return false
    end

    if not cena or (tonumber(cena) < or tonumber(cena) > 9999999then
        outputChatBox("Prawid?owe u?ycie: /sprzedaj <komu> <id pojazdu> <cena $0 - 999999$>"p)
        return false
    end

    local kupujacy getPlayerFromName(komu)
    if not kupujacy then
        outputChatBox("Nie ma takiego gracz"p)
        return false
    end

    for _v in pairs(getElementsByType("vehicle")) do
        if ( tonumber(getElementData(v"car_id")) == tonumber(id) and tostring(getElementData(v"car_owner") == tostring(getAccountName(getPlayerAccount(p))) ) then

            oferty_sprzedazy[kupujacy] = {
                sprzedajacy p,
                pojazd v,
                kwota tonumber(cena),
                timer setTimer(
                    function (oferta)
                        if isTimer(oferty_sprzedazy[oferta].timerthen
                            outputChatBox("Oferta wygas?a!" oferta)
                            outputChatBox("Oferta wygas?a!"oferty_sprzedazy[oferta].sprzedajacy)
                            killTimer(oferty_sprzedazy[oferta].timer)
                        end
                    end30 10001kupujacy)
            }

            outputChatBox("Gracz "..getPlayerName(p).." oferuje Ci pojazd: "..getVehicleNameFromModel(getElementModel(v)).." za $"..cenakupujacy)
            outputChatBox("Wpisz /akceptuj, aby przyj?? jego ofert?. Oferta wyga?nie za 30 sekund!"kupujacy)
            outputChatBox("Wys?ano ofert? sprzeda?y do "..getPlayerName(kupujacy), p)
            return true
        end
    end
end

function akceptuj_cmdHandler(pc)
    if not oferty_sprzedazy[pthen 
        outputChatBox("Nie masz ?adnej oferty w chwili obecnej!"p)
        return false
    end

    local pMoney getPlayerMoney(p)
    local pAccount getAccountName(getPlayerAccount(p))

    if oferty_sprzedazy[p].kwota pMoney then
        outputChatBox("Nie posiadasz tylu pieni?dzy!"p)
        return false
    end

    takePlayerMoney(poferty_sprzedazy[p].cena)
    givePlayerMoney(oferty_sprzedazy[p].sprzedajacyoferty_sprzedazy[p].cena)

    local id getElementData(oferty_sprzedazy[p].pojazd"car_id")
    ustawDanePojazdu(oferty_sprzedazy[p].pojazdidpAccount)
    dbExec(handler"UPDATE pojazdy SET wlasciciel=? WHERE id=?"pAccountid)

    outputChatBox("Zakupi?e? pojazd!"p)
    outputChatBox("Gracz "..getPlayerName(p).." przyj?? twoj? ofert? sprzeda?y pojazdu! +$"..oferty_sprzedazy[p].cenaoferty_sprzedazy[p].sprzedajacy)

    if isTimer(oferty_sprzedazy[p].timerthen
        killTimer(oferty_sprzedazy[p].timer)
    end
    oferty_sprzedazy[p] = nil
end

addCommandHandler("sprzedaj"sprzedaj_cmdHandler)
addCommandHandler("akceptuj"akceptuj_cmdHandler)


Sprawd?, powinno dzia?a?.

Postaw piwo autorowi tego posta
 

 
Tagi: sprzedaż :: 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 » Sprzedaż 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