English [Tibia]Max Health / Max Mana

3 replies
Goto Page
To the start Previous 1 Next To the start
07.04.14 03:31:23 pm
Up
NeverLast
User
Offline Off
Hello,
I need help with my function:
Code:
1
2
3
4
5
6
7
8
9
10
addhook("ms100", "maxmp_maxhp")
function maxmp_maxhp()
parse("setmaxhealth " .. id .. " " .. PLAYERS[id].MAXHP) <--- This doesn't work :/
if PLAYERS[id] and PLAYERS[id].tmp.hp > PLAYERS[id].MAXHP then
   PLAYERS[id].tmp.hp = PLAYERS[id].MAXHP
end
if PLAYERS[id] and PLAYERS[id].MP > PLAYERS[id].MAXMP then
   PLAYERS[id].MP = PLAYERS[id].MAXMP
end
end

Here the error + line
Code:
1
2
3
parse("setmaxhealth " .. id .. " " .. PLAYERS[id].MAXHP)

LUA ERROR: sys/lua/cs2dtibia/hooks.lua:3: attempt to index field '?' (a nil value)


Or have a other idea to save and load max hp/mp + make max hp?
edited 2×, last 07.04.14 04:11:35 pm
IMG:http://www.sloganizer.net/style3,NeverLast.png
07.04.14 03:38:35 pm
Up
iLoveUS
User
Offline Off
Somethings wrong with the "PLAYERS[id].MAXHP",
maybe it doesn't exist, and there's also unnecessary spaces in line number 3
"No matter how much training you have or how strong you are, when you step on the battlefield for the first time, it changes you forever."
07.04.14 03:45:53 pm
Up
NeverLast
User
Offline Off
(config.lua)     
PLAYERINIT = {
          Experience = 0,
          Level = 1,
          Money = 50,
          HP = 100,
      MAXHP = 100,          
          MP = 100,
     MAXMP = 100,          
          Inventory = {},
          Equipment = {},
          Class = 0,
          Spawn = {784, 240},
          Tutorial = {},
          Info = {},
     },

the function(hook.lua)
IMG:http://www.sloganizer.net/style3,NeverLast.png
20.04.14 08:20:59 pm
Up
TA
User
Offline Off
If your using nick's edition then you need to to edit the health bar hook
To the start Previous 1 Next To the start