Wysłany: 2020-07-06, 01:07
filip0985
Początkujący w LUA
Wiek: 22 Na forum: 2755 dni Posty: 112
Piwa : 13
Witam chcia?em stworzy? panel jail. Na serwerze mam og?lnie komend? pod jail /jail <gracz/ID> <czas> <m/h> <pow?d> i teraz chcia? bym to podpi?? pod przyciski.
w jaki spos?b to wykona?!?
Zdj?cie panelu: https://imgur.com/a/KRBPoMR
Więcej szczegółów
Wystawiono 1 piw(a):lotka_
Wysłany: 2020-07-06, 01:10
PatryKK.
Emeryt LUA
Wiek: 26 Na forum: 3061 dni Posty: 1060
Nick w MP: PatryKK.
Piwa : 2322
Wysłany: 2020-07-06, 01:21
filip0985
Początkujący w LUA
Wiek: 22 Na forum: 2755 dni Posty: 112
Piwa : 13
Kod:
Code na panel
local gui = {}
gui.window = guiCreateWindow(0.28, 0.20, 0.47, 0.60, "Panel-Jail", true)
guiWindowSetMovable(gui.window, false)
guiWindowSetSizable(gui.window, false)
guiSetVisible(gui.window, false)
gui.button = guiCreateButton(0.06, 0.10, 0.39, 0.13, "Potwierdz", true, gui.window)
gui.button2 = guiCreateButton(0.06, 0.25, 0.39, 0.13, "Zamknij", true, gui.window)
gui.edit1 = guiCreateEdit(0.07, 0.52, 0.38, 0.07, "", true, gui.window)
gui.edit2 = guiCreateEdit(0.07, 0.62, 0.38, 0.07, "", true, gui.window)
gui.text = guiCreateLabel(0.07, 0.60, 0.38, 0.02, "Czas..", true, gui.window)
gui.text = guiCreateLabel(0.07, 0.50, 0.38, 0.02, "Nick..", true, gui.window)
gui.edit3 = guiCreateEdit(0.07, 0.72, 0.38, 0.07, "", true, gui.window)
gui.text = guiCreateLabel(62, 449, 344, 18, "Jednostka m/h..", false, gui.window)
gui.edit4 = guiCreateEdit(0.07, 0.82, 0.38, 0.07, "", true, gui.window)
gui.text = guiCreateLabel(62, 515, 344, 18, "Pow?d..", false, gui.window)
addEvent("marker", true)
addEventHandler("marker", getRootElement(), function()
guiSetVisible(gui.window, true)
showCursor(true)
end)
local function zamknij()
if guiGetVisible(gui.window) then
guiSetVisible(gui.window, false)
showCursor (false)
end
end
addEventHandler("onClientGUIClick", gui.button2, zamknij, false)
addEventHandler("onClientColShapeLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
zamknij()
showCursor (false,false)
end)
end
addEventHandler("onClientGUIClick",gui.button,jail, false)
Kod:
Code na komende /jail
local cub = createColCuboid(-1596.12,714.14,907.27, 22.25, 30, 10)
function u(e)
getElementData(e, "player:sid")
end
local cele = { -- x,y,z,int,dim
{-1586.43,708.69,907.27,0,0},
{-1587.85,724.61,907.27,0,0},
{-1595.65,709.39,907.27,0,0},
{-1608.95,709.26,907.27,0,0},
{-1608.35,725.07,907.27,0,0},
}
local x,y,z = -1585.38,714.82,907.27
local m=createElement("textorg")
setElementData(m, "name", "/jail\n/unjail\n(dla SAPD)")
setElementData(m, "scale", 1.3)
setElementPosition(m, -1585.38,714.82,907.27)
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,"player:sid") then return end
local x = exports['pystories-db']:dbGet("SELECT * FROM aj WHERE Serial=?",getPlayerSerial(plr))
if not x or #x < 1 then return end
local x2=exports['pystories-db']:dbGet("SELECT Termin FROM aj WHERE Serial=? and Termin < NOW()",getPlayerSerial(plr))
if x2 and #x2 > 0 then
exports['pystories-db']:dbSet("DELETE FROM aj 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,"player:sid") then return end
local x = exports['pystories-db']:dbGet("SELECT * FROM aj WHERE Serial=?",getPlayerSerial(plr))
if not x or #x < 1 then return end
local x2=exports['pystories-db']:dbGet("SELECT Termin FROM aj WHERE Serial=? and Termin < NOW()",getPlayerSerial(plr))
if x2 and #x2 > 0 then
exports['pystories-db']:dbSet("DELETE FROM aj WHERE Serial=?", getPlayerSerial(plr))
wypusc(plr)
return end
outputChatBox("Jeste? uwi?ziony w wi?zieniu do: "..x[1].Termin.." za: "..x[1].Powod.."", plr, 255, 255, 255)
end
function ajotceju(plr,cmd,cel,ile,typ,zaco)
if getElementData(plr, "player:faction")=="SAPD" then
if not cel 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 target=exports["pystories-core"]:findPlayer(plr,cel)
if not target then
outputChatBox("Nie znaleziono podanego gracza.", plr, 255, 255, 255)
return
end
x1,x2,x3 = getElementPosition(plr)
y1,y2,y3 = getElementPosition(target)
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["pystories-db"]:dbSet("INSERT INTO aj (Serial,Termin,Cela,Powod) VALUES (?,NOW() + INTERVAL minute,??,?)", getPlayerSerial(target), ile,cela, zaco)
outputChatBox("Zosta?e? uwi?ziony w wi?zieniu przez "..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").." za "..zaco.." na "..ile.." minut(-a/-y)", target, 255, 255, 255)
outputChatBox("Uwi?ziono gracza "..getPlayerName(target):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["pystories-db"]:dbSet("INSERT INTO aj (Serial,Termin,Cela,Powod) VALUES (?,NOW() + INTERVAL hour,??,?)", getPlayerSerial(target), ile,cela, zaco)
outputChatBox("Zosta?e? uwi?ziony w wi?zieniu przez "..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").." za "..zaco.." na "..ile.." godzin(-a/-y)", target, 255, 255, 255)
outputChatBox("Uwi?ziono gracza "..getPlayerName(target):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,cel)
if getElementData(plr, "player:faction")=="SAPD" then
local target=exports["pystories-core"]:findPlayer(plr,cel)
if not target then
outputChatBox("Nie znaleziono podanego gracza.", plr, 255, 255, 255)
return
end
local jebnijsie=exports['pystories-db']:dbGet("SELECT Termin FROM aj WHERE Serial=? and Termin > NOW()",getPlayerSerial(target))
if jebnijsie and #jebnijsie <= 0 then outputChatBox("Ten gracz nie jest w wi?zieniu! ("..getPlayerName(target)..")", plr,255,255,255) return end
exports['pystories-db']:dbSet("DELETE FROM aj WHERE Serial=?", getPlayerSerial(target))
outputChatBox("Gracz zosta? uwolniony z wi?zienia.", plr, 255, 255, 255)
sprawdz(target)
wypusc(target)
end
end
addCommandHandler("unjail", unaj)
setTimer(function()
for _,p in pairs(getElementsByType("player")) do
sprawdz(p)
end
end,1000,0)
function spawn()
local x=exports['pystories-db']:dbGet("SELECT Termin FROM aj WHERE Serial=? and Termin > NOW()",getPlayerSerial(source))
if x and #x <= 0 then return end
sprawdzczas(source)
end
addEventHandler("onPlayerSpawn", getRootElement(), spawn)
To jest code na panel czyli na stworzone gui a to jest ogolnie code na komende /jail i przeczyta?em ca?y poradnik i nwm nadal jak podpi?? przyciski czyli Potwierdz i edit boxy:?
Wysłany: 2020-07-06, 01:42
PatryKK.
Emeryt LUA
Wiek: 26 Na forum: 3061 dni Posty: 1060
Nick w MP: PatryKK.
Piwa : 2322
Przyk?ad:
addEventHandler ( "onClientGUIClick" , root , function()
if source ~= GUIEditor . button [ 1 ] then return end
triggerClientEvent ( "cos" , localPlayer )
end )
Ostatnio zmieniony przez PatryKK. 2020-07-06, 01:47, w całości zmieniany 1 raz
Wysłany: 2020-07-06, 01:45
filip0985
Początkujący w LUA
Wiek: 22 Na forum: 2755 dni Posty: 112
Piwa : 13
Niestety nadal nie wiem jak to wykona? gdzie mam to u?y? w kodzie jail / czy w panel i pod co to podpi?? w kodzie jail (Jestem zielony w lua)
Wysłany: 2020-07-06, 01:50
PatryKK.
Emeryt LUA
Wiek: 26 Na forum: 3061 dni Posty: 1060
Nick w MP: PatryKK.
Piwa : 2322
Wysłany: 2020-07-06, 13:24
filip0985
Początkujący w LUA
Wiek: 22 Na forum: 2755 dni Posty: 112
Piwa : 13
Za bardzo nie wiem gdzie to umie?ci? w kodzie ?
Wysłany: 2020-07-06, 13:54
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Bo?e, piszesz, ?e robisz panel JAIL a nie umiesz wstawi? bindKey? Po co bra? si? za serwery w takim razie.
podmieniasz addCommandHandler kt?ry s?u?by komendzie "jail" na funkcj? bindKey
przyk?ad :
bindKey ( "F3" , "down" ,function()
if guiGetVisible ( okno ) then
guiSetVisible ( okno , false )
else
guiSetVisible ( okno , true )
end
end )
Wysłany: 2020-07-06, 13:59
filip0985
Początkujący w LUA
Wiek: 22 Na forum: 2755 dni Posty: 112
Piwa : 13
Panel jest podpi?ty pod marker
Kod: marker = createMarker(-2404.20020, -593.62866, 131.64844, "cylinder", 1.2, 255, 0, 0, 30)
addEventHandler("onMarkerHit", marker, function(he)
triggerClientEvent(he, "marker", he)
end)
Wysłany: 2020-07-06, 14:51
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4395 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Bez sensu dzia?anie, po co robi? onMarkerHit po stronie servera i triggerowac na clienta jak mozna uzyc onClientMarkerHit.
Teraz powstaj? 2 opcj?.
a) Wchodzisz w marker okno si? otwiera wychodz?? z markera zamyka
b) wchodzisz w marker okno si? otwiera pojawia si? cursor a zamykasz guzikiem.
KT?RA?
Wysłany: 2020-07-06, 15:05
filip0985
Początkujący w LUA
Wiek: 22 Na forum: 2755 dni Posty: 112
Piwa : 13
Kod: local function zamknij()
if guiGetVisible(gui.window) then
guiSetVisible(gui.window, false)
showCursor (false)
end
end
addEventHandler("onClientGUIClick", gui.button2, zamknij, false)
addEventHandler("onClientColShapeLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
zamknij()
showCursor (false,false)
end)
Podpi??em zamykanie na przycisk
Tagi: gui :: panel :: jail
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: