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

Wysłany: 2019-07-02, 18:35


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam mam pytanko co mam ?le w tych dw?ch exportach, w db3 0 b?ed?w a exporty nie dzia?aj?.
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=?", target, cost*100*0.97)
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=3191", plr, cost*100*0.03)

kod gie?dy na kt?rej maj? dzia?a? exporty
function RGBToHex(red, green, blue, alpha)
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
        return nil
    end
    if(alpha) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end

local LIMIT=9999-- tylko gracz mo?e kupi? trzy pojazdy

local cmd="sprzedajpojazd"
local cmd2="akceptuj"
local sprzedazPojazdu={}
local marker=nil
local timer=nil

function init()
local x=exports['ogrpg-db']:dbGet("SELECT * from komisy")
if not x or #x < 1 then return end
for i,p in pairs(x) do
wczytaj(p)
end
end
addEventHandler("onResourceStart",resourceRoot,init)

function wczytaj(v)
v.pos=split(v.pos,",")
local mkr=createMarker(v.pos[1], v.pos[2], v.pos[3]-0.90, "cylinder", 2, 96, 96, 96, 255)
setElementDimension(mkr, v.dimension or 0)
setElementInterior(mkr, v.interior or 0)
setElementData(mkr, "sprzedaz:pojazd?w", true)
setElementData(mkr,"sprzedaz:typ",2)
setElementData(mkr,"sprzedaz:owner",tonumber(v.owner))
local t=createElement("text")
setElementData(t,"name", "Sprzeda? w komisie!")
setElementPosition(t,v.pos[1], v.pos[2], v.pos[3])
setElementDimension(t, v.dimension or 0)
setElementInterior(t, v.interior or 0)
    addEventHandler ("onMarkerHit", mkr, function(el,md)
    if getElementType(el) ~= "player" then return end
    if getPedOccupiedVehicle(el) then
        outputChatBox("* Najpierw wyjd? z pojazdu.", el , 255, 0, 0)
        return
    end
    outputChatBox("* Aby sprzeda? pojazd: ", el)
    outputChatBox("* Wpisz /sprzedajpojazd <nick/ID> <id pojazdu> <cena>", el)
    local typ = getElementData(mkr,"sprzedaz:typ")
    if typ == 2 then
    end
    setElementData(el, "sprzedaz:pojazdow", true)
    setElementData(el, "sprzedaz:typ", typ)
    setElementData(el,"sprzedaz:owner",getElementData(source,"sprzedaz:owner"))
end)
    addEventHandler ("onMarkerLeave", mkr, function(el,md)
    if getElementType(el) ~= "player" then return end
    if getPedOccupiedVehicle(el) then
        outputChatBox("* Najpierw wyjd? z pojazdu.", el , 255, 0, 0)
        return
    end
    outputChatBox("* Wyszedles z markera ", el)
    setElementData(el, "sprzedaz:pojazdow", false)
    setElementData(el, "sprzedaz:typ", false)
    setElementData(el,"sprzedaz:owner",false)
end)
end

local pozycjeMarkerow={
    {"Gie?da SanFierro\nOdzia? Foster Valley", -2127.48, -996.53, 32.58-1.2},
}

for i,v in pairs(pozycjeMarkerow) do
    local mkr=createMarker(v[2], v[3], v[4]-0.90, "cylinder", 2.5, 255,200,0, 80)
    setElementDimension(mkr, v[6] or 0)
    setElementInterior(mkr, v[5] or 0)
    setElementData(mkr, "sprzedaz:pojazd?w", true)
    if v[7] and v[7] == true then
    setElementData(mkr,"sprzedaz:typ",2)
    else
    setElementData(mkr,"sprzedaz:typ",1)
    end
    marker = mkr
    local t=createElement("text")
    setElementData(t,"name", v[1])
    setElementPosition(t,v[2],v[3],v[4]+1.7)
    setElementDimension(t, v[6] or 0)
    setElementInterior(t, v[5] or 0)
    addEventHandler ("onMarkerHit", mkr, function(el,md)
    if getElementType(el) ~= "player" then return end
    if getPedOccupiedVehicle(el) then
        outputChatBox("* Najpierw wyjd? z pojazdu.", el , 255, 0, 0)
        return
    end
    outputChatBox("* Aby sprzeda? pojazd: ", el)
    outputChatBox("* Wpisz /sprzedajpojazd <nick/ID> <id pojazdu> <cena>", el)
    local typ = getElementData(mkr,"sprzedaz:typ")
    if typ == 2 then
    end
    setElementData(el, "sprzedaz:pojazdow", true)
    setElementData(el, "sprzedaz:typ", typ)
end)
    addEventHandler ("onMarkerLeave", mkr, function(el,md)
    if getElementType(el) ~= "player" then return end
    if getPedOccupiedVehicle(el) then
        outputChatBox("* Najpierw wyjd? z pojazdu.", el , 255, 0, 0)
        return
    end
    outputChatBox("* Wyszedles z markera ", el)
    setElementData(el, "sprzedaz:pojazdow", false)
    setElementData(el, "sprzedaz:typ", false)
end)
end

