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

Wysłany: 2019-09-13, 16:43


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

Hejo, mam skrypt taki tam o taki o, ale chc?, aby robil on cos takiego: Po zrespieniu sie gracza sprawdza ile wynosi jego data "Level", jesli ma tyle i tyle to daje mu t? i tak? bro?, a wiadomosc z pogratulowaniem za dany prog (1000) itp. ma sie pokazywac tylko raz, wtedy, kiedy gracz przekroczy ten prog, lub jego data bedzie wynosila tyle co sam prog. Kod:

addEventHandler("onPlayerLogin", getRootElement(),
function(_, konto_obecne)
    setTimer(przydzielanielvla, 60*50*20, 0, konto_obecne, source)
    setTimer(przydzielanielvlaH, 60*50*20, 0, konto_obecne, source)
    local aktualny_lvl = (getAccountData(konto_obecne, "Level") or 0)
    setElementData(source, "Level", aktualny_lvl)
    if (aktualny_lvl >= 500000) then
        giveWeapon(source, 37, 550)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
        return
    end
    if (aktualny_lvl >= 100000) then
        giveWeapon(source, 16, 5)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
        return
    end
    if (aktualny_lvl >= 60000) then
        giveWeapon(source, 28, 150)
        giveWeapon(source, 24, 77)
        giveWeapon(source, 46)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
        return
    end
    if (aktualny_lvl >= 40000) then
        giveWeapon(source, 5)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
        return
    end
    if (aktualny_lvl >= 10000) then
        giveWeapon(source, 34, 200)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
        return
    end
    if (aktualny_lvl >= 4000) then
        giveWeapon(source, 26, 60)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
        return
    end
    if (aktualny_lvl >= 1000) then
        giveWeapon(source, 25, 100)
        setElementData(source, "Level", aktualny_lvl + 300)
        outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
return        
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-09-13, 22:22


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3951 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2322

Respekt: 240
Respekt: 240Respekt: 240

addEventHandler("onPlayerLogin", getRootElement(),
function(_, konto_obecne)
    setTimer(przydzielanielvla, 60*50*20, 0, konto_obecne, source)
    setTimer(przydzielanielvlaH, 60*50*20, 0, konto_obecne, source)
    local aktualny_lvl = (getAccountData(konto_obecne, "Level") or 0)
    setElementData(source, "Level", aktualny_lvl)
end)
addEventHandler("onPlayerSpawn", root, function()

local aktualny_lvl=getElementData(source, "Level")
if (aktualny_lvl >= 500000) then
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
giveWeapon(source, 37, 550)
end
if (aktualny_lvl >= 100000) then
giveWeapon(source, 16, 5)
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
end
if (aktualny_lvl >= 60000) then
giveWeapon(source, 28, 150)
giveWeapon(source, 24, 77)
giveWeapon(source, 46)
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
end
if (aktualny_lvl >= 40000) then
giveWeapon(source, 5)
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
end
if (aktualny_lvl >= 10000) then
giveWeapon(source, 34, 200)
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
end
if (aktualny_lvl >= 4000) then
giveWeapon(source, 26, 60)
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
end
if (aktualny_lvl >= 1000) then
giveWeapon(source, 25, 100)
setElementData(source, "Level", aktualny_lvl + 300)
outputChatBox("#00FF00[#00FFFFRESPEKT#00FF00]#FFD700GRATULACJE, #FFA500za aktywne granie otrzyma?e? now? #FFD700BRO? #FFA500oraz #FFD700300 RESPEKTU!", source, 255, 255, 255, true)
end
end)
function outputChange(theKey, oldValue, newValue)
    if (theKey=="Level") then
if(oldValue<=przekroczonyprog and przekroczonyprog<newValue and newValue<nastepnyprog)
outputChatBox("przekroczyles prog",source)
end
    end
end
addEventHandler("onElementDataChange", root, outputChange)


nietestowane, musisz podstawic wartosci w ostatniej funkcji

Ostatnio zmieniony przez Pawel5321 2019-09-14, 12:45, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-09-14, 10:24


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

Nie dziala to jeszcze jak chcialem, troche przerobilem, ale nadal nie potrafie sprawic, aby wiadomosc naa czacie pookazywala si? tylko raz, podczas przekroczenia progu, nie zawsze po zalogowaniu/spawnie! Tak samo z tym +300 respektu. A i ten, jakie wartosci mam dopisac? Nie kumam tej ostatniej funkcji ;v Obecny kod wyglada u mnie tak:
addEventHandler("onPlayerLogin", getRootElement(),
function(_, konto_obecne)
    setTimer(przydzielanielvla, 60*50*20, 0, konto_obecne, source)
    setTimer(przydzielanielvlaH, 60*50*20, 0, konto_obecne, source)
    local aktualny_lvl = (getAccountData(konto_obecne, "Level") or 0)
    setElementData(source, "Level", aktualny_lvl)
end)
addEventHandler("onPlayerSpawn", root, function()

local aktualny_lvl=getElementData(source, "Level")
if (aktualny_lvl >= 500000) then
giveWeapon(source, 37, 550)
end
if (aktualny_lvl >= 100000) then
giveWeapon(source, 16, 5)
end
if (aktualny_lvl >= 60000) then
giveWeapon(source, 28, 150)
giveWeapon(source, 24, 77)
giveWeapon(source, 46)
end
if (aktualny_lvl >= 40000) then
giveWeapon(source, 5)
end
if (aktualny_lvl >= 10000) then
giveWeapon(source, 34, 200)
end
if (aktualny_lvl >= 4000) then
giveWeapon(source, 26, 60)
end
if (aktualny_lvl >= 1000) then
giveWeapon(source, 25, 100)
end
end)
function outputChange(theKey, oldValue, newValue)
    if (theKey=="Level") then
if(oldValue<=przekroczonyprog and przekroczonyprog<newValue and newValue<nastepnyprog) then
end
    end
end
addEventHandler("onElementDataChange", root, outputChange)

addEventHandler("onPlayerLogin", root, function()

local aktualny_lvl=getElementData(source, "Level")
if (aktualny_lvl >= 500000) then
giveWeapon(source, 37, 550)
end
if (aktualny_lvl >= 100000) then
giveWeapon(source, 16, 5)
end
if (aktualny_lvl >= 60000) then
giveWeapon(source, 28, 150)
giveWeapon(source, 24, 77)
giveWeapon(source, 46)
end
if (aktualny_lvl >= 40000) then
giveWeapon(source, 5)
end
if (aktualny_lvl >= 10000) then
giveWeapon(source, 34, 200)
end
if (aktualny_lvl >= 4000) then
giveWeapon(source, 26, 60)
end
if (aktualny_lvl >= 1000) then
giveWeapon(source, 25, 100)
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-09-14, 10:38


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Bro? nadawaj dopiero przy onPlayerSpawn, przecie? to ju? masz zrobione. Usu? ten ostatni event.
?eby wiadomo?? pokaza?a si? tylko raz musisz w accountDacie zapisa? jak?? warto?? na true i sprawdzasz po przekroczeniu progu czy gracz ma tak? accountDat?.


addEventHandler("onElementDataChange", getRootElement(), function outputChange(theKey, oldValue, newValue)
    if (theKey=="Level") then
        if (oldValue<=przekroczonyprog and przekroczonyprog<newValue and newValue<nastepnyprog and (not getAccountData(source, "zdobyto:prog"))
            outputChatBox("przekroczyles prog",source)
            setAccountData(source, "zdobyto:prog", true)
        end
    end
end)


przekroczonyprog zamieniasz na odpowiedni? liczb?

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Szyszka947
Wysłany: 2019-09-14, 11:13


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3951 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2322

Respekt: 240
Respekt: 240Respekt: 240


local progi={1000,4000,10000,40000,60000,100000,500000}
function outputChange(theKey, oldValue, newValue)
    if (theKey=="Level") then
    for k,v in ipairs(progi) do
if(oldValue<v and v<=newValue) then

outputChatBox("Przekroczyles prog - "..v)
end
    end
end
end
addEventHandler("onElementDataChange", root, outputChange)

kod na wy?wietlanie wiadomo?ci o przekroczeniu progu

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-09-14, 12:05


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

Okej, dzia?a pi?knie po ma?ej przer?bce, tylko mam jedno pytanie. Dlaczego po przekroczeniu progu 4000 respa, skrypt dodaje ammo do shotgana za 1k respa, zamiast po prostu zamienic go z obrzynem? Jakas rada?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-09-14, 12:37


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3951 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2322

Respekt: 240
Respekt: 240Respekt: 240

Skrypt jest czytany od g?ry do do?u, zamie? miejscami to

if (aktualny_lvl >= 4000) then
giveWeapon(source, 26, 60)
end

i to

if (aktualny_lvl >= 1000) then
giveWeapon(source, 25, 100)
end


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Szyszka947
Wysłany: 2019-09-14, 13:34


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

dzieki, jzu daje respekt i piwko

Postaw piwo autorowi tego posta
 

 
Tagi: bronie :: wartosci
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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