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

Wysłany: 2020-08-26, 01:53


Rumper

Majster od pysa






Wiek: 15
Na forum: 3315 dni
Posty: 231
Nick w MP: Rumper

Piwa: 592

Respekt: 180
Respekt: 180Respekt: 180

Ostrzeżeń: 20%
Witam. Chcia?bym zapisa? eldate "szybko"w mysql, wcze?niej robi?em w ten spos?b co teraz i mi dzia?a?o ale teraz jak robi? kolejny raz to nie wiem czemu mi nie dzia?a.
s_saveplayers

--[[
    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["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=? AND premium=?",getElementData(plr,"player:sid"), premium)
        if result and #result > 0 then
            return true
        else
            return false
        end
    else
        local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?"getElementData(plr,"player:sid"))
        if result and #result > 0 then
            return true
        else
            return false
        end
    end
end



function loadPlayerData(plr)
    local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?"getElementData(plr,"player:sid"))
    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:logged",true)
        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:pjL",v.pjL)
        setElementData(plr,"player:srp",v.srp)
        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,"marihuana",v.marihuana)
        setElementData(plr"szybko"v.zarobek)
                
        local queryA=string.format("SELECT * FROM pystories_users WHERE id=%d AND premiumdate>NOW() LIMIT 1"getElementData(plr,"player:sid"))
        local resultA=exports["DB2"]:pobierzWyniki(queryA)
        if (resultAthen
            setElementData(plr,"player:premium",true)
            setElementData(plr,"player:premiumdate",v.premiumdate)
            setPlayerName(plr,"#C0FF00"..getPlayerName(plr))
            setElementData(plr,"premium:level",1)
        else
            setElementData(plr,"player:premium",false)
        end

        
        --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
        
        
        --[[if getPremium(plr,1then
            setElementData(plr,"player:premium",true)
            setElementData(plr,"player:premiumdate",v.premiumdate)
            setPlayerName(plr,"#FFFF00"..getPlayerName(plr))
        else
            setElementData(plr,"player:premium",false)
        end--]]
        
        
        -- org
        --local org=exports["pystories-db"]:dbGet("SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1"getElementData(plr,"player:organization"), getElementData(plr,"player:sid")) -- pobieramy tylko JEDEN rekord
        --local name getPlayerName(plr):gsub("#%x%x%x%x%x%x","")
        --if org and #org > 0 then
            --setElementData(plr,"player:organization",org[1].code)
            --outputChatBox("* Jeste? w organizacji, kt?ra nosi nazwe: "..org[1].code..""plr)
            --exports['pystories-db']:dbSet("UPDATE ms_organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:sid"))
        --end
        
        --local org=exports["pystories-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE code=? AND uid=? LIMIT 1"getElementData(plr,"player:organization"), getElementData(plr,"player:sid"))
        --local org=exports["pystories-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE uid=? LIMIT 1"getElementData(plr,"player:sid")) -- pobieramy tylko JEDEN rekord
        --if org and #org > 0 then
            --setElementData(plr,"player:organization",org[1].code)
            --outputChatBox("* Jeste? w organizacji, kt?ra nosi nazwe: "..org[1].code..""plr)
            --exports['pystories-db']:dbSet("UPDATE ogrpg_organization_list WHERE id=? AND uid=?"iduid)
            --\\--exports['pystories-db']:dbSet("UPDATE ogrpg_organizations SET actived=curdate() WHERE uid=?"getElementData(plr,"player:sid"))
        --end
        
        local org=exports["pystories-db"]:dbGet("SELECT * FROM ms_organizacje WHERE code=? AND uid=? LIMIT 1"getElementData(plr,"player:organization"), getElementData(plr,"player:sid")) -- pobieramy tylko JEDEN rekord
        local name getPlayerName(plr):gsub("#%x%x%x%x%x%x","")
        if org and #org > 0 then
            setElementData(plr,"player:organization",org[1].code)
            outputChatBox("* Jeste? w organizacji, kt?ra nosi nazwe: "..org[1].code..""plr)
            exports['pystories-db']:dbSet("UPDATE ms_organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:sid"))
        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("pystories_users> Za?adowano statystyki gracza: "..getPlayerName(player))
end
end)
function savePlayerData(plr)
    local sid=getElementData(plr,"player:sid")
    if not sid 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 licensel=getElementData(plr,"player:license:pjL")
    local srp=getElementData(plr,"player:srp")
    local mech getElementData(plr,"license:mecha")
    local worker =getElementData(plr,"player:workinjob")
    local hourstonumber(getElementData(plr,"player:hours")) or 0
    local marihuana=getElementData(plr,"marihuana")
    local zarobek getElementData(plr,"szybko")
      
     
    local query=exports["pystories-db"]:dbSet("UPDATE pystories_users SET money=?, srp=?, zarobek=?  marihuana=?, mech=?, mandate=?, pjA=?, pjB=?, pjC=?, pjL=?, worker=?, hours=? WHERE id=?",
    moneysrpzarobekmarihuanamechmandatelicensealicenseblicenseclicenselworkerhourssid)
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("pystories_users> Zapisano statystyki gracza: "..getPlayerName(player))
end
end)
addEventHandler("onPlayerQuit"root, function() savePlayerData(sourceend)

Ustawienie eldaty:
setElementData(localPlayer"szybko".1)

Wygl?d tabeli w mysql:



Podpis
Elo benc
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-26, 09:12


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

ocal query=exports["pystories-db"]:dbSet("UPDATE pystories_users SET money=?, srp=?, zarobek=?,  marihuana=?, mech=?, mandate=?, pjA=?, pjB=?, pjC=?, pjL=?, worker=?, hours=? WHERE id=?",
    moneysrpzarobekmarihuanamechmandatelicensealicenseblicenseclicenselworkerhourssid)


przecinek zjad?e?:D

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Rumper
Tagi: zapis :: mysql
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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