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

Wysłany: 2017-04-04, 13:56


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

Witam posiadam skrypt od kolegi na premium. Ale graczy gdy wyjdzie z serwera i wejdzie nie ma tego premium kiedy da?em mu przed wyj?ciem.

function getPremiumDate(plr)
    local queryA=exports['ogrpg-db']:dbGet("SELECT * FROM ogrpg_users WHERE id=? AND premiumdate>NOW() LIMIT 1"getElementData(plr,"player:uid"))
    if (queryA and #queryA > 0) then
        return queryA[1].premiumdate
    end
    return false    
end

function setPremiumDay(plr,days)
    if getPremiumDate(plrthen
    local queryA=exports['ogrpg-db']:dbSet(string.format("UPDATE ogrpg_users SET premiumdate = DATE(premiumdate) + INTERVAL %d DAY WHERE id=%d",days,getElementData(plr,"player:uid")))
    return end
    local queryA=exports['ogrpg-db']:dbSet(string.format("UPDATE ogrpg_users SET premiumdate = DATE(curdate()) + INTERVAL %d DAY WHERE id=%d",days,getElementData(plr,"player:uid")))                          
end

addCommandHandler("daj.vip",function(plr,cmd,cel,dni) 
    if getAdmin(plr,3) or getElementData(plr,"player:uid") == 3 then 
    if not cel then outputChatBox(" /daj.vip [gracz] [dni]",plr) return end
    if not dni then outputChatBox(" /daj.vip [gracz] [dni]",plr) return end
    if not tonumber(dnithen outputChatBox(" /daj.vip [gracz] [dni]",plr) return end
        local target=exports["ogrpg-core"]:findPlayer(plr,cel)
        if not target then
            outputChatBox("* Nie znaleziono podanego gracza."plr25500)
            return
        end
        setPremiumDay(target,dni)
        outputChatBox("* Nadano konto premium na "..dni.." dni !"plr)
        outputChatBox("* Otrzyma?e?(a?) konto premium na "..dni.." dni !"target)
        triggerEvent("save:player",root,target)
        triggerEvent("load:player",root,target)
        setElementData(target,"player:premium",true)
    end
end)




Pomo?e kto??


Stosuj znaczniki lua/code //Emm

Ostatnio zmieniony przez Emm 2017-04-04, 18:44, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 14:36


Chrystek.

Programista LUA






Wiek: 26
Na forum: 3378 dni
Posty: 16
Nick w MP: Chrysto.

Piwa: 3

Respekt: 45,3

Ostrzeżeń: 100%
saveplayer ?le skonfigurowany

Podpis



Programista LUA





Postęp prac: 15%

Forum: http://b-w.ct8.pl
TeamSpeak: FR3.ts-3.cx:11740
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 15:49


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

"Chrystek." napisał/a:

saveplayer ?le skonfigurowany


Pom?g? by? ?

[ Dodano: 2017-04-04, 15:49 ]
"Chrystek." napisał/a:

saveplayer ?le skonfigurowany


Pom?g? by? ?

[ Dodano: 2017-04-04, 15:49 ]
"Chrystek." napisał/a:

saveplayer ?le skonfigurowany


Pom?g? by? ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 16:00


DylemaT929

Nikt






Wiek: 28
Na forum: 4041 dni
Posty: 333
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

Masz :>

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: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:reputation",v.reputation)
        setElementData(plr,"player:workinjob",v.worker)
        setElementData(plr,"player:registerdate",v.registered)
        setElementData(plr,"player:hours",v.hours)
        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"]:pobierzWyniki(queryA)
        if (resultAthen
            setElementData(plr,"player:premium",true)
            setElementData(plr,"player:premiumdate",v.premiumdate)
            setPlayerName(plr,"#FFBF00"..getPlayerName(plr))
        else
            setElementData(plr,"player:premium",false)
        end
        setElementData(plr,"player:skin",v.skin)
        end
        --organizacje
        local org=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE code=? AND uid=? LIMIT 1"getElementData(plr,"player:organization"), getElementData(plr,"player:uid")) -- 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(""..getPlayerName(source).." jeste? w organizacji - "..org[1].code..""plr)
            exports['ogrpg-db']:dbSet("UPDATE tl_organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:uid"))
        end
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("Zaladowano 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 licensel=getElementData(plr,"player:license:pjL")
    local reputation=getElementData(plr,"player:reputation")
    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=?, mandate=?, pjA=?, pjB=?, pjC=?, pjL=?, worker=?, hours=? WHERE id=?",
    moneyreputationmandatelicensealicenseblicenseclicensel,worker,hoursuid)
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(" Zapisano statystyki gracza :"..getPlayerName(player))
end
end)
addEventHandler("onPlayerQuit"root, function() savePlayerData(sourceend)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 17:49


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

"DylemaT929" napisał/a:

Masz :>

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: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:reputation",v.reputation)
        setElementData(plr,"player:workinjob",v.worker)
        setElementData(plr,"player:registerdate",v.registered)
        setElementData(plr,"player:hours",v.hours)
        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"]:pobierzWyniki(queryA)
        if (resultAthen
            setElementData(plr,"player:premium",true)
            setElementData(plr,"player:premiumdate",v.premiumdate)
            setPlayerName(plr,"#FFBF00"..getPlayerName(plr))
        else
            setElementData(plr,"player:premium",false)
        end
        setElementData(plr,"player:skin",v.skin)
        end
        --organizacje
        local org=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE code=? AND uid=? LIMIT 1"getElementData(plr,"player:organization"), getElementData(plr,"player:uid")) -- 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(""..getPlayerName(source).." jeste? w organizacji - "..org[1].code..""plr)
            exports['ogrpg-db']:dbSet("UPDATE tl_organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:uid"))
        end
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("Zaladowano 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 licensel=getElementData(plr,"player:license:pjL")
    local reputation=getElementData(plr,"player:reputation")
    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=?, mandate=?, pjA=?, pjB=?, pjC=?, pjL=?, worker=?, hours=? WHERE id=?",
    moneyreputationmandatelicensealicenseblicenseclicensel,worker,hoursuid)
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(" Zapisano statystyki gracza :"..getPlayerName(player))
end
end)
addEventHandler("onPlayerQuit"root, function() savePlayerData(sourceend)



Zostawi? to co mia?em i doklei? twoje ?

[ Dodano: 2017-04-04, 17:49 ]
"DylemaT929" napisał/a:

Masz :>

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: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:reputation",v.reputation)
        setElementData(plr,"player:workinjob",v.worker)
        setElementData(plr,"player:registerdate",v.registered)
        setElementData(plr,"player:hours",v.hours)
        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"]:pobierzWyniki(queryA)
        if (resultAthen
            setElementData(plr,"player:premium",true)
            setElementData(plr,"player:premiumdate",v.premiumdate)
            setPlayerName(plr,"#FFBF00"..getPlayerName(plr))
        else
            setElementData(plr,"player:premium",false)
        end
        setElementData(plr,"player:skin",v.skin)
        end
        --organizacje
        local org=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE code=? AND uid=? LIMIT 1"getElementData(plr,"player:organization"), getElementData(plr,"player:uid")) -- 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(""..getPlayerName(source).." jeste? w organizacji - "..org[1].code..""plr)
            exports['ogrpg-db']:dbSet("UPDATE tl_organizacje SET actived=curdate() WHERE uid=?"getElementData(plr,"player:uid"))
        end
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("Zaladowano 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 licensel=getElementData(plr,"player:license:pjL")
    local reputation=getElementData(plr,"player:reputation")
    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=?, mandate=?, pjA=?, pjB=?, pjC=?, pjL=?, worker=?, hours=? WHERE id=?",
    moneyreputationmandatelicensealicenseblicenseclicensel,worker,hoursuid)
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(" Zapisano statystyki gracza :"..getPlayerName(player))
end
end)
addEventHandler("onPlayerQuit"root, function() savePlayerData(sourceend)



Zostawi? to co mia?em i doklei? twoje ?

[ Dodano: 2017-04-04, 17:51 ]
Dalej nie dzia?a

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 18:16


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

Chrystek., DylemaT929, Co wy kminicie?
pawelz, Da?e? kod na danie vipa a nie na wczytywanie gracza. Sprawd? tak: Daj komu? kto nie mia? vipa i w mysql sprawdz czy si? zapisa? kod. Je?eli nie podaj event 'save:player', je?eli si? zapisa? ale gdy gracz wchodzi na server i nie dostaje premium to podaj event 'loadplayer'

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 18:31


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

Niby co si? tworzy w mysql ? cut - pomagamy tylko na forum....//Emm

Ostatnio zmieniony przez Emm 2017-04-04, 18:43, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 18:35


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

pawelz, pomagamy tylko na forum. Nie wiesz co ma si? tworzy? w mysql? No chyba info ?e gracz ma premium? tabelta 'ogrpg_users' kolumna 'premiumdate'

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 18:55


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

no tak tworzy si? ale co mam zrobi? ?eby to dzia?a?o ? helpniesz

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 18:59


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

Przeczyta?e? m?j post wy?ej? podaj mi event 'load:player'...

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 19:01


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

Kod:

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("Zaladowano statystyki gracza :"..getPlayerName(player))
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 19:02


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

oraz loadPlayerData

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 19:03


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

Kod:

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: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:reputation",v.reputation)
setElementData(plr,"player:workinjob",v.worker)
setElementData(plr,"player:registerdate",v.registered)
setElementData(plr,"player:hours",v.hours)
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"]:pobierzWyniki(queryA)
if (resultA) then
setElementData(plr,"player:premium",true)
setElementData(plr,"player:premiumdate",v.premiumdate)
setPlayerName(plr,"#FFBF00"..getPlayerName(plr))
else
setElementData(plr,"player:premium",false)
end
setElementData(plr,"player:skin",v.skin)
end
--organizacje
local org=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE code=? AND uid=? LIMIT 1", getElementData(plr,"player:organization"), getElementData(plr,"player:uid")) -- 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(""..getPlayerName(source).." jeste? w organizacji - "..org[1].code.."", plr)
exports['ogrpg-db']:dbSet("UPDATE tl_organizacje SET actived=curdate() WHERE uid=?", getElementData(plr,"player:uid"))
end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 19:10


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

Dobra a gdy dasz komu? premke kiedy jej nie mia? to od razu masz go np. w tabli TAB w grze jako premium? albo zmieni? mu si? kolor na jaki? inny? Je?eli tak to przy nak?adaniu vipa oraz gdy kto? ma vipa w wchodzi do gdy podaj db3 bo w kodzie nic nie widz? z?ego oraz daj screena mysql kolumny premium

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-04-04, 19:11


pawelz

CJ






Wiek: 43
Na forum: 3364 dni
Posty: 27
Nick w MP: pawelz

Piwa: 1

Respekt: 45,3

Daje graczowi premium na TABli?cie nie ma z?otego nicku ale ma normalnie permisje premiummo?e pisaogloszenia i na chacie /(czat premium)


Ostatnio zmieniony przez pawelz 2017-04-04, 19:16, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: działa :: premium
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » nie działa premium 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