function checkVehiclePlayer(plr)
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles")
    local number=0
    for i,v in ipairs(result) do
        if result[1].ownedPlayer == getElementData(plr,"player:uid") then
            number=number+1
        end
    end
    return number
end

local function pokazOperacje(plr,typ)
    if not typ then return end
    if not sprzedazPojazdu[plr] then return end
    local veh=sprzedazPojazdu[plr][3]
    outputChatBox("* Otrzyma?e?/a? ofert? sprzeda?y pojazdu "..getVehicleNameFromModel(getVehicleModel(veh)).." za cen? "..sprzedazPojazdu[plr][4], plr, 255, 255, 0)
    if typ == 1 then
    end
    outputChatBox("* ID: "..getElementData(veh,"vehicle:id").." | Przebieg: "..getElementData(veh,"vehicle:mileage").."| Pojemno??: "..getElementData(veh,"Pojemnosc:silnika").."", plr, 255, 255, 0)
    outputChatBox("* Aby potwierdzi? zakup prosz? wpisz /zakup, masz 20 sekund", plr, 255, 255, 0)
    setElementData(plr,"sprzedaz:typ",typ)
    timer=setTimer(function()
        sprzedazPojazdu[plr]=nil
        outputChatBox("* Transakcja zosta?a anulowana.", plr, 255, 0, 0)
        removeCommandHandler("zakup", akceptujTransakcje)
    end, 20000, 1)
    addCommandHandler("zakup", akceptujTransakcje)
end

function akceptujTransakcje(plr,cmd)
    if not sprzedazPojazdu[plr] then return end
    local veh=sprzedazPojazdu[plr][3]
    local typ=getElementData(plr,"sprzedaz:typ")
    if not isElement(veh) then outputChatBox("* Pojazd w przecho",plr) return end
    local cost=sprzedazPojazdu[plr][4]
    local cost2=sprzedazPojazdu[plr][4]
    local podatek = 0
    if typ == 1 then
    cost=sprzedazPojazdu[plr][4]+(math.floor(sprzedazPojazdu[plr][4]*0.02))
    cost2=sprzedazPojazdu[plr][4]-(math.floor(sprzedazPojazdu[plr][4]*0.05))
    podatek = math.floor(sprzedazPojazdu[plr][4]*0.02) + math.floor(sprzedazPojazdu[plr][4]*0.05)
    end
    local target=sprzedazPojazdu[plr][1]
    if cost < 0 then
        outputChatBox("* Cena jest nieprawid?owa.", plr)
        return
    end
    if tonumber(cost) > getPlayerMoney(plr) then
        outputChatBox(" Nie posiadasz tyle got?wki.", plr)
        return
    end
    --givePlayerMoney(target, cost2)
    --takePlayerMoney(plr, cost)
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=?", target, cost*100*0.97)
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=3191", plr, cost*100*0.03)
    killTimer(timer)
    outputChatBox(" Sprzeda? przeprowadzona pomy?lnie.", plr)
    outputChatBox(" Sprzeda? przeprowadzona pomy?lnie.", target)
    removeCommandHandler("akceptuj", akceptujTransakcje) -- usuwanie komendy
    wykonajZapytanie(veh,plr,getElementData(plr,"player:uid"),getElementData(veh,"vehicle:id"),target,getElementData(target,"player:uid")) -- do bazy danych ustawiamy od razu
end

function wykonajZapytanie(veh,plr,uid,vid,target,tuid)
    if isElement(veh) then
    setElementData(veh,"vehicle:ownedGroup", 0)
    setElementData(veh,"vehicle:rent", 0)
    setElementData(veh,"vehicle:ownedPlayer",getElementData(plr,"player:uid"))
    end
    exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET ownedPlayer=? AND ownedGroup=0 AND rent=0 WHERE id=?", uid, vid)
    local text = string.format("Sprzedaz Auta | "..getPlayerName(target):gsub("#%x%x%x%x%x%x","" ).."("..getElementData(target,"player:uid")..") >>>"..vid.." "..getVehicleName(veh).."<<< dla "..getPlayerName(plr):gsub("#%x%x%x%x%x%x","" ).."("..getElementData(plr,"player:uid")..") >>>CENA: "..sprzedazPojazdu[plr][4])
    triggerEvent("admin:logs", root, text)
    triggerClientEvent("onDebugMessage", resourceRoot, text,5, "Sprzeda? auta")
    triggerEvent("admin:addText", resourceRoot, RGBToHex(255,255,0)..text..RGBToHex(255,255,255),math.random(0,99))
end

