Forum

> > CS2D > Scripts > its about lua tibia error
Forums overviewCS2D overview Scripts overviewLog in to reply

English its about lua tibia error

6 replies
To the start Previous 1 Next To the start

old its about lua tibia error

Lilliana01838
User Off Offline

Quote
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

old Re: its about lua tibia error

Mora
User Off Offline

Quote
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.

old Re: its about lua tibia error

Lilliana01838
User Off Offline

Quote
@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.

old Re: its about lua tibia error

TrialAndError
User Off Offline

Quote
Error has written
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'.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview