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

Wysłany: 2018-07-25, 22:08


Ognisty_12877







Wiek: 24
Na forum: 3034 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

Witam to znowu ja z problemem zapisywania killi. Prosze o pomoc


To jest Funkcja na wyswietlenie killi, lecz gdy dam getAccountData( account, "allKills") nie dzia?a

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


A to Funkcja na sprawdzanie killi i zapisywanie niby konta mamy na serial funkcja ktora robi konta jest nizej

addEventHandler ( "onPlayerWasted", root,
    function( totalAmmo, killer, killerWeapon, bodypart, stealth )
        if killer then
            local account = getPlayerSerial ( killer )
            if killer ~= source then
                setAccountData( account,"allKills",tonumber( getAccountData( account,"allKills" ) or 0 ) +1 )
                setElementData( killer, "KDr", tonumber(getElementData( killer, "T/K" )/getElementData( source, "T/D") ) )
            end 
        else
            local accountSource = getPlayerSerial ( source )
            setAccountData( accountSource,"Deaths",tonumber( getAccountData(accountSource,"Deaths") or 0 ) +1 )
            setElementData( source, "KDr", getElementData( killer, "T/K" )/getElementData( source, "T/D") )
        end
    end
)      
 
addEventHandler( "onPlayerLogin",root,
    function( thePreviousAccount, theCurrentAccount, autoLogin )
        local account = getPlayerSerial ( source )
        if not getAccountData( account,"allKills" ) and not getAccountData( account,"Deaths" ) then
            setAccountData( account,"allKills",0 )
            setAccountData( account,"Deaths",0 )
        end
        setElementData( source, "KDr", getElementData( source, "T/K" )/getElementData( source, "T/D") )
    end
)


function Sprawdzenie(plr,cmd)
    local account = getPlayerSerial(plr)
    local data = getAccountData(account, "allKills") or "a jednak nie ma..."
    for i, v in ipairs(getElementsByType("player")) do
        outputChatBox(data,v)
    end    
end
addCommandHandler("sprawdzenie",Sprawdzenie)



Funkcja na tworzenia konta na serial

function enterPlayer()
    local username = tostring (getPlayerSerial (source))
    local account = getAccount (username)
    if (account == false) then
        account = addAccount (username, "o43'6Ap4=H")
        logIn (source, account, "o43'6Ap4=H")
        triggerClientEvent ( source, "hideLoginWindow", getRootElement())
        triggerEvent("onPlayerDayZRegister", getRootElement(),username,"o43'6Ap4=H",source)
        return
    end
    if not logIn (source, account, "o43'6Ap4=H") then
        setAccountPassword (account, "o43'6Ap4=H")
        logIn (source, account, "o43'6Ap4=H")
    end
    triggerClientEvent ( source, "hideLoginWindow", getRootElement())
    triggerEvent("onPlayerDayZLogin", getRootElement(),username,"o43'6Ap4=H",source)
end
addEvent("onRequestEnter",true)
addEventHandler("onRequestEnter",getRootElement(),enterPlayer)



PLS HELP. Daje zmro?one piwko i respekcik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-25, 22:18


nanKy







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

Piwa: 1775

Respekt: 239
Respekt: 239Respekt: 239

addEventHandler ( "onPlayerWasted", root,
    function( totalAmmo, killer, killerWeapon, bodypart, stealth )
        if killer then
            local account = getPlayerAccount(killer)
            if killer ~= source then
                setAccountData( account,"allKills",tonumber( getAccountData( account,"allKills" ) or 0 ) +1 )
                setElementData( killer, "KDr", tonumber(getElementData( killer, "T/K" )/getElementData( source, "T/D") ) )
            end 
        else
            local accountSource = getPlayerAccount(source)
            setAccountData( accountSource,"Deaths",tonumber( getAccountData(accountSource,"Deaths") or 0 ) +1 )
            setElementData( source, "KDr", getElementData( killer, "T/K" )/getElementData( source, "T/D") )
        end
    end
)      
 
addEventHandler( "onPlayerLogin",root,
    function( thePreviousAccount, theCurrentAccount, autoLogin )
        local account = getPlayerAccount(source)
        if not getAccountData( account,"allKills" ) and not getAccountData( account,"Deaths" ) then
            setAccountData( account,"allKills",0 )
            setAccountData( account,"Deaths",0 )
        end
        setElementData( source, "KDr", getElementData( source, "T/K" )/getElementData( source, "T/D") )
    end
)


function Sprawdzenie(plr,cmd)
    local account = getPlayerAccount(plr)
    local data = getAccountData(account, "allKills") or "a jednak nie ma..."
    for i, v in ipairs(getElementsByType("player")) do
        outputChatBox(data,v)
    end    
end
addCommandHandler("sprawdzenie",Sprawdzenie)

i...
function enterPlayer()
    local username = tostring (getPlayerSerial (source))
    local account = getAccount (username)
    if (account == false) then
        account = addAccount (username, "o43'6Ap4=H")
        logIn (source, account, "o43'6Ap4=H")
        setElementData(source,'allKills',(getAccountData(account,'allKills') or 0))
        triggerClientEvent ( source, "hideLoginWindow", getRootElement())
        triggerEvent("onPlayerDayZRegister", getRootElement(),username,"o43'6Ap4=H",source)
        return
    end
    if not logIn (source, account, "o43'6Ap4=H") then
        setAccountPassword (account, "o43'6Ap4=H")
        logIn (source, account, "o43'6Ap4=H")
    end
    triggerClientEvent ( source, "hideLoginWindow", getRootElement())
    triggerEvent("onPlayerDayZLogin", getRootElement(),username,"o43'6Ap4=H",source)
end
addEvent("onRequestEnter",true)
addEventHandler("onRequestEnter",getRootElement(),enterPlayer)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-25, 22:46


Ognisty_12877







Wiek: 24
Na forum: 3034 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

Gdy Zresetowalem oba skrypty po zreconnectowaniu po zabiciu gracza i sprawdzenie komend? wyskakuje ?e a jednak nie ma... tak jak jest w tej funkij

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-25, 22:55


nanKy







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

Piwa: 1775

Respekt: 239
Respekt: 239Respekt: 239

sprawd? to...


addEventHandler ( "onPlayerWasted", root,
    function( totalAmmo, killer, killerWeapon, bodypart, stealth )
        if killer then
            if killer ~= source then
            local account = getPlayerAccount(killer)
                setAccountData( account,"allKills",tonumber( getAccountData( account,"allKills" ) or 0 ) +1 )
                setElementData( killer, "KDr", tonumber(getElementData( killer, "T/K" )/getElementData( source, "T/D") ) )
            end 
        else
            local accountSource = getPlayerAccount(source)
            setAccountData( accountSource,"Deaths",tonumber( getAccountData(accountSource,"Deaths") or 0 ) +1 )
            setElementData( source, "KDr", getElementData( killer, "T/K" )/getElementData( source, "T/D") )
        end
    end
)      
 
addEventHandler( "onPlayerLogin",root,
    function( thePreviousAccount, theCurrentAccount, autoLogin )
        local account = getPlayerAccount(source)
        if not getAccountData( account,"allKills" ) and not getAccountData( account,"Deaths" ) then
            setAccountData( account,"allKills",0 )
            setAccountData( account,"Deaths",0 )
        end
        setElementData( source, "KDr", getElementData( source, "T/K" )/getElementData( source, "T/D") )
    end
)


function Sprawdzenie(plr,cmd)
    local account = getPlayerAccount(plr)
    local data = getAccountData(account, "allKills") or "a jednak nie ma..."
    for i, v in ipairs(getElementsByType("player")) do
        outputChatBox(data,v)
    end    
end
addCommandHandler("sprawdzenie",Sprawdzenie)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Ognisty_12877
Wysłany: 2018-07-25, 22:58


Ognisty_12877







Wiek: 24
Na forum: 3034 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

Dalej wyskakuje to samo co wczesniej jakby nie bylo takiej Daty da sie jakos zeby do txt zapisywa?o sie

[ Dodano: 2018-07-26, 10:56 ]
Dobra za pomoc w tym dostajesz respekcik i piwero , lecz niestety dalej to niedzia?a zrobi?em to pro?ciej
nw co jest nie tak, a gdy sprawdzam komed? sprawdzenie po resecie pisze "a jednak nie ma..." a jak zreconnectuje pisze ze 0 czyli jak tu jest
        if not getAccountData( account,"zabicia" ) then
            setAccountData( account,"zabicia",0 )
a po zabicu gracza i tak sie nie zapisuje:

addEventHandler ( "onPlayerWasted", root,
    function( totalAmmo, killer, killerWeapon, bodypart, stealth )
        if killer then
            if killer ~= source then
            local account = getPlayerAccount(killer)
                setAccountData( account,"zabicia",tonumber( getAccountData( account,"zabicia" ) or 0 ) +1 )
            end 
        end
    end
)      
 
addEventHandler( "onPlayerLogin",root,
    function( thePreviousAccount, theCurrentAccount, autoLogin )
        local account = getPlayerAccount(source)
        if not getAccountData( account,"zabicia" ) then
            setAccountData( account,"zabicia",0 )
        end
    end
)


function Sprawdzenie(plr,cmd)
    local account = getPlayerAccount(plr)
    local data = getAccountData(account, "zabicia") or "a jednak nie ma..."
    for i, v in ipairs(getElementsByType("player")) do
        outputChatBox(data,v)
    end    
end
addCommandHandler("sprawdzenie",Sprawdzenie)





login

function enterPlayer()
    local username = tostring (getPlayerSerial (source))
    local account = getAccount (username)
    if (account == false) then
        account = addAccount (username, "o43'6Ap4=H")
        logIn (source, account, "o43'6Ap4=H")
        setElementData(source,'zabicia',(getAccountData(account,'zabicia') or 0))
        triggerClientEvent ( source, "hideLoginWindow", getRootElement())
        triggerEvent("onPlayerDayZRegister", getRootElement(),username,"o43'6Ap4=H",source)
        return
    end
    if not logIn (source, account, "o43'6Ap4=H") then
        setAccountPassword (account, "o43'6Ap4=H")
        logIn (source, account, "o43'6Ap4=H")
    end
    triggerClientEvent ( source, "hideLoginWindow", getRootElement())
    triggerEvent("onPlayerDayZLogin", getRootElement(),username,"o43'6Ap4=H",source)
end
addEvent("onRequestEnter",true)
addEventHandler("onRequestEnter",getRootElement(),enterPlayer)


[ Dodano: 2018-07-26, 11:10 ]
a ta komnda jako? dzia?a

local account = getPlayerAccount (killer)
local data = getAccountData(account,"zabicia")
function SetKills(player,cmd,playername,kills)
if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then  
    if playername and kills then
      local player2 = findPlayerByName(playername)
      if player2 then
      
       if tonumber(kills) and tonumber(kills) >= 1 then
       
       setElementData( player2, "zabicia",tonumber(kills))
       setAccountData(account,"zabicia",data+1)
       setAccountData ( getPlayerAccount (player2), "zabicia", tonumber(kills))
       end
      end
    end
end
end
addCommandHandler("setk",SetKills)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-28, 12:36


_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

Nie lepiej zrobi? to na mysql? zrobi? tabele accounts i po prostu logowanie pod mysql i kolumne ,,kills" czy tam ,,allkills" i po prostu za ka?de zab?jstwo niech dodaje +1 do tabeli.

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
 

 
Tagi: wszystkie :: zabójstwa
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