function findPlayer(plr,cel)
local target=nil
if (tonumber(cel) ~= nil) then
target=getElementByID("p"..cel)
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(), 1, 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
return target
end
local frakcja_KGPLS = createTeam("KGP",0,0,255)
local frakcja_KGSPLS = createTeam("KGSP",255,0,0)
local frakcja_PRLS = createTeam("PR",50,100,200)
local fractions = { -- g??wne markery frakcji
--["nazwa_frakcji"]={x,y,z,dim,int},
["KGSP"]={1939.42,-1972.66,13.55,0,0},
["KGP"]={297.49,186.41,1007.17,1000,3},
["PR"]={936.28,-1536.94,13.55,0,0},
}
for _,v in pairs(fractions) do
local x,y,z = v[1],v[2],v[3]-1
local d,i = v[4],v[5]
local marker = createMarker(x,y,z,"cylinder",1.2,50,100,200,120,root)
setElementInterior(marker,i)
setElementDimension(marker,d)
setElementData(marker,"fraction:marker",true)
setElementData(marker,"fraction:marker:rgb",{r,g,b})
end
function isPlayerInTeam(player, team)
assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got "..tostring(player).."]")
assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got "..tostring(team).."]")
return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true)))
end
addEventHandler("onMarkerHit",resourceRoot,function(plr)
if plr and isElement(plr) and getElementType(plr) == "player" then
if tonumber(getElementData(plr,"player:sid")) then
if getElementData(plr,"fraction") then
if not isPedInVehicle(plr) then
if getElementData(source,"fraction:marker") == true then
triggerClientEvent(plr,"fraction:showButtons:startstop",plr,plr)
else
outputChatBox("Niezidentyfikowany b??d #1.",plr,255,0,0)
end
else
outputChatBox("Wpierw musiz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
end
else
outputChatBox("Nie jeste? zatrudniony w ?adnej frakcji!",plr,255,0,0)
end
else
outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany!",plr,255,0,0)
end
end
end)
addEvent("fraction:start:duty",true)
addEventHandler("fraction:start:duty",root,function(plr)
if plr and isElement(plr) and getElementType(plr) == "player" then
if tonumber(getElementData(plr,"player:sid")) then
if getElementData(plr,"fraction") then
if not isPedInVehicle(plr) then
local frakcja = false
if getElementData(plr,"fraction") == "KGP" then
frakcja = frakcja_KGPLS
elseif getElementData(plr,"fraction") == "KGSP" then
frakcja = frakcja_KGSPLS
elseif getElementData(plr,"fraction") == "PR" then
frakcja = frakcja_PRLS
end
local q = exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(plr,"player:sid")))
local result = dbPoll(q,-1)
if result then
for _,v in ipairs(result) do
if frakcja then
setPlayerTeam(plr,frakcja)
local dowodca = v["fraction_rang_commander"]
local ranga = v["fraction_rang"]
setElementData(plr,"fraction:rang",tostring(ranga))
setElementData(plr,"fraction:rang:commander",tonumber(dowodca))
setElementData(plr,"fraction:duty","S3")
outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
outputChatBox("* Rozpocz??e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
outputChatBox("* Twoja ranga we frakcji: "..tostring(ranga)..".",plr,0,255,0)
outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
end
end
end
else
outputChatBox("Wpierw musisz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
end
else
outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
end
else
outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
end
end
end)
addEvent("fraction:stop:duty",true)
addEventHandler("fraction:stop:duty",root,function(plr)
if plr and isElement(plr) and getElementType(plr) == "player" then
if tonumber(getElementData(plr,"player:Sid")) then
if getElementData(plr,"fraction") then
if getElementData(plr,"fraction:duty") == "S3" then
setElementModel(plr,getElementData(plr,"clothes"))
setPlayerTeam(plr,nil)
setElementData(plr,"fraction:duty",nil)
outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
outputChatBox("* Zako?czy?e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
else
outputChatBox("Wpierw musisz wej?? na duty, by m?c zako?czy? s?u?b?!",plr,255,0,0)
end
else
outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
end
else
outputChatBox("Aby zako?czy? s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
end
end
end)
function naliczajCzas()
if getElementData(source,"player:sid") then
if getElementData(source,"fraction") then
if getElementData(source,"fraction:duty") == "S3" then
if getElementData(source,"fraction:rang") then
setTimer(function()
local q = exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(source,"player:sid")))
local result = dbPoll(q,-1)
if result then
for _,v in ipairs(result) do
local minuty = v["fraction_minutes"]
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_minutes`=? WHERE ID=?",tonumber(minuty)+1,tonumber(getElementData(source,"player:sid")))
end
end
end,60000,0)
end
end
end
end
end
addCommandHandler("frakcja_ranga",function(plr,cmd,cel,ranga)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
if ranga then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang`=? WHERE login=?",ranga,tostring(cel))
if update then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
setElementData(odbiorca,"fraction:rang",ranga)
outputChatBox("* Ranga zosta?a zmieniona na: "..ranga..".",plr,255,255,255)
outputChatBox("* Twoja ranga we frakcji zosta?a zaktualizowana!",odbiorca,255,255,255)
else
outputChatBox("Nie znaleziono celu! Ranga zosta?a zmieniona w bazie danych.",plr,255,0,0)
end
end
end
end
end
end
end
end)
addCommandHandler("frakcja_dodaj",function(plr,cmd,cel,ranga)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
if ranga then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?",getElementData(plr,"fraction"),ranga,3,getElementData(odbiorca,"login"))
if update then
outputChatBox("* Dodano "..getPlayerName(odbiorca).." do frakcji! Jego ranga: "..ranga..".",plr,255,255,255)
outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? dodany do "..getElementData(plr,"fraction")..". Twoja ranga: "..ranga..".",odbiorca,255,255,255)
setElementData(odbiorca,"fraction",getElementData(plr,"fraction"))
setElementData(odbiorca,"fraction:rang",tostring(ranga))
setElementData(odbiorca,"fraction:rang:commander",3)
end
else
outputChatBox("Nie znaleziono celu!",plr,255,0,0)
end
end
end
end
end
end
end)
addCommandHandler("frakcja_usun",function(plr,cmd,cel)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?","","",0,getElementData(odbiorca,"login"))
if update then
outputChatBox("* Wyrzucono "..getPlayerName(odbiorca).." z Twojej frakcji!",plr,255,255,255)
outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? wyrzucony z "..getElementData(plr,"fraction")..".",odbiorca,255,0,0)
setElementData(odbiorca,"fraction",false)
setElementData(odbiorca,"fraction:rang",false)
setElementData(odbiorca,"fraction:rang:commander",false)
setPlayerTeam(odbiorca,nil)
setElementData(odbiorca,"fraction:duty",false)
end
else
outputChatBox("Nie znaleziono celu!",plr,255,0,0)
end
end
end
end
end
end)
addCommandHandler("frakcja_typ",function(plr,cmd,cel,typ)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
if typ and tonumber(typ) and tonumber(typ) < 4 then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang_commander`=? WHERE login=?",typ,getElementData(odbiorca,"login"))
if update then
outputChatBox("* Zmieniono typ rangi dla "..getPlayerName(odbiorca).." ; nowy typ rangi: "..typ..".",plr,255,255,255)
outputChatBox("* Tw?j typ rangi we frakcji zosta? zaktualizowany! Aktualny typ rangi: "..typ.."",odbiorca,255,0,0)
setElementData(odbiorca,"fraction:rang:commander",false)
end
else
outputChatBox("Typ: 1-dow?dca frakcji ; 2-zast?pca frakcji ; 3-inna. ",plr,255,0,0)
end
else
outputChatBox("Nie znaleziono celu!",plr,255,0,0)
end
end
end
end
end
end)
addCommandHandler("frakcja_rangi",function(plr,cmd)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
--CL_fractions
local q = exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `fraction`=?",getElementData(plr,"fraction"))
local result = dbPoll(q,-1)
if result then
outputChatBox("Rangi we frakcji "..getElementData(plr,"fraction")..":",plr,255,255,255)
for _,v in ipairs(result) do
outputChatBox("- Ranga: "..v["Rang"].." / Zarobek: "..v["Payment"]..".",plr,255,255,0)
end
end
end
end
end
end)
addCommandHandler("frakcja_komendy",function(plr,cmd)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
outputChatBox(" - - - - - - - - - - - - - - - ",plr)
outputChatBox("/frakcja_typ cel typ - Ustawienie typu rangi (1-dow?dca ; 2-zast?pca ; 3-inna).",plr)
outputChatBox("/frakcja_usun cel - Usuwanie gracza z frakcji.",plr)
outputChatBox("/frakcja_dodaj cel ranga - Dodawanie do frakcji gracza.",plr)
outputChatBox("/frakcja_ranga cel ranga - Zmiana rangi we frakcji danego gracza.",plr)
outputChatBox("/frakcja_rangi - Rangi we frakcji.",plr)
outputChatBox("- - - - - - - - - - - - - - -",plr)
end
end
end
end)
setTimer(function()
for _,v in pairs(getElementsByType("player")) do
if isPlayerInTeam(v) and getElementData(v,"fraction") and getElementData(v,"fraction:duty") == "S3" then
exports["pystories-db"]:GdbExec("UPDATE pystories_users SET fraction_minutes=fraction_minutes+1 WHERE ID=?",tonumber(getElementData(v,"ID")))
end
end
end,60000,0)
[size=9][ [i][b]Dodano[/b]: 2018-07-11, 18:20[/i] ][/size]
function findPlayer(plr,cel)
local target=nil
if (tonumber(cel) ~= nil) then
target=getElementByID("p"..cel)
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(), 1, 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
return target
end
local frakcja_KGPLS = createTeam("KGP",0,0,255)
local frakcja_KGSPLS = createTeam("KGSP",255,0,0)
local frakcja_PRLS = createTeam("PR",50,100,200)
local fractions = { -- g??wne markery frakcji
--["nazwa_frakcji"]={x,y,z,dim,int},
["KGSP"]={1939.42,-1972.66,13.55,0,0},
["KGP"]={297.49,186.41,1007.17,1000,3},
["PR"]={936.28,-1536.94,13.55,0,0},
}
for _,v in pairs(fractions) do
local x,y,z = v[1],v[2],v[3]-1
local d,i = v[4],v[5]
local marker = createMarker(x,y,z,"cylinder",1.2,50,100,200,120,root)
setElementInterior(marker,i)
setElementDimension(marker,d)
setElementData(marker,"fraction:marker",true)
setElementData(marker,"fraction:marker:rgb",{r,g,b})
end
function isPlayerInTeam(player, team)
assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got "..tostring(player).."]")
assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got "..tostring(team).."]")
return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true)))
end
addEventHandler("onMarkerHit",resourceRoot,function(plr)
if plr and isElement(plr) and getElementType(plr) == "player" then
if tonumber(getElementData(plr,"player:sid")) then
if getElementData(plr,"fraction") then
if not isPedInVehicle(plr) then
if getElementData(source,"fraction:marker") == true then
triggerClientEvent(plr,"fraction:showButtons:startstop",plr,plr)
else
outputChatBox("Niezidentyfikowany b??d #1.",plr,255,0,0)
end
else
outputChatBox("Wpierw musiz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
end
else
outputChatBox("Nie jeste? zatrudniony w ?adnej frakcji!",plr,255,0,0)
end
else
outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany!",plr,255,0,0)
end
end
end)
addEvent("fraction:start:duty",true)
addEventHandler("fraction:start:duty",root,function(plr)
if plr and isElement(plr) and getElementType(plr) == "player" then
if tonumber(getElementData(plr,"player:sid")) then
if getElementData(plr,"fraction") then
if not isPedInVehicle(plr) then
local frakcja = false
if getElementData(plr,"fraction") == "KGP" then
frakcja = frakcja_KGPLS
elseif getElementData(plr,"fraction") == "KGSP" then
frakcja = frakcja_KGSPLS
elseif getElementData(plr,"fraction") == "PR" then
frakcja = frakcja_PRLS
end
local q = exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(plr,"player:sid")))
local result = dbPoll(q,-1)
if result then
for _,v in ipairs(result) do
if frakcja then
setPlayerTeam(plr,frakcja)
local dowodca = v["fraction_rang_commander"]
local ranga = v["fraction_rang"]
setElementData(plr,"fraction:rang",tostring(ranga))
setElementData(plr,"fraction:rang:commander",tonumber(dowodca))
setElementData(plr,"fraction:duty","S3")
outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
outputChatBox("* Rozpocz??e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
outputChatBox("* Twoja ranga we frakcji: "..tostring(ranga)..".",plr,0,255,0)
outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
end
end
end
else
outputChatBox("Wpierw musisz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
end
else
outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
end
else
outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
end
end
end)
addEvent("fraction:stop:duty",true)
addEventHandler("fraction:stop:duty",root,function(plr)
if plr and isElement(plr) and getElementType(plr) == "player" then
if tonumber(getElementData(plr,"player:Sid")) then
if getElementData(plr,"fraction") then
if getElementData(plr,"fraction:duty") == "S3" then
setElementModel(plr,getElementData(plr,"clothes"))
setPlayerTeam(plr,nil)
setElementData(plr,"fraction:duty",nil)
outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
outputChatBox("* Zako?czy?e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
else
outputChatBox("Wpierw musisz wej?? na duty, by m?c zako?czy? s?u?b?!",plr,255,0,0)
end
else
outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
end
else
outputChatBox("Aby zako?czy? s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
end
end
end)
function naliczajCzas()
if getElementData(source,"player:sid") then
if getElementData(source,"fraction") then
if getElementData(source,"fraction:duty") == "S3" then
if getElementData(source,"fraction:rang") then
setTimer(function()
local q = exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(source,"player:sid")))
local result = dbPoll(q,-1)
if result then
for _,v in ipairs(result) do
local minuty = v["fraction_minutes"]
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_minutes`=? WHERE ID=?",tonumber(minuty)+1,tonumber(getElementData(source,"player:sid")))
end
end
end,60000,0)
end
end
end
end
end
addCommandHandler("frakcja_ranga",function(plr,cmd,cel,ranga)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
if ranga then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang`=? WHERE login=?",ranga,tostring(cel))
if update then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
setElementData(odbiorca,"fraction:rang",ranga)
outputChatBox("* Ranga zosta?a zmieniona na: "..ranga..".",plr,255,255,255)
outputChatBox("* Twoja ranga we frakcji zosta?a zaktualizowana!",odbiorca,255,255,255)
else
outputChatBox("Nie znaleziono celu! Ranga zosta?a zmieniona w bazie danych.",plr,255,0,0)
end
end
end
end
end
end
end
end)
addCommandHandler("frakcja_dodaj",function(plr,cmd,cel,ranga)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
if ranga then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?",getElementData(plr,"fraction"),ranga,3,getElementData(odbiorca,"login"))
if update then
outputChatBox("* Dodano "..getPlayerName(odbiorca).." do frakcji! Jego ranga: "..ranga..".",plr,255,255,255)
outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? dodany do "..getElementData(plr,"fraction")..". Twoja ranga: "..ranga..".",odbiorca,255,255,255)
setElementData(odbiorca,"fraction",getElementData(plr,"fraction"))
setElementData(odbiorca,"fraction:rang",tostring(ranga))
setElementData(odbiorca,"fraction:rang:commander",3)
end
else
outputChatBox("Nie znaleziono celu!",plr,255,0,0)
end
end
end
end
end
end
end)
addCommandHandler("frakcja_usun",function(plr,cmd,cel)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?","","",0,getElementData(odbiorca,"login"))
if update then
outputChatBox("* Wyrzucono "..getPlayerName(odbiorca).." z Twojej frakcji!",plr,255,255,255)
outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? wyrzucony z "..getElementData(plr,"fraction")..".",odbiorca,255,0,0)
setElementData(odbiorca,"fraction",false)
setElementData(odbiorca,"fraction:rang",false)
setElementData(odbiorca,"fraction:rang:commander",false)
setPlayerTeam(odbiorca,nil)
setElementData(odbiorca,"fraction:duty",false)
end
else
outputChatBox("Nie znaleziono celu!",plr,255,0,0)
end
end
end
end
end
end)
addCommandHandler("frakcja_typ",function(plr,cmd,cel,typ)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
if cel then
local odbiorca = findPlayer(plr,cel)
if odbiorca then
if typ and tonumber(typ) and tonumber(typ) < 4 then
local update = exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang_commander`=? WHERE login=?",typ,getElementData(odbiorca,"login"))
if update then
outputChatBox("* Zmieniono typ rangi dla "..getPlayerName(odbiorca).." ; nowy typ rangi: "..typ..".",plr,255,255,255)
outputChatBox("* Tw?j typ rangi we frakcji zosta? zaktualizowany! Aktualny typ rangi: "..typ.."",odbiorca,255,0,0)
setElementData(odbiorca,"fraction:rang:commander",false)
end
else
outputChatBox("Typ: 1-dow?dca frakcji ; 2-zast?pca frakcji ; 3-inna. ",plr,255,0,0)
end
else
outputChatBox("Nie znaleziono celu!",plr,255,0,0)
end
end
end
end
end
end)
addCommandHandler("frakcja_rangi",function(plr,cmd)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
--CL_fractions
local q = exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `fraction`=?",getElementData(plr,"fraction"))
local result = dbPoll(q,-1)
if result then
outputChatBox("Rangi we frakcji "..getElementData(plr,"fraction")..":",plr,255,255,255)
for _,v in ipairs(result) do
outputChatBox("- Ranga: "..v["Rang"].." / Zarobek: "..v["Payment"]..".",plr,255,255,0)
end
end
end
end
end
end)
addCommandHandler("frakcja_komendy",function(plr,cmd)
if plr and getElementData(plr,"fraction") then
if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 or getElementData(plr,"fraction:rang:commander") == 2 then
if getElementData(plr,"fraction:duty") == "S3" then
outputChatBox(" - - - - - - - - - - - - - - - ",plr)
outputChatBox("/frakcja_typ cel typ - Ustawienie typu rangi (1-dow?dca ; 2-zast?pca ; 3-inna).",plr)
outputChatBox("/frakcja_usun cel - Usuwanie gracza z frakcji.",plr)
outputChatBox("/frakcja_dodaj cel ranga - Dodawanie do frakcji gracza.",plr)
outputChatBox("/frakcja_ranga cel ranga - Zmiana rangi we frakcji danego gracza.",plr)
outputChatBox("/frakcja_rangi - Rangi we frakcji.",plr)
outputChatBox("- - - - - - - - - - - - - - -",plr)
end
end
end
end)
setTimer(function()
for _,v in pairs(getElementsByType("player")) do
if isPlayerInTeam(v) and getElementData(v,"fraction") and getElementData(v,"fraction:duty") == "S3" then
exports["pystories-db"]:GdbExec("UPDATE pystories_users SET fraction_minutes=fraction_minutes+1 WHERE ID=?",tonumber(getElementData(v,"ID")))
end
end
end,60000,0)