Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2017-05-15, 12:27


wojakmati







Wiek: 29
Na forum: 3576 dni
Posty: 8
Nick w MP: AlabamaJustice



Respekt: 36,3

Ostrzeżeń: 80%
Witam zamieszczam zdj?cie 2 linijek b??du wraz z kawa?kiem kodu


linijki od 85

function loadFactionData(q, q2)
   guiSetText(window2, q2['nazwa'])
   details = q2

145
 addEventHandler("onClientGUIClick", add_accept2, function ()
      if not selected then
         outputChatBox("Nie wybra?e?/a? osoby do dodania", 255, 0, 0)
         return
      end
      triggerServerEvent("addToFaction", localPlayer, selected, details['username'], details['uid'])
      destroyElement(add_window2)
   end, false)
end


Dodaje znaczniki lua //Emm

Ostatnio zmieniony przez Emm 2017-05-15, 16:37, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-05-15, 12:58


Allansso







Wiek: 25
Na forum: 4079 dni
Posty: 386

Piwa: 1546

Respekt: 180
Respekt: 180Respekt: 180

Ostrzeżeń: 100%
Masz skrypt pod??czony pod baz? danych?

Podpis
https://www.youtube.com/TheMikol
https://www.facebook.com/TheMikol1337
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-05-15, 14:29


wojakmati







Wiek: 29
Na forum: 3576 dni
Posty: 8
Nick w MP: AlabamaJustice



Respekt: 36,3

Ostrzeżeń: 80%
tak

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-05-15, 14:33


Allansso







Wiek: 25
Na forum: 4079 dni
Posty: 386

Piwa: 1546

Respekt: 180
Respekt: 180Respekt: 180

Ostrzeżeń: 100%
Podaj mo?e ca?y kod

function loadFactionData(q, q2)
guiSetText(window2, q2['nazwa'])
details = q2
 

Masz w kodzie funkcje q?

Podpis
https://www.youtube.com/TheMikol
https://www.facebook.com/TheMikol1337
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-05-15, 14:37


wojakmati







Wiek: 29
Na forum: 3576 dni
Posty: 8
Nick w MP: AlabamaJustice



Respekt: 36,3

Ostrzeżeń: 80%
--[[
   System panelu frakcji
1
1
]]

local sw,sh = guiGetScreenSize()
local details = false
local selected = false

function openFactionWindow()
   if isElement(window2) then destroyElement(window2) showCursor(false) return end

   if getElementData(localPlayer, "op:block") then
      outputChatBox("Musisz chwil? odczeka?...", 255, 0, 0)
      return
    end

   showCursor(true)

   setElementData(localPlayer, "op:block", true)
   setTimer(function ()
      setElementData(localPlayer, "op:block", false)
   end, 2000, 1)

   window2 = guiCreateWindow(sw/2-300, sh/2-150, 600, 300, "Frakcja", false)
   guiWindowSetSizable(window2, false)

   grid2 = guiCreateGridList(0, 0.08, 0.6, 1, true, window2)
   col12 = guiGridListAddColumn(grid2, "Nazwa gracza", 0.5)
   col22 = guiGridListAddColumn(grid2, "Status", 0.2)
   col32 = guiGridListAddColumn(grid2, "Ranga", 0.2)
  btn_add2 = guiCreateButton(0.63, 0.31, 0.35, 0.15, "Dodaj gracza", true, window2)
  btn_edit2 = guiCreateButton(0.63, 0.48, 0.35, 0.15, "Edytuj gracza", true, window2)
  guiSetEnabled(btn_edit2, false)
  btn_kick2 = guiCreateButton(0.63, 0.65, 0.35, 0.15, "Wyrzu? gracza", true, window2)
  guiSetEnabled(btn_kick2, false)
   btn_close2 = guiCreateButton(0.63, 0.82, 0.35, 0.15, "Zamknij", true, window2)

   triggerServerEvent("getFactionPlayers", localPlayer)

   addEventHandler("onClientGUIClick", btn_close2, function ()
      destroyElement(window2)
      showCursor(false)
      if isElement(add_window2) then destroyElement(add_window2) end
      hideEditWindow()
   end, false)

   addEventHandler("onClientGUIClick", grid2, userClick, false)
   addEventHandler("onClientGUIClick", btn_kick2, kickFromFaction, false)
   addEventHandler("onClientGUIClick", btn_add2, showAddWindow, false)
   addEventHandler("onClientGUIClick", btn_edit2, showEditWindow, false)
end
addEvent("openFactionWindow", true)
addEventHandler("openFactionWindow", root, openFactionWindow)