addCommandHandler(cmd, function(plr,_,cel,id,cost)
    if getElementData(plr,"sprzedaz:owner") and getElementData(plr,"sprzedaz:owner") ~= getElementData(plr,"player:uid") then outputChatBox("*Sprzeda? mo?liwa tylko dla w?asciciela komisu!",plr) return end
    if getElementData(plr, "sprzedaz:pojazdow")== false then
        outputChatBox(" Nie jeste? w miejscu przeznaczonym do tego.", plr, 255, 0, 0)
        return
    end
    costt=tonumber(cost)
    if not cel or not costt then
        outputChatBox("* U?ycie: /sprzedajpojazd <nick/ID> <id pojazdu> <cena>", plr)
        return
    end
    local target=exports["ogrpg-core"]:findPlayer(plr,cel)
    if not target then
        outputChatBox(" Nie znaleziono podanego gracza.", plr, 255, 0, 0)
        return
    end
    if getElementData(target, "sprzedaz:pojazdow")== false then
        outputChatBox("*Gracz jest w miejscu przeznaczonym do tego.", plr, 255, 0, 0)
        return
    end
    if tonumber(costt) < 0 then
        outputChatBox(" Poda?e? nieprawid?ow? warto??.", plr, 255, 0, 0)
        return
    end
    local typ = getElementData(plr,"sprzedaz:typ")
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE id=? AND parking=1 LIMIT 1;", id)
    if result and #result > 0 then
        outputChatBox("* Pojazd znajduje na parkingu, nie mo?esz go sprzeda?.", plr, 255, 0, 0)
        return
    end
    for _,vehicle in ipairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(vehicle,"vehicle:id")) == tonumber(id) then
            if tonumber(getElementData(vehicle,"vehicle:ownedPlayer")) ~= tonumber(getElementData(plr,"player:uid")) then
                outputChatBox("* Nie jeste? w?a?cicielem pojazdu.", plr, 255, 0, 0)
                return
            end
            sprzedazPojazdu[target]={plr,target,vehicle,costt,typ}
        end
    end
    pokazOperacje(target,typ)
    outputChatBox("* Pomy?lnie wys?ano ofert? o sprzeda? pojazdu.", plr)
end)

function vehinfo(plr)
local car=getPedOccupiedVehicle(plr)
if not car then outputChatBox("Nie jeste? w poje?dzie!", plr, 255, 255, 255) return end
outputChatBox("Informacje dot. tego pojazdu:", plr, 255, 255, 255)
local baza=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE id=?", getElementData(car, "vehicle:id"))
for i,vehicle in pairs(baza) do
mk1=vehicle['mk1']
mk2=vehicle['mk2']
rh=vehicle['rh']
naped=vehicle['naped']
end
if tonumber(mk1) == 1 then us1="TAK" else us1="NIE" end
if tonumber(mk2) == 1 then us2="TAK" else us2="NIE" end
if tonumber(rh) == 1 then rh1="TAK" else rh1="NIE" end
if tonumber(naped) == 1 then naped="TAK" else naped="NIE" end
outputChatBox("US1: "..us1.." | US2: "..us2.." | GZ: "..rh1.." | 4x4: "..naped.."", plr, 255, 255,255)
end
addCommandHandler("v.info", vehinfo)


Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 20:12


Adaskokieblasko







Wiek: 23
Na forum: 3095 dni
Posty: 101

Piwa: 18

Respekt: 100
Respekt: 100


    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=?", target, cost*100*0.97)
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=3191", plr, cost*100*0.03)
zmie? na

 local query1 =    exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=?", target, cost*100*0.97)
   local query2 =  exports['ogrpg-db']:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+? WHERE id=3191", plr, cost*100*0.03)
outputDebugString("Query1: " ..query1..)
outputDebugString("Query2: " ..query2..) 

I zobacz czy wszystko jest uzupe?nione poprzez wykonanie funkcji kt?ra posiada te Exporty

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 20:39


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Wog?le nie pokazuje markeru.
DB3
Kod:

unexpected symbol near ')'

170linijka czyli
    outputDebugString("Query2: " ..query2..) 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 20:52


Adaskokieblasko







Wiek: 23
Na forum: 3095 dni
Posty: 101

Piwa: 18

Respekt: 100
Respekt: 100

MB

outputDebugString("Query1: " ..query1.."")
outputDebugString("Query2: " ..query2.."") 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 23:16


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Po co w pierwszej linijce sprawdzasz ID gracza a w drugim nagle sam narzucasz ID? o co chodzi?

Z?a kolejno?? argument?w, tam wskazujesz gracza a nie liczb?. No i ID te? ?le wskazujesz.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 00:42


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Rozumiem to jak to ma by? ? Bo tak ?rednio kumam

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 08:28


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Zamiast ceny pojazdu przekazujesz zmienn? gracza.
W ID gracza z bazy przekazujesz cen? pojazdu.

Postaw piwo autorowi tego posta
 

 
Tagi: exporty
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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