Auction System na Vocation

Status
Zamknięty.

captain2009

User
Zarejestrowany
Dołączył
Sierpień 5, 2009
Posty
14
Liczba reakcji
1
Witam posiadam skrypt Auction System :) wszystko dzia?a idealnie, po za tym, ?e u mnie na OTS zamierzony jest Rook :D i wola?bym, ?eby ludzie z maina nie przesy?ali sobie pieniedzy etc. na Rook. Dlatego wpad?em na pomys?, by ten skrypt by? dla Profesji wszystkich oprocz NONE. Da?o by si? zrobi?? Napewno pomog?o by to nie tylko mi. A je?eli taki temat istnieje to przepraszam, ale nie znalaz?em.
Kod:
local config = {
        levelRequiredToAdd = 1,
        maxOffersPerPlayer = 5,
        SendOffersOnlyInPZ = true,
        blocked_items = {10309}
        }
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zla komenda.")
                return true
        end
        local t = string.explode(param, ",")
        if(t[1] == "add") then
                if((not t[2]) or (not t[3]) or (not t[4])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zla Komenda.")
                        return true
                end
                if(not tonumber(t[3]) or (not tonumber(t[4]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Podales zla cene za tak duza ilosc itemow.")
                        return true
                end
                if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cena, badz ilosc jest za duza.")
                        return true
                end
                local item = getItemIdByName(t[2], false)
                if(not item) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Nie ma itemu o takiej nazwie.")
                        return true
                end
                if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Musisz miec przynajmniej (" .. config.levelRequiredToAdd .. ") level.")
                        return true
                end
                if(isInArray(config.blocked_items, item)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ten Item jest zablokowany.")
                        return true
                end
                if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Nie masz tego itemu(s).")
                        return true
                end
                local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
                if(check:getID() == -1) then
                elseif(check:getRows(true) >= config.maxOffersPerPlayer) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Nie mozesz dodac wiecej ofert max to (max. " .. config.maxOffersPerPlayer .. ")")
                        return true
                end
                if(config.SendOffersOnlyInPZ) then    
                        if(not getTilePzInfo(getPlayerPosition(cid))) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Musisz byc w Protection Zone:PZ.")
                                return true
                        end
                end
                if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Podaj numer wiekszy niz 0.")
                        return true
                end
                local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
                doPlayerRemoveItem(cid, item, itemcount)
                db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Dodales " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps do oferty.")
        end
        if(t[1] == "buy") then
                if(not tonumber(t[2])) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
                        return true
                end
                local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
                if(buy:getID() ~= -1) then
                        if(getPlayerMoney(cid) < buy:getDataInt("cost")) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Nie masz tyle gps.")
                                buy:free()
                                return true
                        end
                        if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Nie mozesz kupic swoich przedmiotow.")
                                buy:free()
                                return true
                        end
                        if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Probujesz kupic o wadze " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. a ty posiadzasz " .. getPlayerFreeCap(cid) .. " oz. wolnego udzwigu. Odloz troche itemow i sprobuj ponownie.")
                                buy:free()
                                return true
                        end
                        if(isItemStackable((buy:getDataString("item_id")))) then
                                doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
                        else
                                for i = 1, buy:getDataInt("count") do
                                        doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
                                end
                        end
                        doPlayerRemoveMoney(cid, buy:getDataInt("cost"))
                        db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Kupiles " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " za " .. buy:getDataInt("cost") .. " gps!")
                        db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
                        buy:free()
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Bledne ID.")
                end
        end
        if(t[1] == "remove") then
                if((not tonumber(t[2]))) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Bledne ID.")
                        return true
                end
                                if(config.SendOffersOnlyInPZ) then    
                                        if(not getTilePzInfo(getPlayerPosition(cid))) then
                                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Musisz byc w PZ.")
                                                return true
                                        end
                end
                local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")        
                if(delete:getID() ~= -1) then
                        if(getPlayerGUID(cid) == delete:getDataInt("player")) then
                                db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                                if(isItemStackable(delete:getDataString("item_id"))) then
                                        doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
                                else
                                        for i = 1, delete:getDataInt("count") do
                                                doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
                                        end
                                end
                                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Usunales oferte z aukcji.")
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "To nie twoja oferta!")
                        end
                delete:free()
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Bledne ID.")
                end
        end
        if(t[1] == "withdraw") then
                local balance = db.getResult("SELECT `auction_balance` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
                if(balance:getDataInt("auction_balance") < 1) then
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Nie masz tyle pieniedzy.")
                        balance:free()
                        return true
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Dostales " .. balance:getDataInt("auction_balance") .. " gps z udanej aukcji!")
                doPlayerAddMoney(cid, balance:getDataInt("auction_balance"))
                db.executeQuery("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
                balance:free()
        end
        return true
end
@Edit
Jeszcze 1 mniej wa?ne :D:
Czy skrypt da?o by si? zrobi? tak, ?eby poprostu kopiowa? dany Item (wszystkie jego cechy) i gdy juz skopiuje do bazy danych to usuwa od gracza, a gdy kto? go kupuje, to wszystkie jego cechy s? takie same jak u gracza sprzedaj?cego? Wiem, ?e to zagmatwane, ale pro?ciej m?wi?c:
Posiadam Upgrade System, kt?ry ulepsza itemki... Jednak przy sprzedawaniu takiego ulepszonego itemu na aukcji item po kupieniu, jest nieulepszony. Czy da si? to tak zmieni?, by by? tak somo ulepszony jak przed kupnem?
Domy?lam si?, ?e Skrypt dot. aukcji sprawdza id itemu usuwa go u gracza zapisuje w bazie danych id postaci itd... a potem "sprzedaje" go dla gracza dajac mu nowy item o danym ID... wiec to raczej malo wykonalne, by ktos go specjalnie przerobil ;/ :( i to za darmo :P
@Edit 2
:D zauwazy?em, ?e upgrade system bazuje (chyba) na Uid ;D tak wi?c 3 pytanie: czy jest mo?liwo?? przerobienia 1 skryptu tak, by zapisywa? Uid ?
Refresh
 
Odp: Auction System na Vocation

witam :P heh poradzilem sobie z tym patrz?c na inne skrypty pomyslalem sobie czemu by nie wstawic funkcji "jesli" :D i o to rezultat :D
wystarczylo dodac na poczatku skryptu
Kod:
local voc = 0
Potem w kazdym sayu dodac:
Kod:
elseif(getPlayerVocation(cid) > voc) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Nie jestes na Mainie.")
                        return true
:)
 
Ostatnia edycja:
Status
Zamknięty.
Back
Do góry