function userClick()
   local selected = guiGridListGetSelectedItem(grid2)
   if selected == -1 then
      guiSetEnabled(btn_edit2, false)
      guiSetEnabled(btn_kick2, false)
   else
      guiSetEnabled(btn_edit2, true)
      guiSetEnabled(btn_kick2, true)
   end
end

function kickFromFaction()
   local selected = guiGridListGetSelectedItem(grid2)
   if selected == -1 then return end
   local uid = guiGridListGetItemData(grid2, selected, col12)
   local name = guiGridListGetItemText(grid2, selected, col12)
   local ranga = guiGridListGetItemData(grid2, selected, col32)
   triggerServerEvent("kickFromFaction", localPlayer, uid, name, ranga, details['nazwa'])
end

function reloadFactionList()
   guiGridListClear(grid2)
   triggerServerEvent("getFactionPlayers", localPlayer)
end
addEvent("reloadFactionList", true)
addEventHandler("reloadFactionList", getRootElement(), reloadFactionList)

function loadFactionData(q, q2)
   guiSetText(window2, q2['nazwa'])
   details = q2

   for i,v in ipairs(q) do
      local row = guiGridListAddRow(grid2)
      guiGridListSetItemText(grid2, row, col12, v['username'], false, false)
      guiGridListSetItemData(grid2, row, col12, v['uid'], false, false)
      if getPlayerFromName(v['username']) then
         guiGridListSetItemText(grid2, row, col22, "ONLINE", false, false)
         guiGridListSetItemColor(grid2, row, col22, 0, 255, 0)
      else
         guiGridListSetItemText(grid2, row, col22, "OFFLINE", false, false)
         guiGridListSetItemColor(grid2, row, col22, 255, 0, 0)
      end

      local ranga = "Nieznana"
      if v['franga'] == 1 then ranga = q2['ranga1'] end
      if v['franga'] == 2 then ranga = q2['ranga2'] end
      if v['franga'] == 3 then ranga = q2['ranga3'] end
      if v['franga'] == 4 then ranga = q2['ranga4'] end
      if v['franga'] == 5 then ranga = q2['ranga5'] end
      guiGridListSetItemText(grid2, row, col32, ranga, false, false)
      guiGridListSetItemData(grid2, row, col32, v['franga'], false, false)
   end
end
addEvent("loadFactionData", true)
addEventHandler("loadFactionData", getRootElement(), loadFactionData)

function showAddWindow()
   if isElement(add_window2) then return end
   add_window2 = guiCreateWindow(sw/2-150, sh/2-70, 300, 140, "Wpisz nazw? gracza", false)
   add_username2 = guiCreateEdit(0.1, 0.25, 0.8, 0.2, "", true, add_window2)
   add_label2 = guiCreateLabel(0.1, 0.5, 0.8, 0.15, "", true, add_window2)
   guiLabelSetVerticalAlign(add_label2, "center")
   guiLabelSetHorizontalAlign(add_label2, "center")
   add_accept2 = guiCreateButton(0.1, 0.7, 0.39, 0.2, "Dodaj", true, add_window2)
   add_cancel2 = guiCreateButton(0.49, 0.7, 0.41, 0.2, "Anuluj", true, add_window2)

   addEventHandler("onClientGUIClick", add_cancel2, function ()
      destroyElement(add_window2)
   end, false)

   addEventHandler("onClientGUIChanged", add_username2, function ()
      local target = findPlayer(localPlayer, guiGetText(add_username2))
      if not target then
         guiSetText(add_label2, "Nie znaleziono takiego gracza")
         guiLabelSetColor(add_label2, 255, 0, 0)
         selected = false
      else
         selected = target
         guiSetText(add_label2, "Znaleziono gracza ("..getPlayerName(target)..")")
         guiLabelSetColor(add_label2, 0, 255, 0)
      end
   end)

   addEventHandler("onClientGUIClick", add_accept2, function ()
      if not selected then
         outputChatBox("Nie wybra?e?/a? osoby do dodania", 255, 0, 0)
         return
      end
      triggerServerEvent("addToFaction", localPlayer, selected, details['username'], details['uid'])
      destroyElement(add_window2)
   end, false)
end

function showEditWindow()
   if isElement(edit_window2) then return end
   edit_window2 = guiCreateWindow(sw/2-150, sh/2-70, 300, 140, "Edycja cz?onka grupy", false)
   edit_combo2 = guiCreateComboBox(0.2, 0.3, 0.6, 0.8, "Ranga gracza", true, edit_window2)
   edit_baccept2 = guiCreateButton(0, 0.7, 0.47, 0.25, "Zapisz", true, edit_window2)
   edit_bcancel2 = guiCreateButton(0.5, 0.7, 0.47, 0.25, "Anuluj", true, edit_window2)

   local fid = getElementData(localPlayer, "user:fid")
   triggerServerEvent("getFactionRanks", localPlayer, fid)

   addEventHandler("onClientGUIClick", edit_baccept2, updateRank2, false)
   addEventHandler("onClientGUIClick", edit_bcancel2, hideEditWindow, false)
end

function hideEditWindow()
   if not isElement(edit_window2) then return end
   destroyElement(edit_window2)
end
addEvent("hideEditWindow2", true)
addEventHandler("hideEditWindow2", getRootElement(), hideEditWindow)

function addToEditWindow(q)
   guiComboBoxAddItem(edit_combo2, q[1]['ranga1'])
   guiComboBoxAddItem(edit_combo2, q[1]['ranga2'])
   guiComboBoxAddItem(edit_combo2, q[1]['ranga3'])
   guiComboBoxAddItem(edit_combo2, q[1]['ranga4'])
end
addEvent("addToEditWindow2", true)
addEventHandler("addToEditWindow2", getRootElement(), addToEditWindow)

function updateRank2()
   local selected = guiComboBoxGetSelected(edit_combo2)
   local selected2 = guiGridListGetSelectedItem(grid2)
   if selected2 == -1 then
      outputChatBox("Nie wybrano gracza to edycji...", 255, 0, 0)
      return
   end
   if selected == -1 then
      outputChatBox("Musisz wybra? rang?, kt?r? chcesz ustawi?...", 255, 0, 0)
      return
   end
   triggerServerEvent("updateRank2", localPlayer, guiGridListGetItemData(grid2, selected2, col12), selected+1)
end

addEventHandler("onClientResourceStart", resourceRoot, function ()
   setElementData(localPlayer, "op:block", false)
end)



---------------
---- UTILS ----
---------------
function findPlayer(plr, cel)
    local target = nil
    if (tonumber(cel) ~= nil) then
        target = getElementByID("p"..cel)
    else
        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
                    return nil
                end
                target=thePlayer
            end
        end
    end
    return target
end

fileDelete("c.lua")


Ostatnio zmieniony przez Emm 2017-05-15, 16:36, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-05-15, 14:48


Allansso







Wiek: 25
Na forum: 4079 dni
Posty: 386

Piwa: 1546

Respekt: 180
Respekt: 180Respekt: 180

Ostrzeżeń: 100%
function loadFactionData(q2)
guiSetText(window2, q2['nazwa'])
details = q2


Podpis
https://www.youtube.com/TheMikol
https://www.facebook.com/TheMikol1337
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-05-15, 15:38


wojakmati







Wiek: 29
Na forum: 3576 dni
Posty: 8
Nick w MP: AlabamaJustice



Respekt: 36,3

Ostrzeżeń: 80%
daje te? stron? serwera gdy? tamta zmiana spowodowa?a wi?cej b??d?w

--[[
   System panelu frakcji
1
1
]]

function getPlayers()
   local q = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_accounts WHERE frakcja=? ORDER BY oranga DESC", getElementData(source, "user:fid"))
   local fid = getElementData(source, "user:fid") or 0
   local q2 = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_factions WHERE uid=?", fid)
   if q then
      triggerClientEvent(source, "loadFactionData", source, q, q2[1])
   end
end
addEvent("getFactionPlayers", true)
addEventHandler("getFactionPlayers", getRootElement(), getPlayers)

function kickFromFaction(uid, name, franga, fname)
  if franga > 4 then
     outputChatBox("Nie mo?esz wyrzuci? z lidera z frakcji!", source, 255, 0, 0)
     return
  end
  
   local q = exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET frakcja=0 WHERE uid=?", uid)

   local target = getPlayerFromName(name)
   if target then
      setElementData(target, "user:fid", 0)
      outputChatBox("Zosta?e?/a wykopany/a z frakcji "..fname.."!", target, 255, 0, 0)
      setElementData(target, "user:fdata", false)
   end
   outputChatBox("Gracz "..getElementData(target, "user:username").." zosta?/a wykopany/a z frakcji!", source, 255, 0, 0)
   triggerClientEvent(source, "reloadFactionList", source)
end
addEvent("kickFromFaction", true)
addEventHandler("kickFromFaction", getRootElement(), kickFromFaction)

