Wysłany: 2020-12-28, 01:02
NoNamik
Wiek: 35 Na forum: 2185 dni Posty: 289
Nick w MP: JestemNoNamem
Piwa : 374
Witam chcia?em doda? do panelu frakcyjnego by pokazywa?o Nick lecz nie pokazuje podejrzewam go
PS jest on z pystories 3.0
local wm ={
window ={},
added ={},
edit ={},
close ={},
delete ={},
gridlist ={},
faction = nil ,
}
-- Panel cz ? onk ? w
wm . window [ 1 ]= guiCreateWindow ( 0.18 , 0.23 , 0.64 , 0.57 , "Panel frakcji" , true )
guiWindowSetMovable ( wm . window [ 1 ], false )
guiWindowSetSizable ( wm . window [ 1 ], false )
guiSetVisible ( wm . window [ 1 ], false )
wm . gridlist [ 1 ]= guiCreateGridList ( 0.02 , 0.05 , 0.97 , 0.73 , true , wm . window [ 1 ])
guiGridListAddColumn ( wm . gridlist [ 1 ], "Nick" , 0.3 )
guiGridListAddColumn ( wm . gridlist [ 1 ], "SID" , 0.3 )
guiGridListAddColumn ( wm . gridlist [ 1 ], "Ranga" , 0.3 )
guiGridListAddColumn ( wm . gridlist [ 1 ], "Aktywny" , 0.3 )
wm . added [ 1 ]= guiCreateButton ( 0.02 , 0.80 , 0.26 , 0.16 , "Dodaj" , true , wm . window [ 1 ])
wm . edit [ 1 ]= guiCreateButton ( 0.38 , 0.80 , 0.26 , 0.16 , "Edytuj" , true , wm . window [ 1 ])
wm . delete [ 1 ]= guiCreateButton ( 0.73 , 0.80 , 0.26 , 0.16 , "Wyrzu?" , true , wm . window [ 1 ])
-- Dodawanie cz ? onka / edycja jego
wm . window [ 2 ]= guiCreateWindow ( 0.35 , 0.43 , 0.30 , 0.22 , "Dodawanie cz?onka - wpisz nick i kliknij dodaj" , true )
guiWindowSetMovable ( wm . window [ 2 ], false )
guiWindowSetSizable ( wm . window [ 2 ], false )
guiSetVisible ( wm . window [ 2 ], false )
wm . edit [ 2 ]= guiCreateEdit ( 0.09 , 0.21 , 0.81 , 0.20 , "" , true , wm . window [ 2 ])
wm . close [ 1 ]= guiCreateButton ( 0.55 , 0.52 , 0.36 , 0.31 , "Zamknij" , true , wm . window [ 2 ])
wm . added [ 2 ]= guiCreateButton ( 0.09 , 0.52 , 0.36 , 0.31 , "Dodaj" , true , wm . window [ 2 ])
function fillUsersData ( result )
guiGridListClear ( wm . gridlist [ 1 ])
for i , v in pairs ( result ) do
local row = guiGridListAddRow ( wm . gridlist [ 1 ])
guiGridListSetItemText ( wm . gridlist [ 1 ], row , 1 , v [ "login" ], false , false )
guiGridListSetItemText ( wm . gridlist [ 1 ], row , 2 , v [ "sid" ], false , false )
guiGridListSetItemText ( wm . gridlist [ 1 ], row , 3 , v [ "rank" ], false , false )
guiGridListSetItemText ( wm . gridlist [ 1 ], row , 4 , v [ "actived" ], false , false )
end
end
addEventHandler ( "onClientMarkerLeave" , resourceRoot , function( el , md )
if el ~= localPlayer then return end
if guiGetVisible ( wm . window [ 1 ]) == true then
showCursor ( false )
guiSetVisible ( wm . window [ 1 ], false )
guiSetVisible ( wm . window [ 2 ], false )
end
end )
addEventHandler ( "onClientGUIClick" , resourceRoot , function()
if source == wm . added [ 1 ] then
guiSetVisible ( wm . window [ 2 ], true )
guiMoveToBack ( wm . window [ 1 ])
guiSetText ( wm . added [ 2 ], "Dodaj" )
guiSetText ( wm . window [ 2 ], "Dodawanie cz?onka - wpisz SID gracza i kliknij dodaj" )
end
if source == wm . edit [ 1 ] then
local selectedRow = guiGridListGetSelectedItem ( wm . gridlist [ 1 ])
if not selectedRow or selectedRow < 0 then return end
local rank = guiGridListGetItemText ( wm . gridlist [ 1 ], selectedRow , 2 )
if tonumber ( rank ) == 99 then outputChatBox ( "* Nie mo?esz edytowa? tego U?ytkownika, poniewa? posiada On Lidera !" , 255 , 0 , 0 ) return end
guiSetVisible ( wm . window [ 2 ], true )
guiMoveToBack ( wm . window [ 1 ])
guiSetText ( wm . added [ 2 ], "Edycja" )
guiSetText ( wm . window [ 2 ], "Edycja cz?onka - wpisz ID rangi (0-98) i kliknij edycja" )
end
if source == wm . close [ 1 ] then
guiSetVisible ( wm . window [ 2 ], false )
end
if source == wm . added [ 2 ] then
local text = guiGetText ( wm . edit [ 2 ])
if guiGetText ( wm . added [ 2 ]) ~= "Dodaj" then
local selectedRow = guiGridListGetSelectedItem ( wm . gridlist [ 1 ])
if not selectedRow or selectedRow < 0 then return end
local name = guiGridListGetItemText ( wm . gridlist [ 1 ], selectedRow , 1 )
if not name then return end
if not text then return end
if tonumber ( text ) and tonumber ( text ) <= 98 then
triggerServerEvent ( "lider:editUser" , resourceRoot , name , text , wm . faction )
else
guiSetText ( wm . window [ 2 ], "Podaj range w liczbach! Maksymalna to 98!" )
end
else
if not text then return end
triggerServerEvent ( "lider:addUser" , resourceRoot , text , wm . faction )
end
end
if source == wm . delete [ 1 ] then
local selectedRow = guiGridListGetSelectedItem ( wm . gridlist [ 1 ])
if not selectedRow or selectedRow < 0 then return end
local rank = guiGridListGetItemText ( wm . gridlist [ 1 ], selectedRow , 2 )
if tonumber ( rank ) == 99 then outputChatBox ( "* Nie mo?esz usun?? tego U?ytkownika, poniewa? posiada On Lidera !" , 255 , 0 , 0 ) return end
local name = guiGridListGetItemText ( wm . gridlist [ 1 ], selectedRow , 1 )
if not name then return end
triggerServerEvent ( "lider:deleteUser" , resourceRoot , name , wm . faction )
end
if source == wm . gridlist [ 1 ] then
local selectedRow = guiGridListGetSelectedItem ( wm . gridlist [ 1 ])
if not selectedRow or selectedRow < 0 then
guiSetEnabled ( wm . edit [ 1 ], false )
guiSetEnabled ( wm . delete [ 1 ], false )
else
guiSetEnabled ( wm . edit [ 1 ], true )
guiSetEnabled ( wm . delete [ 1 ], true )
end
end
end )
addEvent ( "lider:showGUI" , true )
addEventHandler ( "lider:showGUI" , resourceRoot , function( fid , result )
if guiGetVisible ( wm . window [ 1 ]) == false then
-- Ustawienia
showCursor ( true , false )
guiSetVisible ( wm . window [ 1 ], true )
guiSetEnabled ( wm . edit [ 1 ], false )
guiSetEnabled ( wm . delete [ 1 ], false )
wm . faction = fid -- deklarujemy frakcj ?
-- Sprawdzamy cz ? onk ? w
fillUsersData ( result )
end
end )
addEvent ( "lider:refresh" , true )
addEventHandler ( "lider:refresh" , resourceRoot , fillUsersData )
Wysłany: 2020-12-28, 07:01
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Poka? to, co przekazujesz w evencie lider:refresh. W bazie masz te wszystkie 4 kolumny?
Wysłany: 2020-12-28, 17:16
NoNamik
Wiek: 35 Na forum: 2185 dni Posty: 289
Nick w MP: JestemNoNamem
Piwa : 374
addEvent ( "lider:editUser" , true )
addEventHandler ( "lider:editUser" , resourceRoot , function( text , rank , faction )
local result1 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=?" , text )
if not result1 or #result1 < 0 then outputChatBox("* Podany u?ytkownik nie istnieje w bazie danych.", client, 255, 0, 0) return end
local result2 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE code=? AND sid=? LIMIT 1;" , faction , text ) -- pobieramy tylko JEDEN rekord
if not result2 or #result2 < 0 then outputChatBox("*Podany u?ytkownik nie znajduje si? w tej frakcji !",client,255,0,0) return end
local query1 = exports [ "pystories-db" ]: dbSet ( "UPDATE `pystories_factions` SET `rank`=? WHERE `sid`=? AND `code`=?" , rank , text , faction )
if query1 then
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE code=?" , faction )
triggerClientEvent ( client , "lider:refresh" , resourceRoot , resulted )
outputChatBox ( "* Pomy?lnie zmieniono rang? graczowi " .. result1 [ 1 ]. login .. " we frakcji o id: " .. faction .. " na " .. rank , client )
end
end )
addEvent ( "lider:addUser" , true )
addEventHandler ( "lider:addUser" , resourceRoot , function( text , faction )
local result1 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=?" , text )
if not result1 or #result1 < 0 then outputChatBox("* Podany u?ytkownik nie istnieje w bazie danych.", client, 255, 0, 0) return end
local result2 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE sid=? and code=?" , text , faction )
if result2 and #result2 > 0 then outputChatBox("* Podany u?ytkownik ju? znajduje si? w tej frakcji.", client, 255, 0, 0) return end
local result3 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE sid=?" , text )
if result3 and #result3 > 0 then outputChatBox("* Podany u?ytkownik ju? znajduje si? w innej frakcji.", client, 255, 0, 0) return end
outputDebugString ( "Faction: " .. faction )
outputDebugString ( "Text: " .. text )
local query1 = exports [ "pystories-db" ]: dbSet ( "INSERT pystories_factions (sid,code) VALUES (?,?)" , text , faction )
if query1 then
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE code=?" , faction )
triggerClientEvent ( client , "lider:refresh" , resourceRoot , resulted )
outputChatBox ( "* Pomy?lnie dodano gracza " .. result1 [ 1 ]. login .. " o SID: " .. text .. " we frakcji na 1 poziom." , client )
end
end )
addEvent ( "lider:deleteUser" , true )
addEventHandler ( "lider:deleteUser" , resourceRoot , function( text , faction )
local result1 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=?" , text )
if not result1 or #result1 < 0 then outputChatBox("* Podany u?ytkownik nie istnieje w bazie danych.", client, 255, 0, 0) return end
local result2 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE code=? AND sid=? LIMIT 1;" , faction , text ) -- pobieramy tylko JEDEN rekord
if not result2 or #result2 < 0 then outputChatBox("* Podany u?ytkownik nie znajduje si? w tej frakcji !",client,255,0,0) return end
local query1 = exports [ "pystories-db" ]: dbSet ( "DELETE FROM pystories_factions WHERE sid=? AND code=?" , text , faction )
if query1 then
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_factions WHERE code=?" , faction )
triggerClientEvent ( client , "lider:refresh" , resourceRoot , resulted )
outputChatBox ( "* Pomy?lnie usunieto gracza " .. result1 [ 1 ]. login .. " o SID: " .. text .. " z frakcji." , client )
end
end )
a tu masz ss z bazy danych pystories_factions
Wysłany: 2020-12-28, 21:34
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
No, i z tego co widz? to brakuje kolumny 'login' - musisz ow? doda? w bazie danych bo rzekomo j? wykorzystujesz w LUA - co nie ma efektu bo ona nie istnieje.
Wysłany: 2020-12-29, 14:31
NoNamik
Wiek: 35 Na forum: 2185 dni Posty: 289
Nick w MP: JestemNoNamem
Piwa : 374
Wilq , a nie da sie zrobic tak by pobieralo t? kolumne login z pystories_users?
Wysłany: 2020-12-29, 14:56
TheSebaPL
Mod-team
Wiek: 21 Na forum: 3098 dni Posty: 964
Piwa : 3102
NoNamik , lepiej jest zrobi? ow? struktur? te same warto?ci wez jakie s? w pystories_users
Wysłany: 2020-12-29, 19:30
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Tagi: panel :: frakcji
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: