Forum

> > CS2D > Scripts > its about lua tibia error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch its about lua tibia error

6 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt its about lua tibia error

Lilliana01838
User Off Offline

Zitieren
LUA ERROR: sys/lua/cs2dtibia/hooks.lua:343: bad argument #1 to 'player' (number expected, got nil)
-> [C]: in function 'player'
-> sys/lua/cs2dtibia/hooks.lua:343: in function <sys/lua/cs2dtibia/hooks.lua:311>

     for _, id in ipairs(player(id, 'table')) do
          if PLAYERS[id] and PLAYERS[id].tmp then
               mana = 100 + ( PLAYERS[id].Level / 5 )
               mana = mana / 100
               mana = mana * 91
               mana = round(mana)
               mana = PLAYERS[id].Level / 5
               mana = manaa + 100
               mana = round(mana)
               mana = round( ( (100 + (PLAYERS[id].Level/5) ) / 100) * 90)
               mana = mana + 100
               mana = mana / 100
               mana = mana * 90
               mana = round(mana)
               if PLAYERS[id]['Mana'] < mana then
                    mana = PLAYERS[id].Level / 50
                    mana = mana + 10 + PLAYERS[id]['Mana']
                    mana = round(mana)
                    PLAYERS[id]['Mana'] = mana
               elseif PLAYERS[id]['Mana'] < mana and PLAYERS[id]['Mana'] > mana then
                    PLAYERS[id]['Mana'] = 100+round(PLAYERS[id].Level / 5)
               end
               updateHUD(id)
          end
     end

alt Re: its about lua tibia error

Mora
User Off Offline

Zitieren
Did you even tried to analyze the given line?

So we're losing that moment of teaching people to figure out what is going wrong.

Do you know the difference between ipairs and pairs?
Is a next tip.

alt Re: its about lua tibia error

Lilliana01838
User Off Offline

Zitieren
@user Mora: yes i know the difference between ipairs and pairs, i have already tried it but i haven't been able to solve it. could you please tell me what's wrong.

PS: To teach? Who taught me here? so far you haven't taught me anything.

alt Re: its about lua tibia error

TrialAndError
User Off Offline

Zitieren
Error hat geschrieben
bad argument #1 to 'player' (number expected, got nil)


Let's see:

player(id, 'table')

First argument: id is equal to nil. So that tells us id is nil. We must put 0 instead to get all the players.

Also your mana calculation is all over the place. It will probably complain about 'manaa'.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht