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

Wysłany: 2019-08-25, 17:56


DaVeCS

Mapper






Wiek: 31
Na forum: 3386 dni
Posty: 193
Nick w MP: DaVe

Piwa: 59

Respekt: 70,5

Witam ot?? mam problem ze skryptem na sprzeda? pojazd?w, a mianowicie skrypt jest zrobiony tak ?e pobiera i daje got?wk? do konta gracza, a ja chcia?bym zrobi? aby dodawa?o/zabiera?o do bankomatu, lecz nie wiem jak, co i gdzie wstawi?.

Tutaj umieszczam kod
--[[
Developed by Yolos and Split
All rights reserved!
You cannot use this without permission!
--]]

function RGBToHex(redgreenbluealpha)
    if((red or red 255 or green or green 255 or blue or blue 255) or (alpha and (alpha or alpha 255))) then
        return nil
    end
    if(alphathen
        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=-- tylko gracz mo?e kupitrzy 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"20128255255)
setElementDimension(mkrv.dimension or 0)
setElementInterior(mkrv.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(tv.dimension or 0)
setElementInterior(tv.interior or 0)
    addEventHandler ("onMarkerHit"mkr, function(el,md)
    if getElementType(el) ~= "player" then return end
    if getPedOccupiedVehicle(elthen 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
    outputChatBox("* Podatek sprzeda?y pojazdu nie obowi?zuje w komisach :) "el)
        else
    outputChatBox("* Podatek sprzeda?y pojazdu obowi?zuje kupuj?cego(2%) i sprzedaj?cego(5%) "el)
    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(elthen 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={
    -- Opis nad markeremx,y,zintdimjestkomisem(true or false)
    --{"Gie?da LS\nSprzeda? pojazd?w"2527.78,-1290.79,1048.29,2,}, -- gielda ls
    {"Sprzeda? pojazd?w"46.89,-75.58,-13.2010}, -- urzad ls
    --{"Gie?da LV\nSprzeda? pojazd?w"2527.78,-1290.79,1048.29,2,2}, -- gielda lv
  --  {"Sprzeda? w komisie"363.39187.291008.38,3,0,true},
}

for i,v in pairs(pozycjeMarkerow) do
    local mkr=createMarker(v[2], v[3], v[4]-0.90"cylinder"20128255255)
    setElementDimension(mkrv[6] or 0)
    setElementInterior(mkrv[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])
    setElementDimension(tv[6] or 0)
    setElementInterior(tv[5] or 0)
    addEventHandler ("onMarkerHit"mkr, function(el,md)
    if getElementType(el) ~= "player" then return end
    if getPedOccupiedVehicle(elthen 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
    outputChatBox("* Podatek sprzeda?y pojazdu nie obowi?zuje w komisach :) "el)
        else
    outputChatBox("* Podatek sprzeda?y pojazdu obowi?zuje kupuj?cego(2%) i sprzedaj?cego(5%) "el)
    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(elthen return end
    outputChatBox("* Wyszedles z markera "el)
    setElementData(el"sprzedaz:pojazdow"false)
    setElementData(el"sprzedaz:typ"false)
end)
end


function checkVehiclePlayer(plr)
    -- Pobieramy tabeli nast?pnie zwracamy j?
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles")
    local number=0
    -- Uruchamiamy p?tlspradzaj?cpojazdy z bazy danych i
    -- por?wnujemy w?a?ciciela z UID osoby kt?ra chce zakupi?
    for i,v in ipairs(result) do
        if result[1].ownedPlayer == getElementData(plr,"player:uid"then
            number=number+1
        end
    end
    -- Zwracamy ilo?? pojazd?w gracza je?eli nie ma zwr?ci
    -- mu false.
    return number
end

local function pokazOperacje(plr,typ)
    if not typ then return end
    if not sprzedazPojazdu[plrthen return end
    local veh=sprzedazPojazdu[plr][3] -- sprawdzanie tablicy
    outputChatBox("* Otrzyma?e?/a? ofert? sprzeda?y pojazdu "..getVehicleNameFromModel(getVehicleModel(veh)).." za cen? "..sprzedazPojazdu[plr][4], plr2552550)
    if typ == 1 then
    outputChatBox("* Podatek kt?ry zap?acisz wynosi: "..math.floor(sprzedazPojazdu[plr][4]*0.02), plr2552550)
    end
    outputChatBox("* ID: "..getElementData(veh,"vehicle:id").." | Przebieg: "..getElementData(veh,"vehicle:mileage")..""plr2552550)
    outputChatBox("* Aby potwierdzi? zakup prosz? wpisz /zakup, masz 20 sekund"plr2552550)
    --outputDebugString("xd:"..typ)
    setElementData(plr,"sprzedaz:typ",typ)
    timer=setTimer(function()
        sprzedazPojazdu[plr]=nil
        outputChatBox("* Transakcja zosta?a anulowana."plr25500)
        removeCommandHandler("zakup"akceptujTransakcje) -- usuwanie komendy
    end200001)
    addCommandHandler("zakup"akceptujTransakcje) -- tworzenie komendy
end

function akceptujTransakcje(plr,cmd)
    if not sprzedazPojazdu[plrthen return end
    local veh=sprzedazPojazdu[plr][3]
    local typ=getElementData(plr,"sprzedaz:typ")
    --outputDebugString("x131:"..typ)
    if not isElement(vehthen 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(plrthen
        outputChatBox(" Nie posiadasz tyle got?wki."plr)
        return
    end
    givePlayerMoney(targetcost2)
    takePlayerMoney(plrcost)
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_donates SET money=money+?? WHERE type=?",podatek,"gielda")
    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(vehthen
    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=?"uidvid)
    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"roottext)
 --   triggerClientEvent(root"admin:addText"rootpm_text)
    triggerClientEvent("onDebugMessage"resourceRoottext,5"Sprzeda? auta")
    triggerEvent("admin:addText"resourceRootRGBToHex(255,255,0)..text..RGBToHex(255,255,255),math.random(0,99))
--    triggerClientEvent(root"admin:addText"root, )
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."plr25500)
        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."plr25500)
        return
    end
    if getElementData(target"sprzedaz:pojazdow")== false then
        outputChatBox("*Gracz jest w miejscu przeznaczonym do tego."plr25500)
        return
    end
    if tonumber(costt) < 0 then
        outputChatBox(" Poda?e? nieprawid?ow? warto??."plr25500)
        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?."plr25500)
        return
    end
    for _,vehicle in ipairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(vehicle,"vehicle:id")) == tonumber(idthen
            if tonumber(getElementData(vehicle,"vehicle:ownedPlayer")) ~= tonumber(getElementData(plr,"player:uid")) then
                outputChatBox("* Nie jeste? w?a?cicielem pojazdu."plr25500)
                return
            end
            sprzedazPojazdu[target]={plr,target,vehicle,costt,typ}
        end
    end
    -- Warunek sprawdzaj?ca ile gracz ma pojazd?wje?eli bedzie mia?
    -- wi?cej niLIMIT na g?rze to wy?wietli mu sikomunikat.
    --[[if getElementData(target,"player:premium")==false then
    if checkVehiclePlayer(target) and checkVehiclePlayer(target) >= LIMIT then
        --outputChatBox("* Maksymalnie ten gracz mo?e mie?: "..LIMIT.." pojazd?w"plr25500)
        return
    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!"plr255255255) return end
outputChatBox("Informacje dot. tego pojazdu:"plr255255255)
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("MK1: "..us1.." | MK2: "..us2.." | GZ: "..rh1.." | Nap?d 4x4: "..naped..""plr255255,255)
end
addCommandHandler("v.info"vehinfo)


Wiem ?e musz? wstawi? te dwie linijki kodu lecz nie wiem jak :(

exports["ogrpg-db"]:dbGet("SELECT bank_money FROM ogrpg_users WHERE id=" .. getElementData(plr"player:uid") .. " LIMIT 1")


i

exports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET bank_money=bank_money-" .. cost .. " WHERE id=" .. uid .. " LIMIT 1")


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-25, 22:04


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Uwaga, podaj? rozwi?zanie:
musisz to wstawi? tam, gdzie wykonuje si? akcja sprzeda?y pojazdu. Pewnie jest to komenda (np. /kup.pojazd) czy jako? tak.
Szukaj: "Sprzeda? przeprowadzona pomy?lnie"

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-26, 09:42


DaVeCS

Mapper






Wiek: 31
Na forum: 3386 dni
Posty: 193
Nick w MP: DaVe

Piwa: 59

Respekt: 70,5

A m?g?by? mi pom?c wstawi? to do kodu, gdy? pr?bowa?em tak jak wy?ej napisa?e? i nie dzia?a :( Szczerze nie wiem co ?le zrobi?em.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-26, 09:51


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Pokaz kod po swoich zmianach. Troche dziwne, chcesz stawiac serwer to musisz ca?y kod przeanalizowa? ?eby wiedzie? potem co i jak. Zrob tak samo tutaj, zacznij od wyszukania komendy do tego co chcesz zmieni?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-26, 09:58


DaVeCS

Mapper






Wiek: 31
Na forum: 3386 dni
Posty: 193
Nick w MP: DaVe

Piwa: 59

Respekt: 70,5

function akceptujTransakcje(plr,cmd)
    if not sprzedazPojazdu[plrthen return end
    local veh=sprzedazPojazdu[plr][3]
    local typ=getElementData(plr,"sprzedaz:typ")
    --outputDebugString("x131:"..typ)
    if not isElement(vehthen 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
    local uid getElementData(plr,"player:uid"then
    if tonumber(cost) > exports["ogrpg-db"]:dbGet("SELECT bank_money FROM ogrpg_users WHERE id=" .. getElementData(plr"player:uid") .. " LIMIT 1")
        outputChatBox(" Nie posiadasz tyle got?wki."plr)
        return
    end
    exports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+" .. cost2 .. " WHERE id=" .. uid .. " LIMIT 1")
    exports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET bank_money=bank_money-" .. cost .. " WHERE id=" .. uid .. " LIMIT 1")
    exports['ogrpg-db']:dbSet("UPDATE ogrpg_donates SET money=money+?? WHERE type=?",podatek,"gielda")
    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


[ Dodano: 2019-08-27, 12:55 ]
Pomo?e kto??

Postaw piwo autorowi tego posta
 

 
Tagi: sprzedaż :: pojazdów
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