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

Wysłany: 2019-12-26, 23:55


Mazeusz







Wiek: 30
Na forum: 2673 dni
Posty: 52
Nick w MP: Mazeusz*



Respekt: 50

Ostrzeżeń: 80%
Witam pr?buje zrobi? ?eby da?o si? dodawa? auta do organizacji, gdy przepisuje auto ca?y czas mam komunikat ?e nie jestem w organizacji pr?bowa?em pozmienia? moj? baz? danych ale nie wychodzi.

server
--[[
    Developed by Yolos You dont have agree to use this code! ;3
]]

function refreshgui(element)
    local uid=getElementData(element,"player:uid")
    if not uid then return end
    local result=exports["tiyl-db"]:dbGet("SELECT tiyl_pojazdy.model,tiyl_pojazdy.id,tiyl_pojazdy.ownedGroup,tiyl_organizacje.name FROM tiyl_pojazdy left join tiyl_organizacje on tiyl_organizacje.id=tiyl_pojazdy.ownedGroup WHERE ownedPlayer=?"uid)
    triggerClientEvent(element"org:refresh"resourceRootresult)
end

addEvent("org:check"true)
addEventHandler("org:check"resourceRoot, function(id,name)
    -- Pobieramy UID gracza
    local uid=getElementData(client,"player:uid")
    if not uid then return end
    -- Sprawdzamy czy jest jeszcze w?a?cicielem
    local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_pojazdy WHERE id=? AND ownedPlayer=?"iduid)
    if #result < 0 then 
        outputChatBox("* Nie jeste? w?a?cicielem pojazdu."client25500)
        return
    end
    local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_pojazdy WHERE id=? AND parking=0"id)
    if #result > 0 then 
        outputChatBox("* Pojazd nie jest w przechowalni!."client25500)
        return
    end
    local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_pojazdy WHERE id=? AND ownedPlayer=?"iduid)
    if #result > 0 then 
        if result[1].ownedGroup ~= "0" then 
            local query=exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET ownedGroup=0 WHERE id=? AND ownedPlayer=?"iduid)
            outputChatBox("* Zmieni?e? pojazdowi "..name.."("..id..") przypis na siebie"client)
            refreshgui(client)
            return
        end
    local org getElementData(client,"player:organization:id")
    if not org then outputChatBox("Nie jeste? w frakcji!",client,255,0,0) return end
    local query=exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET ownedGroup=? WHERE id=? AND ownedPlayer=?"orgiduid)
    if query then
        outputChatBox("* Zmieni?e? pojazdowi "..name.."("..id..") przypis na frakcje"client)
        refreshgui(client)
    end
    end
end)

addEvent("org:download"true)
addEventHandler("org:download"resourceRootrefreshgui)


Baza
https://imgur.com/a/5f0vczl

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 00:05


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

Domy?lam si? ?e pisz?c: "komunikat nie jestem w organizacji" chodzi?o Ci o: "Nie jeste? w frakcji!"

Przeanalizuj kod, masz tam

getElementData(client,"player:organization:id")


i je?li gracz jej nie posiada to wtedy pojawia si? w?a?nie ten komunikat.

spr?buj stworzy? zamiast pobierania elementdaty export kt?ry sprawdza czy gracz jest w danej organizacji, b?d? w miejscu wczytywania statystyk zr?b nak?adanie elementDaty kt?rej w?a?nie gracz obecnie nie posiada.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 00:06


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Nie wiem, zobacz czy elementdata player:organization:id jest dobra?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 00:44


Mazeusz







Wiek: 30
Na forum: 2673 dni
Posty: 52
Nick w MP: Mazeusz*



Respekt: 50

Ostrzeżeń: 80%
Zrobi?em takie cu?, ale nadal nie dziala ;p
    local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_organizacje WHERE uid=?"iduid) 
    if not org then outputChatBox("Nie jeste? w frakcji!",client,255,0,0) return end
    local query=exports["tiyl-db"]:dbSet("UPDATE tiyl_pojazdy SET ownedGroup=? WHERE id=? AND ownedPlayer=?"orgiduid)
    if query then
        outputChatBox("* Zmieni?e? pojazdowi "..name.."("..id..") przypis na frakcje"client)
        refreshgui(client)
    end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 00:59


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

Zobacz ?e wynik exportu masz jako "result" a sprawdzasz nadal "org"

w dodatku w exporcie [..]", id, uid) usu? "id", gdy? to jest niepotrzebne, i przeszkadza w sprawdzeniu, no chyba ?e jego warto?? jest r?wna UID gracza

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 01:27


Mazeusz







Wiek: 30
Na forum: 2673 dni
Posty: 52
Nick w MP: Mazeusz*



Respekt: 50

Ostrzeżeń: 80%
local query=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_organizacje WHERE uid=?"uid) 
    if not org then outputChatBox("Nie jeste? w frakcji!",client,255,0,0) return end
Co? takiego

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 01:40


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

"Mazeusz" napisał/a:

local query=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_organizacje WHERE uid=?"uid) 
    if not org then outputChatBox("Nie jeste? w frakcji!",client,255,0,0) return end
Co? takiego


Teraz poprawi?e? w exporcie, ale zobacz co napisa?em na samym pocz?tku poprzedniej odpowiedzi
masz
if not org

czyli nadal sprawdzasz "org" - zmie? je na
if #query < 1 then


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 15:32


Mazeusz







Wiek: 30
Na forum: 2673 dni
Posty: 52
Nick w MP: Mazeusz*



Respekt: 50

Ostrzeżeń: 80%
Okej dzia?a tylko ze w gui nie pokazuje si? Nazwa organizacji

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 17:18


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

"Mazeusz" napisał/a:

Okej dzia?a tylko ze w gui nie pokazuje si? Nazwa organizacji


Podaj kod kt?ry odpowiada za wy?wietlanie nazwy organizacji w gui

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-27, 17:32


Mazeusz







Wiek: 30
Na forum: 2673 dni
Posty: 52
Nick w MP: Mazeusz*



Respekt: 50

Ostrzeżeń: 80%
Dobra ogarn??em to zmieniaj?c skrypt tylko ?e ma inne Element daty i gdy wychodze z serwera nie zapisuje pr?bowa?em doda?, ale na nic.

Skrypt odpowiedzialny za zapis

--[[
    ResourceOURGame v2
    DevelopersSplit <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c2015 <split.programista@gmail.com>. All rights reserved.
]]

function loadPlayerData(plr)
    local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_gracze WHERE id=?"getElementData(plr,"player:uid"))
    if result and #result > 0 then
        local v=result[1]
        setPlayerMoney(plr,v.money)
        setElementModel(plr,v.skin)
        setElementData(plr,"status","Aktywny")
        setElementData(plr,"user:nickname",v.login1)
        setElementData(plr,"player:logged",true)
        setElementData(plr,"player:license:pjA",v.pjA)
        setElementData(plr,"player:license:pjB",v.pjB)
        setElementData(plr,"player:license:pjC",v.pjC)
        setElementData(plr,"player:license:pjL",v.pjL)
        setElementData(plr,"player:reputation",v.reputation)
        setElementData(plr,"player:workinjob",v.worker)
        setElementData(plr,"player:registerdate",v.registered)
        setElementData(plr,"player:hours",v.hours)
        setElementData(plr,"user:oranga",v.orank)
        setElementData(plr,"user:org",v.org)
        setElementData(plr,"p:title",v.rp_tytul)
        setElementData(plr,"player:scorespedytor"v.scorespedytor)
        setElementData(plr,"nanky:x",v.nankyx)
        setElementData(plr,"nanky:y",v.nankyy)
        setElementData(plr,"nanky:z",v.nankyz)
        local queryA=string.format("SELECT * FROM tiyl_gracze WHERE id=%d AND vipdate>NOW() LIMIT 1"getElementData(plr,"player:uid"))
        local resultA=exports["tiyl-db"]:pobierzWyniki(queryA)
        if (resultAthen
            setElementData(plr,"player:vip",true)
            setElementData(plr,"player:vipdate",v.vipdate)
            setPlayerName(plr,"#FFD700"..getPlayerName(plr))
        else
            setElementData(plr,"player:vip",false)
        end
        local queryA=string.format("SELECT * FROM tiyl_gracze WHERE id=%d AND svipdate>NOW() LIMIT 1"getElementData(plr,"player:uid"))
        local resultA=exports["tiyl-db"]:pobierzWyniki(queryA)
        if (resultAthen
            setElementData(plr,"player:svip",true)
            setElementData(plr,"player:svipdate",v.svipdate)
            setPlayerName(plr,"#FFBF00"..getPlayerName(plr))
        else
            setElementData(plr,"player:svip",false)
        end
        setElementData(plr,"player:skin",v.skin)
        local org=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_gracze WHERE org=? LIMIT 1"getElementData(plr,"player:uid")) -- pobieramy tylko JEDEN rekord
        if org and #org > 0 then
            setElementData(plr,"organizacja",org[1].code)
            exports['tiyl-db']:dbSet("UPDATE organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:uid"))
        end
        return true
    end
    return false
end

function savePlayerData(plr,quitType)
    local uid=getElementData(plr,"player:uid")
    if not uid then return end
    
    local money=getPlayerMoney(plr)
    local reputation=getElementData(plr,"player:reputation")
    local licensea=getElementData(plr,"player:license:pjA")
    local licenseb=getElementData(plr,"player:license:pjB")
    local licensec=getElementData(plr,"player:license:pjC")
    local licensel=getElementData(plr,"player:license:pjL")
    local minuty=getElementData(plr,"player:hours")
    local minutyduty=getElementData(plr,"player:workinjob")
    local rypy=getElementData(plr,"p:title")
    local scorespedytor=getElementData(plr,"player:scorespedytor")
    local xygetElementPosition(plr)
    local query=exports["tiyl-db"]:dbSet("UPDATE tiyl_gracze SET money=?, reputation=?, pjA=?, pjB=?, pjC=?, pjL=?, hours=?, worker=?, rp_tytul=?, scorespedytor=?, nankyx=?, nankyy=?, nankyz=? WHERE id=?"moneyreputationlicensealicenseblicenseclicenselminutyminutydutyrypyscorespedytorxyzuid)
    
    if quitType then
        exports["tiyl-db"]:dbSet("INSERT INTO Logi_wyjscie_serwer (uid,nick,quitType,serial,date,saved) VALUES (?,?,?,?,NOW(),?)"uidgetPlayerName(plr), quitTypegetPlayerSerial(plr), "zapisano")
        outputDebugString("Zapisano statystyki gracza "..getPlayerName(plr)..", pow?d wyj?cia: "..string.lower(quitType))
    else
        exports["tiyl-db"]:dbSet("INSERT INTO Logi_wyjscie_serwer (uid,nick,quitType,serial,date,saved) VALUES (?,?,?,?,NOW(),?)"uidgetPlayerName(plr), "brak powodu wyj?cia"getPlayerSerial(plr), "zapisano")
        outputDebugString("Zapisano statystyki gracza "..getPlayerName(plr))
    end
end
addEventHandler("onPlayerQuit"root, function() savePlayerData(sourceend)

addEvent("antyLost"true)
addEventHandler("antyLost"root, function()
local result=exports["tiyl-db"]:dbGet("SELECT * FROM tiyl_gracze WHERE id=?"getElementData(client"player:uid"))
if result[1].login2 == false then
setPlayerName(client,result[1].login)
else
setPlayerName(clientresult[1].login2)
end
loadPlayerData(client)
end)


Oraz jak dany gracz dolacza to ca?y serwer tez :P P

addEvent("oDodaj"true)
addEventHandler("oDodaj"root, function(pp2)
    if not p and not p2 then return end
    local graczhere findPlayer(pp2)
    if not graczhere then
        exports["np-notyfikacje"]:noti("Nie znaleziono podanego gracza."p)
        return
    end
    if getElementData(graczhere"org"then
        exports["np-notyfikacje"]:noti("Podany gracz posiada organizacje."p)
        return
    end
    exports["np-notyfikacje"]:noti("Wys?ano zaproszenie o do??czenie do organizacji graczu "..getPlayerName(graczhere), p)
    setElementData(graczhere"zaproszenie", {
        ["id"] = getElementData(p"org"),
        ["nazwa"] = getElementData(p"organizacja"),
        ["dodany"] = p,
    })
    outputChatBox("Otrzyma?e? zaproszenie do orgnizacji "..getElementData(p"organizacja"), graczhere)
    outputChatBox("Aby do??czy? u?yj: /dolacz "..getElementData(p"org"), graczhere)
    setTimer(function()
        setElementData(graczhere"zaproszenie"false)
    end300001)
end)

addCommandHandler("dolacz", function(playercmdidd)
    local zaproszenie getElementData(player"zaproszenie")
    if zaproszenie then
        if not idd then
            exports["np-notyfikacje"]:noti("Poprawne u?ycie: /"..cmd.." <id organizacji>"player)
            return
        end
        outputChatBox(getPlayerName(player).." przyj?? zaproszenie do organizacji."p)
        exports["np-notyfikacje"]:noti("Przyj??e? zaproszenie do organizacji "..zaproszenie.nazwaplayer)
        setElementData(player"oranga"1)
        setElementData(player"org"zaproszenie.id)
        setElementData(player"organizacja"zaproszenie.nazwa) 
        exports.mysql:wykonaj("UPDATE tiyl_gracze SET org=? WHERE id=?"zaproszenie.idgetElementData(player"id"))
        setElementData(player"zaproszenie"false)
    else
        exports["np-notyfikacje"]:noti("Nie posiadasz zaproszenia do organizacji."player)
    end
end)


Postaw piwo autorowi tego posta
 

 
Tagi: nie :: mogę :: dodać :: pojazdu :: org
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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