Wysłany: 2018-03-25, 23:06
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
Witam przychodze z problem, i? normalnie moge dodac auto do organizacji kazdy moze jezdzic ale gdy odpuszam organizacje lub mnie wyrzuca to moje auta sa dalej do niej przypisane i kazdy wciaz moze z nich korzystac. Za pomoc daje piwka
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:sid" )) -- 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
)
addEventHandler ( "onPlayerSpawn" , getRootElement (),
function ( _ )
bindKey ( source , "F2" , "down" , "panel.organizacji" )
end
)
Wysłany: 2018-03-26, 12:57
Avenged
Młodszy Szkrypter
Wiek: 23 Na forum: 3510 dni Posty: 654
Nick w MP: Avenged
Piwa : 1570
Daj kod z przepisywaniem pojazd?w na org
Podpis
LUA, JS, PHP
Zapraszam do skorzystania z moich usług: Klik
Wysłany: 2018-03-26, 20:44
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
Trzymaj
--[[
Developed by Yolos . You dont have agree to use this code ! ; 3
]]
function refreshgui ( element )
local sid = getElementData ( element , "player:sid" )
if not sid then return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_vehicles WHERE ownedPlayer=?" , sid )
triggerClientEvent ( element , "org:refresh" , resourceRoot , result )
end
addEvent ( "org:check" , true )
addEventHandler ( "org:check" , resourceRoot , function( id , name )
-- Pobieramy SID gracza
local sid = getElementData ( client , "player:sid" )
if not sid then return end
-- Sprawdzamy czy jest jeszcze w ? a ? cicielem
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_vehicles WHERE id=? AND ownedPlayer=?" , id , sid )
if #result < 0 then
outputChatBox ( "* Nie jeste? w?a?cicielem pojazdu." , client , 255 , 0 , 0 )
return
end
local org = getElementData ( client , "player:organization" )
if not org then outputChatBox ( "* Nie jeste? w organizacji !" , client , 255 , 0 , 0 ) return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_vehicles WHERE id=? AND parking=0" , id , org )
if #result > 0 then
outputChatBox ( "* Pojazd nie jest w przechowalni !." , client , 255 , 0 , 0 )
return
end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_vehicles WHERE id=? AND ownedPlayer=?" , id , sid )
if #result > 0 then
if result [ 1 ]. ownedGroup ~= "0" then
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_vehicles SET ownedGroup=0 WHERE id=? AND ownedPlayer=?" , id , sid )
outputChatBox ( "* Zmieni?e?(a?) pojazdowi " .. name .. "(" .. id .. ") przypis na siebie" , client )
refreshgui ( client )
return
end
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_vehicles SET ownedGroup=? WHERE id=? AND ownedPlayer=?" , org , id , sid )
if query then
outputChatBox ( "* Zmieni?e?(a?) pojazdowi " .. name .. "(" .. id .. ") przypis na organizacje" , client )
refreshgui ( client )
end
end
end )
addEvent ( "org:download" , true )
addEventHandler ( "org:download" , resourceRoot , refreshgui )
Tagi: przepisywanie :: pojazdow :: organizacji
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: