English its about lua tibia error

6 replies
Goto Page
To the start Previous 1 Next To the start
08.01.20 02:57:34 pm
Up
Lilliana01838
User
Offline Off
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
08.01.20 03:14:58 pm
Up
TrialAndError
User
Offline Off
Code:
1
for _, id in ipairs(player(id, 'table')) do


The error is there. You'll have to figure out to solve future errors by yourself.
08.01.20 03:27:40 pm
Up
haha1955
User
Offline Off
Then close the community if any not want help to fix errors.

I guess, all lost the respect...
@user TrialAndError:
08.01.20 03:39:06 pm
Up
Mora_rus
User
Offline Off
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.
08.01.20 03:45:26 pm
Up
Lilliana01838
User
Offline Off
@user Mora_rus: 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.
08.01.20 03:59:57 pm
Up
TrialAndError
User
Offline Off
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'.
08.01.20 04:10:03 pm
Up
Lilliana01838
User
Offline Off
@user TrialAndError: ok it works thanks
To the start Previous 1 Next To the start