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

Wysłany: 2018-07-04, 13:48


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Witam . Mam problem z jailem na mysql , nie ma ?adnych warto?ci w tabeli po wpisaniu komendy i gracz zostaje uwi?ziony i jednocze?nie wypuszczony z wi?zienie , oto kod :

local cub = createColCuboid(-2452.44, 3742.13, 300.57-1, 19, 15, 0)

function u(e)
getElementData(e, "dbid")
end

local cele = { -- x,y,z,int,dim
{-2445.87, 3744.52, 300.57,0,0},
{-2445.26, 3738.51, 300.57,0,0},
{-2458.32, 3739.40, 300.57,0,0},
{-2458.33, 3745.95, 300.57,0,0},
}
local x,y,z = -2451.67, 3757.35, 300.57
local function wypusc(plr)
setElementDimension(plr,0)
setElementInterior(plr,0)
setElementPosition(plr,x,y,z)
outputChatBox("Zosta?e? wypuszczony z wi?zienia.",plr, 255, 255, 255)
end

function getPlayerName2(plr)
if not plr then return end
return getPlayerName(plr):gsub("#%x%x%x%x%x%x","")
end

local function sprawdz(plr)
if not plr then return end
if not getElementData(plr,"dbid") then return end
local x = exports.mysql:wykonaj("SELECT * FROM jail WHERE Serial=?",getPlayerSerial(plr))
if not x or #x < 1 then return end
local x2=exports.mysql:wykonaj("SELECT Termin FROM jail WHERE Serial=? and Termin < NOW()",getPlayerSerial(plr))
if x2 and #x2 > 0 then
exports.mysql:wykonaj("DELETE FROM jail WHERE Serial=?", getPlayerSerial(plr))
wypusc(plr)
return end
if isElementWithinColShape(plr,cub) then return end
setElementPosition(plr,cele[x[1].Cela][1],cele[x[1].Cela][2],cele[x[1].Cela][3])
setElementDimension(plr, 0)
end

local function sprawdzczas(plr)
if not plr then return end
if not getElementData(plr,"dbid") then return end
local x = exports.mysql:wykonaj("SELECT * FROM jail WHERE Serial=?",getPlayerSerial(plr))
if not x or #x < 1 then return end
local x2=exports.mysql:wykonaj("SELECT Termin FROM jail WHERE Serial=? and Termin < NOW()",getPlayerSerial(plr))
if x2 and #x2 > 0 then
exports.mysql:wykonaj("DELETE FROM jail WHERE Serial=?", getPlayerSerial(plr))
wypusc(plr)
return end
outputChatBox("Jeste? uwi?ziony w wi?zieniu do: #ff000"..x[1].Termin.." #ffffffza: #ff0000"..x[1].Powod.."", plr, 255, 255, 255, true)
end

function ajotceju(plr,cmd,target,ile,typ,zaco)
    if getElementData(plr, "frakcja")=="KGP" then
        if not target or not ile or not typ or not zaco then
        outputChatBox("U?ycie: /jail <gracz/ID> <czas> <m/h> <pow?d>", plr, 255, 255, 255)
        return
    end
    local osoba = findPlayer(plr, target)
    if not osoba then
        outputChatBox("Nie znaleziono podanego gracza.", plr, 255, 255, 255)
        return
    end
    x1,x2,x3 = getElementPosition(plr)
    y1,y2,y3 = getElementPosition(osoba)
    dystans = getDistanceBetweenPoints3D(x1,x2,x3,y1,y2,y3)
    if dystans > 20.0 then outputChatBox("Ten gracz jest za daleko!", plr, 255, 255, 255) return end
    local cela=math.random(1, #cele)
    if typ=="m" or typ=="h" then
        if typ=="m"then
            exports.mysql:wykonaj("INSERT INTO jail (Serial,Termin,Cela,Powod) VALUES (?,NOW() + INTERVAL ?? minute,??,?)", getPlayerSerial(osoba), ile,cela, zaco)
            outputChatBox("Zosta?e? uwi?ziony w wi?zieniu przez #ff0000"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").." #ffffffza #ff0000"..zaco.." #ffffffna #ff0000"..ile.."#ffffff minut(-a/-y)", osoba, 255, 255, 255)
            outputChatBox("Uwi?ziono gracza "..getPlayerName(osoba):gsub("#%x%x%x%x%x%x","").." w wi?zieniu za "..zaco.." na "..ile.." minut(-a/-y)", plr, 255, 255, 255)
            sprawdz(plr)
        end
        if typ=="h" then
            exports.mysql:wykonaj("INSERT INTO jail (Serial,Termin,Cela,Powod) VALUES (?,NOW() + INTERVAL ?? hour,??,?)", getPlayerSerial(osoba), ile,cela, zaco)
            outputChatBox("Zosta?e? uwi?ziony w wi?zieniu przez #ff0000"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").." #ffffffza #ff0000"..zaco.." #ffffffna #ff0000"..ile.."#ffffff godzin(a/y)", osoba, 255, 255, 255)
            outputChatBox("Uwi?ziono gracza "..getPlayerName(osoba):gsub("#%x%x%x%x%x%x","").." w wi?zieniu za "..zaco.." na "..ile.." godzin(-a/-y)", plr, 255, 255, 255)
            sprawdz(plr)
        end
    end
    sprawdz(plr)
    cela=math.random(1, #cele)
    sprawdzczas(plr)
end
end
addCommandHandler("jail", ajotceju)

function unaj(plr,cmd,target)
if getElementData(plr, "frakcja")=="KGP" then
    local osoba = findPlayer(plr, target)
    if not osoba then
        outputChatBox("Nie znaleziono podanego gracza.", plr, 255, 255, 255)
        return
    end
    local jebnijsie=exports.mysql:wykonaj("SELECT Termin FROM jail WHERE Serial=? and Termin > NOW()",getPlayerSerial(osoba))
    if jebnijsie and #jebnijsie <= 0 then outputChatBox("Ten gracz nie jest w wi?zieniu! ("..getPlayerName(osoba)..")", plr,255,255,255) return end
    exports.mysql:wykonaj("DELETE FROM jail WHERE Serial=?", getPlayerSerial(osoba))
    outputChatBox("Gracz zosta? uwolniony z wi?zienia.", plr, 255, 255, 255)
    sprawdz(osoba)
    wypusc(osoba)
end
end
addCommandHandler("unjail", unaj)

setTimer(function()
for _,p in pairs(getElementsByType("player")) do
sprawdz(p)
end
 end,5000,0)

function spawn()
local x=exports.mysql:wykonaj("SELECT Termin FROM jail WHERE Serial=? and Termin > NOW()",getPlayerSerial(source))
if x and #x <= 0 then return end
sprawdzczas(source)
end
addEventHandler("onPlayerSpawn", getRootElement(), spawn)

function findPlayer(plr, cel)
    local target = nil
    if (tonumber(cel) ~= nil) then
        target = getElementByID("p"..cel)
    else
        for _,thePlayer in ipairs(getElementsByType("player")) do
            if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), cel:lower(), 1, true) then
                if (target) then
                    outputChatBox("Znaleziono wiecej niz jednego gracza o pasujacym nicku, podaj wiecej liter.", plr)
                    return nil
                end
                target=thePlayer
            end
        end
    end
    return target
end

Dzi?ki za udzielenie pomocy . I stawiam :piwo:

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 14:02


AppleSir

Majster LUA






Wiek: 28
Na forum: 3186 dni
Posty: 19
Nick w MP: Przybysz



Respekt: 45,3

sadze ?e tabela

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 14:06


PatryKK.

Emeryt LUA






Wiek: 27
Na forum: 3202 dni
Posty: 1059
Nick w MP: PatryKK.

Piwa: 2331

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

http://gtao.pl/skrypt-z-j...?highlight=jail taki sam kod, wi?c zobacz tutaj.

Podpis
GG:75080675
- ✔
- ✔
- ✔
- ✔

Aktualny projekt: BRAK
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 15:17


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Ten link w niczym nie pom?g? bo u mnie tak jakby cz??ciowo dzia?a , komendy dzia?aj? ale w tym problem ze jak wpisz? /jail id czas jednostka powod to gracz zostaje uwi??iony i wypuszczony , s? 3 outputChatBox'y normalnie . Brak w db3 .

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 15:58


PatryKK.

Emeryt LUA






Wiek: 27
Na forum: 3202 dni
Posty: 1059
Nick w MP: PatryKK.

Piwa: 2331

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

A jak wpiszesz ten /jail to dodaje Ciebie do mysql?

Podpis
GG:75080675
- ✔
- ✔
- ✔
- ✔

Aktualny projekt: BRAK
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 16:25


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

W?a?nie w tym problem , ?e nie dodaje

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 16:27


PatryKK.

Emeryt LUA






Wiek: 27
Na forum: 3202 dni
Posty: 1059
Nick w MP: PatryKK.

Piwa: 2331

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

A masz podpi?ta baz? danych pod serwer? I czy masz wgrana struktur? SQL?

Podpis
GG:75080675
- ✔
- ✔
- ✔
- ✔

Aktualny projekt: BRAK
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 22:13


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Wszystko mam .

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Tagi: jail :: mysql
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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