Wysłany: 2018-07-01, 22:29
Kulegg
Wiek: 46 Na forum: 3125 dni Posty: 283
Piwa : 20
Cze?? posiadam wgrane dwa osobne skrypty, jeden na zarz?zdanie panelem organizacji z paczki pystories (mam t? paczke wgran? w serwer) i drugi z jakiego? innego serwera z ogrpg chyba, na za?o?enie organizacji w urzedzie, problem jest taki ?e nie dzia?a komenda jak to pisze w skrypcie: /panel.organizacji, nic si? nie wy?wietla po wpisaniu a powinien by? panel:
kod:
local zaproszenia = {}
local max_people_in_org = 55 ---- MAKSYMALNA LICZBA LUDZI W ORGANIZACJI !
function findPlayer ( plr , cel )
local target = nil
if ( tonumber ( cel ) ~= nil ) then
for _ , thePlayer in ipairs ( getElementsByType ( "player" )) do
if getElementData ( thePlayer , "player:sid" ) == tonumber ( cel ) then target = thePlayer end
end
else -- podano fragment nicku
for _ , thePlayer in ipairs ( getElementsByType ( "player" )) do
if string . find ( string . gsub ( getPlayerName ( thePlayer ): lower (), "#%x%x%x%x%x%x" , "" ), cel : lower (), 0 , 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
if target and getElementData ( target , "p:inv" ) then return nil end
return target
end
addEvent ( "lidero:editUser" , true )
addEventHandler ( "lidero: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 ms_organizacje WHERE code=? AND uid=? LIMIT 1;" , faction , text ) -- pobieramy tylko JEDEN rekord
if not result2 or #result2 < 0 then outputChatBox("* Podany u?ytkownik nie znajduje si? w tej organizacji",client,255,0,0) return end
local ranke = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1;" , faction , getElementData ( client , "player:uid" )) -- pobieramy tylko JEDEN rekord
if not ranke or #ranke < 0 then outputChatBox("* Nie znajdujesz si? w tej organizacji!",client,255,0,0) return end
if tonumber ( ranke [ 1 ]. rank ) <= 3 and ( tonumber ( rank ) > 2 ) then outputChatBox ( "*Posiadasz za ma?? range!" , client , 255 , 0 , 0 ) return end
local query1 = exports [ "pystories-db" ]: dbSet ( "UPDATE ms_organizacje SET rank=? WHERE uid=? AND code=?" , rank , text , faction )
if query1 then
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=?" , faction )
triggerClientEvent ( client , "lidero:refresh" , resourceRoot , resulted )
outputChatBox ( "* Pomy?lnie zmieniono rang? graczowi " .. result1 [ 1 ]. login .. " o id: " .. faction .. " na " .. rank .. " w organizacji." , client )
end
local target = findPlayer ( client , text )
if target then outputChatBox ( "* Twoja przynale?no?? w organizacji: " .. faction .. " zosta?a zaaktualizowana. Aby odej?? wpisz /opusc.organizacje" , target ) end
end )
addEvent ( "lidero:addUser" , true )
addEventHandler ( "lidero:addUser" , resourceRoot , function( text , faction )
if string . len ( text ) <= 0 then return end
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 ms_organizacje WHERE uid=? and code=?" , text , faction )
if result2 and #result2 > 0 then outputChatBox("* Podany u?ytkownik ju? znajduje si? w tej organizacji.", client, 255, 0, 0) return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=?" , faction )
if result and #result >= max_people_in_org then outputChatBox("* Posiadasz ju? maksymaln? liczbe ludzi w organizacji.", client, 255, 0, 0) return end
local result3 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE uid=?" , text )
if result3 and #result3 > 0 then outputChatBox("* Podany u?ytkownik ju? znajduje si? w innej organizacji.", client, 255, 0, 0) return end
local target = findPlayer ( client , text )
if target then
if zaproszenia [ target ] then outputChatBox ( "** Gracz ju? dosta? zaproszenie !" , client ) return end
if zaproszenia [ target ] and isTimer ( zaproszenia [ target ][ 3 ]) then killTimer ( zaproszenia [ target ][ 3 ]) end
zaproszenia [ target ] = { faction , client , setTimer (function() zaproszenia [ target ] = nil end , 10000 , 1 )}
outputChatBox ( "* Zosta?e?(a?) zaproszony(a) do organizacji o nazwie :" .. faction .. " !" , target , 0 , 255 , 0 )
outputChatBox ( "* Masz 10 sekund na zaakceptowanie zaproszenia! (Wpisz /akceptuj.organizacje)" , target , 0 , 255 , 0 )
end
end )
addEvent ( "lidero:deleteUser" , true )
addEventHandler ( "lidero: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 ms_organizacje WHERE code=? AND uid=? LIMIT 1;" , faction , text ) -- pobieramy tylko JEDEN rekord
if not result2 or #result2 < 0 then outputChatBox("*Podany u?ytkownik nie znajduje si? w tej organizacji !",client,255,0,0) return end
local query1 = exports [ "pystories-db" ]: dbSet ( "DELETE FROM ms_organizacje WHERE uid=? AND code=?" , text , faction )
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=?" , faction )
triggerClientEvent ( client , "lidero:refresh" , resourceRoot , resulted )
outputChatBox ( "* Pomy?lnie usunieto gracza " .. result1 [ 1 ]. login .. " o SID: " .. text .. " z organizacji" , client )
local target = findPlayer ( client , text )
if target then outputChatBox ( "* Twoja przynale?no?? w organizacji: " .. faction .. " zosta?a zaaktualizowana." , target ); setElementData ( target , "player:organization" , false ) end
end )
addCommandHandler ( "panel.organizacji" ,function ( plr , cmd ,...)
local uid = getElementData ( plr , "player:sid" )
if not uid then return end
local code = getElementData ( plr , "player:organization" )
if not code then return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1;" , code , uid ) -- pobieramy tylko JEDEN rekord
if result and #result > 0 then
if result [ 1 ]. rank <= 2 then outputChatBox ( "* Brak uprawnie? do panelu organizacji !" , plr ) return end
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=?" , code )
triggerClientEvent ( plr , "lidero:showGUI" , resourceRoot , code , resulted )
end
end )
addCommandHandler ( "akceptuj.organizacje" ,function ( plr , cmd )
local uid = getElementData ( plr , "player:sid" )
if not uid then return end
if not zaproszenia [ plr ] then outputChatBox ( "* Nie masz zaproszenia do organizacji lub przedawni?o si? !" , plr , 255 , 0 , 0 ) return end
local result1 = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE id=?" , uid )
if not result1 or #result1 < 0 then outputChatBox("* Nie wczytano twoich danych !", plr, 255, 0, 0) return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE uid=? and code=?" , uid , zaproszenia [ plr ][ 1 ])
if result and #result > 0 then outputChatBox("* Podany u?ytkownik ju? znajduje si? w tej organizacji.", client, 255, 0, 0) return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE uid=?" , uid )
if result and #result > 0 then outputChatBox("* Podany u?ytkownik ju? znajduje si? w innej organizacji.", client, 255, 0, 0) return end
local query1 = exports [ "pystories-db" ]: dbSet ( "INSERT ms_organizacje (uid,login,code) VALUES (?,?,?)" , uid , result1 [ 1 ]. login , zaproszenia [ plr ][ 1 ])
if isElement ( zaproszenia [ plr ][ 2 ]) then
if isTimer ( zaproszenia [ plr ][ 3 ]) then killTimer ( zaproszenia [ plr ][ 3 ]) end
local resulted = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=?" , zaproszenia [ plr ][ 1 ])
triggerClientEvent ( zaproszenia [ plr ][ 2 ], "lidero:refresh" , resourceRoot , resulted )
outputChatBox ( "* Pomy?lnie dodano gracza " .. result1 [ 1 ]. login .. " o SID: " .. uid .. " w organizacji na 1 poziom" , zaproszenia [ plr ][ 2 ])
end
outputDebugString ( "ms_organizacje> Organizacja: " .. zaproszenia [ plr ][ 1 ].. " SID: " .. uid )
outputChatBox ( "* Akceptowa?e?(a?) zaproszenie do organizacji o nazwie: " .. zaproszenia [ plr ][ 1 ].. ". Aby odej?? wpisz /opusc.organizacje" , plr )
setElementData ( plr , "player:organization" , zaproszenia [ plr ][ 1 ])
exports [ 'pystories-db' ]: dbSet ( "UPDATE ms_organizacje SET actived=curdate() WHERE uid=?" , getElementData ( plr , "player:sid" ))
zaproszenia [ plr ] = nil
end )
addCommandHandler ( "opusc.organizacje" ,function ( plr , cmd )
local uid = getElementData ( plr , "player:sid" )
if not uid then return end
local code = getElementData ( plr , "player:organization" )
if not code then outputChatBox ( "* Nie posiadasz ?adnej organizacji !" , plr ) return end
local query1 = exports [ "pystories-db" ]: dbSet ( "DELETE FROM ms_organizacje WHERE uid=? AND code=?" , uid , code )
outputChatBox ( "* Opu?ci?e?(a?) organizacje " .. code .. " !" , plr ); setElementData ( plr , "player:organization" , false )
end )
function globalMessage ( plr , cmd , ...)
local frakcja = getElementData ( plr , 'player:organization' )
if not frakcja then
return
end
local msg = table . concat ( { ... }, " " )
local admins = getElementsByType ( 'player' )
for i , v in pairs ( admins ) do
local pfrakcje = getElementData ( v , 'player:organization' )
if frakcja == pfrakcje then
outputChatBox ( "#000000" .. pfrakcje .. "> #FFFFFF" .. getPlayerName ( plr ): gsub ( "#%x%x%x%x%x%x" , "" ).. "#FFFFFF:#FFFFFF " .. msg : gsub ( "#%x%x%x%x%x%x" , "" ), v , _ , _ , _ , true )
end
end
local desc = "[ORGANIZACJA] [" .. getElementData ( plr , "id" ).. "]" .. getPlayerName ( plr ): gsub ( "#%x%x%x%x%x%x" , "" ).. "(" .. getElementData ( plr , "player:organization" ).. "): " .. msg : gsub ( "#%x%x%x%x%x%x" , "" ).. ""
triggerEvent ( "admin:addText" , resourceRoot , desc : gsub ( "#%x%x%x%x%x%x" , "" ))
outputServerLog ( desc )
end
addCommandHandler ( "Organizacja" , globalMessage )
addEventHandler ( "onResourceStart" , root , function()
local players = getElementsByType ( 'player' )
for _ , p in pairs ( players ) do
bindKey ( p , "o" , "down" , "chatbox" , "Organizacja" )
end
end )
addEventHandler ( "onPlayerSpawn" , getRootElement (),
function ( _ )
bindKey ( source , "o" , "down" , "chatbox" , "Organizacja" )
end
)
[ Dodano : 2018-07-01, 22:41 ]
Prawdopodobnie co? z element dat?, bo /opusc.organizacje dzia?a
Wysłany: 2018-07-02, 10:20
Mezo.
Mod-Team
Wiek: 24 Na forum: 3211 dni Posty: 548
Nick w MP: Mezo
Piwa : 6070
Jakies b??dy w db3?
Podpis
- Na forum pomagam na miarę swoich możliwości, oraz bezpłatnie.
- Jeżeli potrzebujesz pomocy, pisz do mnie w prywatnej wiadomości, pomoc uzyskasz szybciej.
Współpraca -
[email protected]
Użytkownik - 19.08.2017
GTAO MEMBER - 29.03.2019
Support-Team - 03.02.2019 - 07.05.2019
Moderator - 07.05.2019 - 02.08.2020
Mod-Team - 02.08.2020 - 25.03.2022
Wysłany: 2018-07-02, 13:15
Kulegg
Wiek: 46 Na forum: 3125 dni Posty: 283
Piwa : 20
Wysłany: 2018-07-03, 09:44
Atroth
Wiek: 23 Na forum: 3677 dni Posty: 1089
Nick w MP: Atroth
Piwa : 4808
1. Czy tabela zamiera kolumny o nazwie "code" i "uid"? Czy s? uzupe?nione?
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1;" , code , uid ) -- pobieramy tylko JEDEN rekord
2. Czy masz wszystkie nadane te elementDaty? Najlepiej by?oby sprawdzi? je w outputChatBox, na samym pocz?tku kodu w momencie wpisania komendy:
outputChatBox ( tostring ( getElementData ( plr , "data" )))
Podpis
Użytkownik - 10-05-2016
Support Team - 17.06.2017
Moderator - 25.11.2017
Mod-Team - 02.07.2018
Tagi: organizacje :: (panel :: lidera :: org :: nie :: działą)
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: