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

Wysłany: 2018-07-03, 22:30


HeviK*







Wiek: 29
Na forum: 3156 dni
Posty: 34

Piwa: 2

Respekt: 40,5

Witam, zn?w przychodz? z pytaniem czemu nie dzia?a mi totalkills ?
Mam w skrypcie zrobione zab?jstwo jak np. na jednym ?yciu zabije osobe to wyswietla mi sie to ale niestety nie dziala mi to, ?e zapisuje do totalkills mi tego ;/

 getElementData ( element, "murders" ) 
- to funkcja od killi na jednym ?yciu

 peds = getElementsByType("ped") 
players = getElementsByType("player") 
addEventHandler ( "onPlayerWasted", root, 
    function( totalAmmo, killer, killerWeapon, bodypart, stealth ) 
        if killer == players and killer ~= peds and source == players and source ~= peds then 
            local account = getPlayerAccount ( killer ) 
            if killer ~= source then 
                setAccountData( account,"totalkillsdeaths.Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) +1 ) 
                setElementData( killer, "Kills", tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) ) ) 
                setElementData( killer, "Ratio", tonumber(getElementData( killer, "Kills" )/getElementData( source, "Deaths") ) ) 
            end  
        else 
            local accountSource = getPlayerAccount ( source ) 
            setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) 
            setElementData( source, "Deaths", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) ) ) 
            setElementData( source, "Ratio", tonumber(getElementData( killer, "Kills" )/getElementData( source, "Deaths") ) ) 
        end 
    end 
)       
  
addEventHandler( "onPlayerLogin",root, 
    function( thePreviousAccount, theCurrentAccount, autoLogin ) 
        local account = getPlayerAccount ( source ) 
        if not getAccountData( account,"totalkillsdeaths.Kills" ) and not getAccountData( account,"totalkillsdeaths.Deaths" ) then 
            setAccountData( account,"totalkillsdeaths.Kills",0 ) 
            setAccountData( account,"totalkillsdeaths.Deaths",0 ) 
        end 
        setElementData( source,"Deaths",tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) 
        setElementData( source,"Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) ) 
        setElementData( source, "Ratio", getElementData( source, "Kills" )/getElementData( source, "Deaths") ) 
    end 
 )


Ca?a funkcja od Killi, ded?w i ratio
daje zimne PIWKO i reputacje za pomoc ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-03, 22:51


amited







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

Piwa: 512

Respekt: 466
Respekt: 466

nwm ale przyda?oby si? DB3 i konkretna linijka od tego :)

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

 
Wysłany: 2018-07-03, 23:30


HeviK*







Wiek: 29
Na forum: 3156 dni
Posty: 34

Piwa: 2

Respekt: 40,5

Nie wywala bledow w debugscripcie o dziwo. A wiec wytlumacze ci o co chodzi:
Mam scoreboard i dodaje do niego tabele z totalkills, totaldead i Kill and dead ratio
scoreboardColumns = {
    { name = "Gracze", width = 200, data = function (element) return getPlayerName ( element ) end },
    { name = "Zab?jstwa", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },
    { name = "Wszystkie zab?jstwa", width = 100, data = function (element) return ( getElementData ( element, "totalkillsdeaths.Kills" ) or 0 ) end },
    { name = "Zgony", width = 80, data = function (element) return getElementData ( element, "Deaths" ) or 0 end },
    { name = "Zabite Zombie", width = 80, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },
    { name = "Czas ?ycia", width = 80, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },
    { name = "Grupa", width = 150, data = function (element) return ( getElementData ( element, "gang" ) or "Brak" ) end },
    --{ name = "KDr", width = 80, data = function (element) return getElementData ( element, "Ratio" ) or 0 end },

}


murders
odpowiada za kille przy jednym ?yciu (chodzi o to, ?e je?li zabijesz 4 osoby to masz tutaj liczbe 4, ale je?li zginiesz to resetuje sie) a mi chodzi o total kills wi?c nie chce zeby sie resetowa?o i chce zeby sie to zapisywalo.

A linijki konkretnej nie wska?e ci, bo ja pisz?c skrypt niestety ?le jak?? z danych wpisalem i co? nie dzia?a mi. Ale g??wnie jest to:
 setAccountData( account,"totalkillsdeaths.Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) +1 ) 
                setElementData( killer, "Kills", tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) ) ) 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 01:28


nanKy







Wiek: 23
Na forum: 4007 dni
Posty: 498
Nick w MP: nanky

Piwa: 1775

Respekt: 239
Respekt: 239Respekt: 239

    
{ name = "Wszystkie zab?jstwa", width = 100, data = function (element) return ( getElementData ( element, "Kills" ) or 0 ) end },

sprawd? to.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 08:53


HeviK*







Wiek: 29
Na forum: 3156 dni
Posty: 34

Piwa: 2

Respekt: 40,5

Nie dzia?a, zabojstwa zalicza ale wszystkich zabojst juz nie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 13:14


_jvneczek







Wiek: 22
Na forum: 4467 dni
Posty: 1509
Nick w MP: _jvneczek

Piwa: 3960

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

HeviK*, zr?b to na podstawie bazy danych, zr?b ?e b?dzie ci to zapisywa? w bazie danych, i z bazy danych b?dzie ci wyczytywa? kille.

Podpis

Support Team: 04.10.2020 - 01.09.2020
Test Moderator: 03.05.2021 - 01.09.2021
Moderator: 01.09.2021 - 23.10.2021

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-04, 13:22


HeviK*







Wiek: 29
Na forum: 3156 dni
Posty: 34

Piwa: 2

Respekt: 40,5

My?la?em nad tym, tylko chc? jeszcze popr?bowa? tym sobosobem. Je?li kto? ma jeszcze jaki? pomys? prosze pom??cie ;(

Postaw piwo autorowi tego posta
 

 
Tagi: totalkills :: nie :: działa
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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