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

Wysłany: 2015-07-19, 16:43


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
Witam. Znowu mam problem z respektem. A minowicie chcia?em, aby dawa?o 1 respektu co minut?, ale nie daje a w db3 jest taki b??d:

:4: Attempt to arithmetic on local 'data' (a boolean value)


Tutaj kod:

local player = getLocalPlayer ()
function resp_minuta ()
     local data = getElementData(player, "Respekt")
         setElementData (player, "Respekt", data + 1)
end
setTimer (resp_minuta, 60*1000, 0)


Je?li kto? mi to zrobi to dam :arrow: :piwo: i R*

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:08


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Sprobuj

 local data = getElementData(player, "Respekt") or 0


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:22


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
"DestroY" napisał/a:

Sprobuj

 local data = getElementData(player, "Respekt") or 0


Dzi?ki, dzia?a :P . Do zamkni?cia. Tak jak m?wi?em, :piwo: i R*

[ Dodano: 2015-07-19, 17:28 ]
Albo nie, nie zamykajcie. Nie b?d? z forum ?mietnika robi?. Zrobi mi kto? skrypt, ?eby ten respekt si? zapisywa?? Za to te? dam :piwo: i R* :->

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:35


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
To juz sam sobie machnij ;P

Eventy; onPlayerLogin, onPlayerQuit

Przy wyjsciu pobierasz element date i zapisujesz do konta
(SetAccountData)


Przy logowaniu sprawdzasz cxy konto ma zapisany respert (getAccountData), jezeli ma ustawiasz w elementdate wlasnia ta wartosc, jezeli nie ustawiasz 0.

Pisz sam, w razie czego pomozemy ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:36


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
Dobra, zaraz co? sklec? :D

[ Dodano: 2015-07-19, 17:40 ]
function odczyt ()
local konto = getAccountName(getPlayerAccount(source))
local data = getAccountData(konto, "Respekt")
    if data then
    setElementData(source, "Respekt", data)
    else
    setAccountData(konto, "Respekt", 0)
    setElementData(source, "Respekt", 0)
    end
end
addEventHandler ( 'onPlayerLogin', getRootElement (), odczyt)

function zapis ()
local konto1 = getAccountName(getPlayerAccount(source))
    local data1 = getElementData(source, "Respekt")
    if data1 then
    setAccountData(konto1, "Respekt", data1)
    end
end
addEventHandler("onPlayerLogout",getRootElement(),zapis)
addEventHandler( "onPlayerQuit", getRootElement(), zapis)


Dobra, zrobi?em co? takiego, ale nie dzia?a ;(


Nawet nie wiem czy dobrze, bo to tak na szybko :D

[ Dodano: 2015-07-19, 17:41 ]
Odpisz? w razie czego za 1h ;)

[ Dodano: 2015-07-19, 17:43 ]
doda?em te? onPlayerLogout, jakby kto? u?y? /logout :D

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:47


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
W logowaniu zgubiles jeszcze 1 setElementDate

No i sam event OnPlayerLogin zwraca Ci argument konta

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:47


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
A mo?esz mi to poprawi?? :mrgreen:

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 17:52


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%

function odczyt (prev,cur)
local data = getAccountData(cur, "Respekt")
    if data then
    setElementData(source, "Respekt", data)
    else
    setElementData(source, "Respekt", 0)
    end
end
addEventHandler ( 'onPlayerLogin', getRootElement (), odczyt)

function zapis ()
local konto1 = getAccountName(getPlayerAccount(source))
    local data1 = getElementData(source, "Respekt")
    if data1 then
    setAccountData(konto1, "Respekt", data1)
    end
end
addEventHandler("onPlayerLogout",getRootElement(),zapis)
addEventHandler( "onPlayerQuit", getRootElement(), zapis)


Mi tez sie ciutke popitolilo w poscie wyzej, powinno juz byc

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 18:59


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
"DestroY" napisał/a:


function odczyt (prev,cur)
local data = getAccountData(cur, "Respekt")
    if data then
    setElementData(source, "Respekt", data)
    else
    setElementData(source, "Respekt", 0)
    end
end
addEventHandler ( 'onPlayerLogin', getRootElement (), odczyt)

function zapis ()
local konto1 = getAccountName(getPlayerAccount(source))
    local data1 = getElementData(source, "Respekt")
    if data1 then
    setAccountData(konto1, "Respekt", data1)
    end
end
addEventHandler("onPlayerLogout",getRootElement(),zapis)
addEventHandler( "onPlayerQuit", getRootElement(), zapis)


Mi tez sie ciutke popitolilo w poscie wyzej, powinno juz byc



Dalej nie dzia?a ;(

[ Dodano: 2015-07-19, 19:01 ]
W??czy?em sobie db3 i wpisa?em logout i b??d jest taki:

zapis.lua:15: Bad argument @ 'setAccountData' [Expected account at argument 1, got string 'guest']

Nie wiem czy to co? wam da, ale zawsze co? ;)

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 19:05


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Wywal cale getAccountName, zostaw samo getPlayerAccount...

To tez moje niedopatrzenie xD

A logout wywal, najlepiej sobie to (komende) zablokuj* xD
Ew jezeli chcesz koniecznie ten logout to prosze bardzo


function zapis2 (konto)
    local data1 = getElementData(konto, "Respekt")
    if data1 then
    setAccountData(konto, "Respekt", data1)
    end
end
addEventHandler("onPlayerLogout",getRootElement(),zapis2)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 19:35


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
"DestroY" napisał/a:

Wywal cale getAccountName, zostaw samo getPlayerAccount...

To tez moje niedopatrzenie xD

A logout wywal, najlepiej sobie to (komende) zablokuj* xD
Ew jezeli chcesz koniecznie ten logout to prosze bardzo


function zapis2 (konto)
    local data1 = getElementData(konto, "Respekt")
    if data1 then
    setAccountData(konto, "Respekt", data1)
    end
end
addEventHandler("onPlayerLogout",getRootElement(),zapis2)


A mo?esz mi to przerobi?? :D . A poza tym t? komend? chc? zablokowa?, po prostu akurat my?la?em, ?e si? przyda ;)

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 19:48


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Pa prostu usun z poprzedniego event na logout'a
A co do blokady logout'a to

Więcej informacji znajdziesz w Wikipedii MTA:

onPlayerCommand

I jezeli komenda to logout to anulujesz zdarzenie (cancelEvent())

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 19:57


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
"DestroY" napisał/a:

Pa prostu usun z poprzedniego event na logout'a
A co do blokady logout'a to

Więcej informacji znajdziesz w Wikipedii MTA:

onPlayerCommand

I jezeli komenda to logout to anulujesz zdarzenie (cancelEvent())


Czyli wystarczy 1 eveent usun???! LOL

A propo blokady to ju? tak? mam :D

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 20:02


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Po prostu w kwesti wychodzenia pozostaw to:


function zapis ()
local konto1 = getPlayerAccount(source)
    local data1 = getElementData(source, "Respekt")
    if data1 then
    setAccountData(konto1, "Respekt", data1)
    end
end
addEventHandler( "onPlayerQuit", getRootElement(), zapis)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-19, 20:19


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
"DestroY" napisał/a:

Po prostu w kwesti wychodzenia pozostaw to:


function zapis ()
local konto1 = getPlayerAccount(source)
    local data1 = getElementData(source, "Respekt")
    if data1 then
    setAccountData(konto1, "Respekt", data1)
    end
end
addEventHandler( "onPlayerQuit", getRootElement(), zapis)


OK, dzia?a, THX ziom :mrgreen:

[ Dodano: 2015-07-19, 20:20 ]
Sorka, respa ci nie dam, bo nie mo?na 2 razy :D

[ Dodano: 2015-07-19, 21:21 ]
A jeszcze kolejny problem ;( . chcia?em, aby dawa?o respa co godzine i $ i nie dzia?a :(

local player = getLocalPlayer ()
function resp_godzina ()
      local data = getElementData (player, "Respekt") or 0
         setElementData (player, "Respekt", data + 200)
         givePlayerMoney (player, 20000)
         outputChatBox ("*[INFO] Otrzymujesz premi? za godzin? gry!", player, 0, 255, 255)
         outputChatBox ("*200 Respektu oraz 20000$ na w?asne wydatki!", player, 0, 255, 255)
end
setTimer (resp_minuta, 30*1000, 0)


Dam tak?e :piwo: i R* :mrgreen: .

[ Dodano: 2015-07-19, 21:22 ]
da?em na 30 sekundy ?eby sprawdzi? czy dzia?a ;)

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Tagi: respekt :: minutę
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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