function addToFaction(target, fname, fid)
   if not fid or not fname then
      outputChatBox("Wyst?pi? pewien problem, spr?buj ponownie p??niej..", source, 255, 0, 0)
      return
   end
   if not getElementData(target, "user:uid") then
      outputChatBox("Gracz nie jest zalogowany", source, 255, 0, 0)
      return
   end
   local result = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_accounts WHERE uid=?", getElementData(target, "user:uid"))
   if result[1].frakcja < 0 then
      outputChatBox("Gracz znajduje si? ju? w innej frakcji", source, 255, 0, 0)
      return
   end

   local q = exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET frakcja=?, franga=? WHERE uid=?", tonumber(fid), 1, getElementData(target, "user:uid"))
   local q2 = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_factions WHERE uid=?", tonumber(oid))
   if q then
      outputChatBox("Gracz "..getElementData(target, "user:username").." zosta? dodany do frakcji!", source, 0, 255, 0)
      outputChatBox("Gracz "..getElementData(source, "user:username").." doda? ci? do frakcji "..fname.."!", target, 0, 255, 0)
      setElementData(target, "user:fid", tonumber(fid))
      setElementData(target, "user:frank", 1)
      setElementData(target, "user:fdata", q2)
      triggerClientEvent(source, "reloadFactionList", source)
   else
      outputChatBox("Wyst?pi? pewien problem, spr?buj ponownie p??niej..", source, 255, 0, 0)
   end
end
addEvent("addToFaction", true)
addEventHandler("addToFaction", getRootElement(), addToFaction)

function getFactionRanks(oid)
   local q = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_factions WHERE uid=?", tonumber(oid))
   if q then
      triggerClientEvent(source, "addToEditWindow2", source, q)
   else
      outputChatBox("Wyst?pi? pewien problem, spr?buj ponownie p??niej..", source, 255, 0, 0)
   end
end
addEvent("getFactionRanks", true)
addEventHandler("getFactionRanks", getRootElement(), getFactionRanks)

function updateRank(uid, rank)
  local target = findPlayerByUID(uid)
  if getElementData(target, "user:frank") == 5 then
    outputChatBox("Nie mo?esz edytowa? lidera.", 255, 0, 0)
    return
  end
  if target then
    outputChatBox("Twoja ranga w frakcji zosta?a zaktualizowana", target, 0, 255, 0)
    setElementData(target, "user:frank", rank)
  end
  outputChatBox("Ranga tego gracza w frakcji zosta?a zaktualizowana", source, 0, 255, 0)
  triggerClientEvent(source, "hideEditWindow2", source)
  triggerClientEvent(source, "reloadFactionList", source)
  exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET franga=? WHERE uid=?", tonumber(rank), tonumber(uid))
end
addEvent("updateRank2", true)
addEventHandler("updateRank2", getRootElement(), updateRank)

local markery = {
{2498.9521484375, -1713.6923828125, 1339.9281005859, "TCSA", 0, 1},
{-2407.5983886719, -125.20780944824, 41.703285217285, "SAFD", 0, 0},
{216.5166015625, 109.4423828125, 1003.21875, "SAPD", 3, 10},
}

for i, v in pairs(markery) do
  local marker = createMarker(v[1], v[2], v[3]-1, "cylinder", 2, 255, 0, 0, 75)
  setElementDimension(marker, v[5])
  setElementInterior(marker, v[6])
  setElementData(marker, "marker:faction", v[4])
  local text = createElement("text")
  setElementData(text, "text", "Panel frakcji "..v[4])
  setElementPosition(text, v[1], v[2], v[3])
  setElementDimension(text, v[5])
  setElementInterior(text, v[6])
end

addEventHandler("onMarkerHit", resourceRoot, function(hit)
  if getElementData(hit, "user:faction") ~= getElementData(source, "marker:faction") then
    outputChatBox("Nie posiadasz uprawnie? lub nie ma cie na s?uzbie frakcji.", hit, 255, 0, 0)
    return
  end
  local ranga = getElementData(hit, "user:frank")
  if ranga == 4 or ranga == 5 then
    triggerClientEvent(hit, "openFactionWindow", hit)
  else
    outputChatBox("Nie posiadasz uprawnie? do panelu frakcji.", hit, 255, 0, 0)
    end
end)

---------------
---- UTILS ----
---------------
function findPlayerByUID(uid)
   for i,v in ipairs(getElementsByType("player")) do
      if getElementData(v, "user:uid") == tonumber(uid) then
         return v
      end
   end
   return false
end


Komentarz Emm dodany 2017-05-15, 16:36Stosuj znaczniki lua/code //Emm
Ostatnio zmieniony przez Emm 2017-05-15, 16:38, w całości zmieniany 5 razy  
Postaw piwo autorowi tego posta
 

 
Tagi: panel :: lidera :: frakcji-brak :: reakcji
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Panel lidera frakcji-brak reakcji Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku