Wysłany: 2018-04-01, 18:50
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
Witam, ot?z posiadam taki problem i? normalnie organizacje dzia?aj? lecz gdy przepisuje pojazd na organizacje i z niej odejde lub zostane wyrzucony to moje pojazdy w niej zostaja i mozna nimi jezdzic. Za pomoc stawiam
s.zarz?dzanie
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" , 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)" , 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" ,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" , 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" ,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
)
s.utility
--[[
Developed by Yolos
All rights reserved !
You cannot use this without permission !
--]]
function getOnlinePlayersinOrganization ( org )
local number = 0
for i , v in ipairs ( getElementsByType ( "player" )) do
if getElementData ( v , "player:organization" ) == org then
number = number + 1
end
end
return number
end
function getPlayerOrganization ( el )
local uid = getElementData ( el , "player:sid" )
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE uid=? LIMIT 1;" , uid ) -- pobieramy tylko JEDEN rekord
if result and #result > 0 then
return result [ 1 ]. name
else
return false
end
end
function getPlayerOrganizationRank ( el , org )
local uid = getElementData ( el , "player:sid" )
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1;" , org , uid ) -- pobieramy tylko JEDEN rekord
if result and #result > 0 then
return result [ 1 ]. rank
else
return false
end
end
Wysłany: 2018-04-01, 19:23
IgorPL222
LUA
Wiek: 26 Na forum: 3112 dni Posty: 133
Nick w MP: mxgvr
Piwa : 746
Z tego co wiem, to w?a?ciciel pojazd?w po odej?ciu, musi je odpisa? z organizacji r?cznie.
Wysłany: 2018-04-01, 20:12
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
IgorPL222 , Nie wydaje mi sie poniewaz gdy nie mam organizacji nie moge otworzyc panelu przepisywania pojazdow. Wyskakuje ze nie jestem w organizacji, wiec nie ma gracz mozliwosci cofnac przypisu
Wysłany: 2018-04-01, 22:17
NoKill1997
Online
Wiek: 28 Na forum: 3224 dni Posty: 183
Nick w MP: Mefedroniarz.PDW
Piwa : 778
Kod na organizacje jest dobry. Musisz poprawic kod na przepisywanie pojazdow.
Czyli musisz wejsc w OGRPG-offices, i podmienic to:
addEventHandler ( "onClientMarkerHit" , marker , function( el , md )
if el ~= localPlayer then return end
if not getElementData ( el , "player:organization" ) then outputChatBox ( "* Nie posiadasz organizacji!" ) return end
if not guiGetVisible ( wm . gridlist ) then
showCursor ( true )
guiSetVisible ( wm . window , true )
triggerServerEvent ( "org:download" , resourceRoot , el )
end
end ) Na to:
addEventHandler ( "onClientMarkerHit" , marker , function( el , md )
if el ~= localPlayer then return end
if not guiGetVisible ( wm . gridlist ) then
showCursor ( true )
guiSetVisible ( wm . window , true )
triggerServerEvent ( "org:download" , resourceRoot , el )
end
end )
Mysle, ze pomoglem.
Podpis
Aktualny projekt: LSgame
Na scenie MTA od: 2015 roku.
Discord: Chwilowoo, brak
Więcej szczegółów
Wystawiono 1 piw(a):readreis
Wysłany: 2018-04-01, 23:37
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
NoKill1997 , Rozwi?zales problem tego ze moze gracz sam wypisac pojazdy lecz da sie zrobic tak by automatycznie jego auta wypisywalo? Mi sie udalo juz zrobic ze tylko 1 auto wypisuje
Tagi: pys :: 3.0 :: organizacje
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: