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

Wysłany: 2019-02-14, 18:22


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot??, mam skrypt na org, wszystko git dzia?a zak?adanie itd. Jak wchodz? na serwer wszystko w mysql git si? zapisuje. Tylko gdy wbijam na serwer nie mam danej organizacji
kod na zapisy org
s_saveplayer.lua
--[[
    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 getPremium(plr,premium)
    if premium then
        local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE id=? AND premium=?",getElementData(plr,"player:uid"), premium)
        if result and #result > 0 then
            return true
        else
            return false
        end
    else
        local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE id=?"getElementData(plr,"player:uid"))
        if result and #result > 0 then
            return true
        else
            return false
        end
    end
end


function loadPlayerData(plr)
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users 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,"player:mandate",v.mandate)
        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:pjD",v.pjD)
        setElementData(plr,"player:license:pjL",v.pjL)
        setElementData(plr,"player:reputation",v.reputation)
        setElementData(plr,"player:movep",v.movep)
        setElementData(plr,"player:workinjob",v.worker)
        setElementData(plr,"player:registerdate",v.registered)
        setElementData(plr,"player:hours",v.hours)
        setElementData(plr,"player:skin",v.skin)
        setElementData(plr,"player:nickname"v.login)
        
        --local queryA=string.format("SELECT * FROM ogrpg_users WHERE id=%d AND premiumdate>NOW() LIMIT 1"getElementData(plr,"player:uid"))
        --local resultA=exports["ogrpg-db"]:dbSet(queryA)
        --if (resultAthen
        local resultA=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE id=? AND premiumdate>NOW() LIMIT 1"getElementData(plr,"player:uid"))
        if (resultA and #resultA > 0) then
            setElementData(plr,"player:premium",true)
            setElementData(plr,"player:premiumdate",v.premiumdate)
            setPlayerName(plr,"#FFFF00"..getPlayerName(plr))
        else
            setElementData(plr,"player:premium",false)
            setPlayerName(plr,getPlayerName(plr):gsub("#%x%x%x%x%x%x",""))
        end
        setElementData(plr,"player:skin",v.skin)

        
        local mute exports['ogrpg-db']:dbGet('select * from n_mute where serial=? AND time>now()',getPlayerSerial(plr))
        if #mute > 0 then
            setElementData(plr,'player:mute',true)
            outputChatBox('Jeste? wyciszony do: '..mute[1].time,plr)
        else
            exports['ogrpg-db']:dbSet('delete from n_mute where serial=?',getPlayerSerial(plr))
        end
        
        local org=exports["ogrpg-db"]:dbGet("SELECT * FROM tiyl_organizacje WHERE uid=? LIMIT 1"getElementData(plr,"player:uid")) -- pobieramy tylko JEDEN rekord
        if org and #org > 0 then
            setElementData(plr,"player:organization",org[1].code)
            exports['ogrpg-db']:dbSet("UPDATE tiyl_organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:uid"))
        end
        return true
    end
    return false
end

addEvent("load:player",true)
addEventHandler("load:player"root, function(player)
if isElement(player) and player then
if getElementType(player) ~= "player" then return end
loadPlayerData(player)
outputDebugString("ogrpg_users> Za?adowano statystyki gracza: "..getPlayerName(player))
end
end)
function savePlayerData(plr)
    local uid=getElementData(plr,"player:uid")
    if not uid then return end
    local money=getPlayerMoney(plr)
    local mandate=getElementData(plr,"player:mandate")
    local licensea=getElementData(plr,"player:license:pjA")
    local licenseb=getElementData(plr,"player:license:pjB")
    local licensec=getElementData(plr,"player:license:pjC")
    local licensed=getElementData(plr,"player:license:pjD")
    local licensel=getElementData(plr,"player:license:pjL")
    local reputation=getElementData(plr,"player:reputation")
    local movep=getElementData(plr,"player:movep")
    local worker =getElementData(plr,"player:workinjob")
    local hourstonumber(getElementData(plr,"player:hours")) or 0
    local query=exports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET money=?, reputation=?, movep=?,mandate=?, pjA=?, pjB=?, pjC=?, pjL=?, pjD=?,worker=?, hours=? WHERE id=?",
    moneyreputationmovep,mandatelicensealicenseblicenseclicensellicensed,workerhoursuid)
end
addEvent("save:player",true)
addEventHandler("save:player"root, function(player)
if isElement(player) and player then
if getElementType(player) ~= "player" then return end
savePlayerData(player)
outputDebugString("ogrpg_users> Zapisano statystyki gracza: "..getPlayerName(player))
end
end)
addEventHandler("onPlayerQuit"root, function() savePlayerData(sourceend)


Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-14, 18:35


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Co masz na my?li pisz?c 'nie ma danej organizacji'?
Nie dzia?a ich czat, nie ma organizacji w spisie na serwerze?

Odczytujesz poprawne elementDaty tam gdzie korzystasz z organizacji?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-14, 20:20


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Nie dzia?a, czat nie pokazuje na scorboardzie, tak jakby jej nie by?o, lecz w sql jest.

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Tagi: zapisy :: organizacji
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zapisy Organizacji 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