Wysłany: 2022-07-03, 14:33
Leszek
Programista lua $ Mapper
Wiek: 21 Na forum: 2002 dni Posty: 99
Nick w MP: Leszek
Piwa : 393
Cze??
Robi? panel lidera frakcji i chce u?y? ComboBox'a w celu wy?wietlenia wszystkich graczy kt?rzy s? dodani we frakcji(w bazie danych mam wypisanych graczy po nicku i serialu) i nie mam poj?cia jak to zrobi?. Ma kto? jakie? pomys?y?
Wysłany: 2022-07-04, 11:54
JakisPolak199
wieczny student
Wiek: 20 Na forum: 3510 dni Posty: 131
Nick w MP: bover.
Piwa : 905
Wysłany: 2022-07-04, 14:56
Leszek
Programista lua $ Mapper
Wiek: 21 Na forum: 2002 dni Posty: 99
Nick w MP: Leszek
Piwa : 393
W?a?nie pr?buje to zrobi?, ale error w debugu.
Client
Kod:
liderpanelmarker = createMarker(-2454.75879, 540.34064, -68.62682,"cylinder",1.45,255,0,0,75)
glowne_okno = guiCreateWindow(688, 311, 510, 422, "xx", false)
lista_graczy = guiCreateComboBox(13, 50, 487, 45, "", false, glowne_okno)
addEventHandler("onClientMarkerHit",liderpanelmarker,function(hitElement)
triggerServerEvent("Wynikimordo", resourceRoot)
guiSetVisible(glowne_okno,true)
showCursor(true)
setElementFrozen(hitElement,true)
end)
addEventHandler("onClientMarkerLeave",liderpanelmarker,function(hitElement)
guiSetVisible(glowne_okno,false)
setElementFrozen(hitElement,false)
end)
addEventHandler("onClientGUIClick",getRootElement(),function()
if source == cancel_button then
setElementFrozen(localPlayer,false)
guiSetVisible(glowne_okno,false)
showCursor(false)
end
end)
function res(message)
guiComboBoxAddItem(lista_graczy,message[0].nick)
end
addEvent( "podanowyniki", true )
addEventHandler( "podanowyniki", localPlayer, res )
Server
Kod:
function resoraki ()
if getElementData(client,"sapd:duty") == true then
tabela = exports['DB2']:pobierzWyniki("SELECT * from sapd where frakcja=?","SAPD")
triggerClientEvent(client,"podanowyniki",client,tabela)
end
end
addEvent( "Wynikimordo", true )
addEventHandler( "Wynikimordo", resourceRoot, resoraki )
Baza Danych
Error
Wysłany: 2022-07-04, 17:55
JakisPolak199
wieczny student
Wiek: 20 Na forum: 3510 dni Posty: 131
Nick w MP: bover.
Piwa : 905
Zacznijmy od tego, ?e lua rozpoczyna iteracj? od liczby 1 nie 0 jak inne j?zyki skryptowe/programowania, ponadto nie stworzy?e? p?tli na wynikach wi?c tw?j kod po poprawieniu message[0] na message[1] poda?by tylko pierwsza osobe z bazy danych nie dodajac reszty.
Ten kod (client) powinien dzia?a?, aczkolwiek go nie testowalem.
liderpanelmarker = createMarker (- 2454.75879 , 540.34064 , - 68.62682 , "cylinder" , 1.45 , 255 , 0 , 0 , 75 )
glowne_okno = guiCreateWindow ( 688 , 311 , 510 , 422 , "xx" , false )
lista_graczy = guiCreateComboBox ( 13 , 50 , 487 , 45 , "" , false , glowne_okno )
addEventHandler ( "onClientMarkerHit" , liderpanelmarker ,function( hitElement )
triggerServerEvent ( "Wynikimordo" , resourceRoot )
guiSetVisible ( glowne_okno , true )
showCursor ( true )
setElementFrozen ( hitElement , true )
end )
addEventHandler ( "onClientMarkerLeave" , liderpanelmarker ,function( hitElement )
guiSetVisible ( glowne_okno , false )
setElementFrozen ( hitElement , false )
end )
addEventHandler ( "onClientGUIClick" , getRootElement (),function()
if source == cancel_button then
setElementFrozen ( localPlayer , false )
guiSetVisible ( glowne_okno , false )
showCursor ( false )
end
end )
function res ( message )
for i , v in pairs ( message ) do
guiComboBoxAddItem ( lista_graczy , v . nick )
end
end
addEvent ( "podanowyniki" , true )
addEventHandler ( "podanowyniki" , localPlayer , res )
Wysłany: 2022-07-04, 21:10
Leszek
Programista lua $ Mapper
Wiek: 21 Na forum: 2002 dni Posty: 99
Nick w MP: Leszek
Piwa : 393
Zrobi?em tak jak wys?a?e?, ale wyskakuje b??d.
db3
ten fragment kodu
Kod:
function res(message)
for i, v in pairs(message) do
guiComboBoxAddItem(lista_graczy, v.nick)
end
end
Wysłany: 2022-07-05, 14:09
kamison
Przyszły programista .lua
Wiek: 25 Na forum: 3302 dni Posty: 391
Nick w MP: kamison
Piwa : 594
Zobacz v[i].nick, jak nie zadzia?a to poka? co jest pod zmienn? 'message'
Wysłany: 2022-07-06, 21:32
Leszek
Programista lua $ Mapper
Wiek: 21 Na forum: 2002 dni Posty: 99
Nick w MP: Leszek
Piwa : 393
nadal wyst?puje ten sam b??d co w ss wy?ej, ju? daje kod z tym message.
CLIENT
Kod:
addEventHandler("onClientMarkerHit",liderpanelmarker,function(hitElement)
triggerServerEvent("Wynikimordo", resourceRoot)
guiSetText(mnoznikpole,getElementData(hitElement,"sapd:mnoznikodsiadki"))
guiSetVisible(glowne_okno,true)
showCursor(true)
setElementFrozen(hitElement,true)
end)
function res(message)
for i, v in pairs(message) do
guiComboBoxAddItem(lista_graczy,v[i].nick) <------------ error
end
end
addEvent( "podanowyniki", true )
addEventHandler( "podanowyniki", localPlayer, res )
SERVER
Kod:
function resoraki ()
if getElementData(client,"sapd:duty") == true then
tabela = exports['DB2']:pobierzWyniki("SELECT * from sapd where frakcja=?","SAPD")
triggerClientEvent(client,"podanowyniki",client,tabela)
end
end
addEvent( "Wynikimordo", true )
addEventHandler( "Wynikimordo", resourceRoot, resoraki )
(oczywi?cie strza?ka u clienta z error zosta?a dodana przezemnie i nie znajduje si? w kodzie)
Wysłany: 2022-07-10, 23:21
JakisPolak199
wieczny student
Wiek: 20 Na forum: 3510 dni Posty: 131
Nick w MP: bover.
Piwa : 905
sprobuj kod po sside zmienic na ten
function resoraki ()
if getElementData ( client , "sapd:duty" ) == true then
local graczeTabela = exports [ 'DB2' ]: pobierzWyniki ( "SELECT * from sapd where frakcja=?" , "SAPD" )
triggerClientEvent ( client , "podanowyniki" , client , graczeTabela )
end
end
addEvent ( "Wynikimordo" , true )
addEventHandler ( "Wynikimordo" , resourceRoot , resoraki )
Wysłany: 2022-07-13, 02:28
Leszek
Programista lua $ Mapper
Wiek: 21 Na forum: 2002 dni Posty: 99
Nick w MP: Leszek
Piwa : 393
poradzi?em sobie z problemem, mo?na zamkn??.
je?li kto? ma podobny dylemat to zmieni?em plany na wy?wietlanie graczy kt?rzy s? na serwerze tylko
Kod:
lista_graczy = guiCreateComboBox(13, 50, 487, 45, "", false, glowne_okno)
for i,v in ipairs(getElementsByType("player")) do
if getElementData(v, "sapd:zatrudnienie") == true then
guiComboBoxAddItem(lista_graczy,getPlayerName(v))
end
end
Tagi: combobox
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: