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

Wysłany: 2015-02-01, 00:34


Daisu

Programista Lua






Wiek: 26
Na forum: 4444 dni
Posty: 193
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Witajcie mam SaveScore by marmat przerobi?em go pod system paczek. Kiedy? mia?em ten problem ale on powr?ci? jednak teraz uda?o mi si? ?e w tabeli na TAB mam 0 ale gdy wyjd? z servera lub zresetuje skrypt albo wy??cze server znowu mam 0 po prostu Score si? nie zapisuje, prosi?bym o pomoc jest to banalna sprawa kt?rej nie potrafi? rozwi?za?.

META.XML



<meta> 
    <info name="SaveScore" author="maciek00 and KineQ" type="script" version="3.1" />

 <script src="scores.lua" type="server" />
 <script src="savescore.lua" type="server" />
    
    
</meta>



Scores.lua


addEventHandler('onResourceStart',getResourceRootElement(),
function()
    call(getResourceFromName("scoreboard"), "addScoreboardColumn""Score")
    for theKey,thePlayer in ipairs(getElementsByType "player" )) do
        setElementData(thePlayer,"Score",0)
    end
end)

addEventHandler('onPlayerJoin',getRootElement(),
function()

    setElementData(source,"Score",0)
end)

function addScore(points)
    setElementData(source"score"getElementData(source"score") + points)
end

addEvent("addScore"true)
addEventHandler("addScore"getRootElement(), addScore)
---------dawanie score

addCommandHandler "dajscore",
function ( playercmdnickkwota )
local playerName getAccountName getPlayerAccount player ) )   
 if isObjectInACLGroup "user." .. playerNameaclGetGroup "Admin" ) ) then
  if nick and kwota then
   local aplayer getPlayerFromName nick )
   if aplayer then
    kwota tonumber(kwota)
    setElementData(aplayer,"score",kwota)
    --givePlayerMoney aplayerkwota )
    outputChatBox("PKT Pomy?lnie dodanie"player,230,230,230,true)
    outputDebugString "Score dodane" )

    else
    outputChatBox"Nie uda?o si? doda? pkt."player,230,230,230,true)   
    outputDebugString "Nieudana proba dodania score." )

    end 
   end
   else
   outputChatBox("Nie jeste? administratorem."player,230,230,230,true)
  end
 end
 )






savescore.lua




function onPlayerLogin ()
        local playeraccount getPlayerAccount source )
        if ( playeraccount then
                if not isGuestAccount playeraccount then
                        local playerpkt getAccountData playeraccount"score" )  --points
                        --local playermoney getAccountData playeraccount"s.HandMoney" )
            --setPlayerMoneygetRootElement(), playermoney )
                        if ( playerpkt then
                                setElementData(source"score"tonumber(playerpkt)) --pkt
                                --setElementData(source"Kasa"tonumber(playermoney))
                --setPlayerMoneygetRootElement(), playermoney )

                        end
                end
        end
end

function onPlayerQuit ()
        local playeraccount getPlayerAccount source )
        if ( playeraccount then
                if not isGuestAccount playeraccount then
                        local playerpkt getElementData source"score" )  -- pkt
                       -- local playermoney getPlayerMoney(source)
            --setAccountData playeraccount"s.HandMoney"playermoney )
                        if ( playerpkt then
                                setAccountData playeraccount"score"playerpkt ) -- points
                               -- setAccountData playeraccount"s.HandMoney"playermoney )
                        end
                end
        end
end

addEventHandler "onPlayerLogin"getRootElement (), onPlayerLogin )
addEventHandler "onPlayerQuit"getRootElement (), onPlayerQuit )
addEventHandler ("onResourceRestart"getRootElement (), onPlayerQuit )
addEventHandler ("onResourceStop"getRootElement (), onPlayerQuit )




Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-01, 16:00


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

Drogi kolego. A gdzie funkcja na dawanie setElementData jako Score po zalogowaniu? Rubryka pod TAB wy?wietla Ci elementDat?, z tak? sam? nazw? ;) .

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-01, 17:30


Daisu

Programista Lua






Wiek: 26
Na forum: 4444 dni
Posty: 193
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Funkcja setElementData mia?a by? zawarta w panelu lowowania przy funkcji od rejestracji:
- setElementData(gracz,"Score",0)
- setAccountData(account,"score",0)
Jednak prosi? bym o pomoc aby te funkcj? by?y zawarte w savescore a nie w logowaniu.

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-01, 21:16


Novovix

xNinja powraca






Wiek: 26
Na forum: 4870 dni
Posty: 240
Nick w MP: xNinja

Piwa: 452

Respekt: 80,5

Najpierw zr?b funkcje, po wyjsciu gracza getElementData oraz setAccountData i po wejsciu getAccountData potej funkcji uzyj setElementData. Licze na zimne piwo lub/i repke :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-01, 22:51


Daisu

Programista Lua






Wiek: 26
Na forum: 4444 dni
Posty: 193
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Funkcja po wej?ciu jest zawarta w SaveScore a po wyj?ciu ogarn? jutro.

[ Dodano: 2015-02-02, 01:03 ]
Nie ogarniam jak ma to wygl?da? po wyj?ciu.

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-01, 23:34


Novovix

xNinja powraca






Wiek: 26
Na forum: 4870 dni
Posty: 240
Nick w MP: xNinja

Piwa: 452

Respekt: 80,5

Get account name
get element data
set account data
Tylko te 3 funkcje chyba potrzebujesz.. No i oczywi?cie event - s-side.

[ Dodano: 2015-02-01, 23:37 ]
I jak tam masz setElementData -onPlayerJoin zmien na onPlayerLogin

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-01, 23:44


Daisu

Programista Lua






Wiek: 26
Na forum: 4444 dni
Posty: 193
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

M?g?by? si? zlitowa? i da? gotowca. Tak wiem ?e si? nie naucz? tego.

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-02, 10:40


Novovix

xNinja powraca






Wiek: 26
Na forum: 4870 dni
Posty: 240
Nick w MP: xNinja

Piwa: 452

Respekt: 80,5

Mog?by? w ko?cu zrozumie?, ?e robie to aby? si? czego? nauczy? i w razie problem?w dopiero pisa?.. przesta? prosi? o gotowca i we? si? do roboty, wszystko ci opisa?em co masz zrobi?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-02, 14:21


Daisu

Programista Lua






Wiek: 26
Na forum: 4444 dni
Posty: 193
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Wiem tylko pisa?em w nocy i nawala?a mi g?owa. Zaraz to ogarn? bo wiem jak to zrobi?,

[ Dodano: 2015-02-02, 16:25 ]
Ogarn? panel rejestracji kt?ry nadaje sam 0 po rejestracji i dam zna?.

[ Dodano: 2015-02-02, 17:40 ]
Dobra doda?em do logowania :



            account addAccount(usernamepassword)
            setElementData(gracz,"konto_login",username)
            setAccountData(account,"score",0)
            setAccountData(account,"idac",#getAccounts()+100)
            setElementData(gracz,"Score",0)
            setElementData(gracz,"ID Konta",#getAccounts()+100)
            triggerClientEvent(gracz,"hideLoginWindow",getRootElement())


i


            local sco getAccountData(account,"score")
            local idacc getAccountData(account,"idac")
            setElementData(gracz,"konto_login",username)
            setElementData(gracz,"Score",sco)



Nadaje na start Po rejestracji 0 ale teraz gdy zresetuje skrypt na Save Score jest ok ale gdy wyjde i wejde na serv mam odnowa 0 . Czy gdzie? jest b??d ?

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-02, 23:05


Novovix

xNinja powraca






Wiek: 26
Na forum: 4870 dni
Posty: 240
Nick w MP: xNinja

Piwa: 452

Respekt: 80,5

Do eventu onPlayerQuit/exit podpinasz setAccountData i tyle.. A po wejsciu jak ju? wcze?niej pisa?em getAccountData i setElementData

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-02-04, 23:54


Daisu

Programista Lua






Wiek: 26
Na forum: 4444 dni
Posty: 193
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Czy mo?e by? tak ?

function onPlayerLogin ()
        local playeraccount getPlayerAccount source )
        if ( playeraccount then
                if not isGuestAccount playeraccount then
                        local playerscore getAccountData playeraccount"points" )
                        if ( playerscore then
                                setElementData(source"Score"tonumber(playerscore))
                        end
                end
        end
end

function onPlayerQuit ()
        local playeraccount getPlayerAccount source )
        if ( playeraccount then
                if not isGuestAccount playeraccount then
                        local playerscore getElementData source"Score" )
                        if ( playerscore then
                                setAccountData playeraccount"points"playerscore )
                        end
                end
        end
end

addEventHandler "onPlayerLogin"getRootElement (), onPlayerLogin )
addEventHandler "onPlayerQuit"getRootElement (), onPlayerQuit )
addEventHandler "onResourceStop"resourceRootonCurrentResourceStop)
addEventHandler "onResourceStart"resourceRootonCurrentResourceStart)




Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: działający :: savescore
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