• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua SetPlayerMax HP/MP 0.4

dawnking

Member
Joined
Jun 23, 2016
Messages
176
Reaction score
22
How do i doing wrong? To set max HP / MP?

Code:
       local hp = getPlayerLevel(cid) * 5
       local mp = getPlayerLevel(cid) * 30
       setPlayerMaxHealth(cid, hp)
       setPlayerMaxMana(cid, mp)

Code:
[0:43:25.613] [Error - NpcScript Interface]
[0:43:25.614] data/npc/scripts/oracle.lua:onCreatureSay
[0:43:25.614] Description:
[0:43:25.614] data/npc/scripts/oracle.lua:37: attempt to call global 'setPlayerMaxHealth' (a nil value)
[0:43:25.614] stack traceback:
[0:43:25.614]    data/npc/scripts/oracle.lua:37: in function 'callback'
[0:43:25.614]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[0:43:25.614]    data/npc/scripts/oracle.lua:13: in function <data/npc/scripts/oracle.lua:13>
 
Solution
300/150 ?? Not 150/300?
Code:
local hp = (getCreatureMaxHealth(cid) + getPlayerLevel(cid) * 5)
local mp = (getCreatureMaxMana(cid)+ getPlayerLevel(cid) * 30)
setCreatureMaxHealth(cid, hp)
setCreatureMaxMana(cid, mp)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), false)
doCreatureAddMana(cid, getCreatureMaxMana(cid), false)
doPlayerSetMaxHealth?

Not work bro
Code:
       local hp = getPlayerLevel(cid) * 5
       local mp = getPlayerLevel(cid) * 30
       doPlayerSetMaxHealth(cid, hp)
       doPlayerSetMaxMana(cid, mp)

Code:
[15:54:42.274] [Error - NpcScript Interface]
[15:54:42.274] data/npc/scripts/oracle.lua:onCreatureSay
[15:54:42.274] Description:
[15:54:42.274] data/npc/scripts/oracle.lua:37: attempt to call global 'doPlayerSetMaxHealth' (a nil value)
[15:54:42.274] stack traceback:
[15:54:42.274]    data/npc/scripts/oracle.lua:37: in function 'callback'
[15:54:42.274]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[15:54:42.274]    data/npc/scripts/oracle.lua:13: in function <data/npc/scripts/oracle.lua:13>
 
Not work bro
Code:
       local hp = getPlayerLevel(cid) * 5
       local mp = getPlayerLevel(cid) * 30
       doPlayerSetMaxHealth(cid, hp)
       doPlayerSetMaxMana(cid, mp)

Code:
[15:54:42.274] [Error - NpcScript Interface]
[15:54:42.274] data/npc/scripts/oracle.lua:onCreatureSay
[15:54:42.274] Description:
[15:54:42.274] data/npc/scripts/oracle.lua:37: attempt to call global 'doPlayerSetMaxHealth' (a nil value)
[15:54:42.274] stack traceback:
[15:54:42.274]    data/npc/scripts/oracle.lua:37: in function 'callback'
[15:54:42.274]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[15:54:42.274]    data/npc/scripts/oracle.lua:13: in function <data/npc/scripts/oracle.lua:13>

Try doCreatureSetMaxHealth or setCreatureMaxHealth
The 0.x versions are kinda weird, most getPlayer etc are actually getCreature in the source code.
 
local hp = getPlayerLevel(cid) * 5
local mp = getPlayerLevel(cid) * 30
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)+hp))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+mp))

I think setCreatureMaxHealth is working, but setCreatureHealth not
setCreatureMaxHealth(cid, hp)
setCreatureHealth(cid, hp)

Code:
[16:17:53.356] [Error - NpcScript Interface]
[16:17:53.356] data/npc/scripts/oracle.lua:onCreatureSay
[16:17:53.356] Description:
[16:17:53.357] data/npc/scripts/oracle.lua:43: attempt to call global 'setCreatureHealth' (a nil value)
[16:17:53.357] stack traceback:
[16:17:53.357]    data/npc/scripts/oracle.lua:43: in function 'callback'
[16:17:53.357]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[16:17:53.357]    data/npc/scripts/oracle.lua:13: in function <data/npc/scripts/oracle.lua:13>

Try doCreatureSetMaxHealth or setCreatureMaxHealth
The 0.x versions are kinda weird, most getPlayer etc are actually getCreature in the source code.

Where can i found this stuffs?
 
local hp = (getCreatureMaxHealth(cid) + getPlayerLevel(cid) * 5)
local mp = (getCreatureMaxMana(cid)+ getPlayerLevel(cid) * 30)
setCreatureMaxHealth(cid, hp)
setCreatureMaxMana(cid, mp)
 
Lua:
local hp = getPlayerLevel(cid) * 5
local mp = getPlayerLevel(cid) * 30

setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(hp))
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+(mp))

@edit Too late, Aion was faster.
 
local hp = (getCreatureMaxHealth(cid) + getPlayerLevel(cid) * 5)
local mp = (getCreatureMaxMana(cid)+ getPlayerLevel(cid) * 30)
setCreatureMaxHealth(cid, hp)
setCreatureMaxMana(cid, mp)

Lua:
local hp = getPlayerLevel(cid) * 5
local mp = getPlayerLevel(cid) * 30

setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(hp))
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+(mp))

@edit Too late, Aion was faster.

????

I asked about set health after maxhealth, like i said, maxhealth looks work, but health no
I need to change because my health was 300/150, for example
 
300/150 ?? Not 150/300?
Code:
local hp = (getCreatureMaxHealth(cid) + getPlayerLevel(cid) * 5)
local mp = (getCreatureMaxMana(cid)+ getPlayerLevel(cid) * 30)
setCreatureMaxHealth(cid, hp)
setCreatureMaxMana(cid, mp)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), false)
doCreatureAddMana(cid, getCreatureMaxMana(cid), false)
 
Solution
300/150 ?? Not 150/300?
Code:
local hp = (getCreatureMaxHealth(cid) + getPlayerLevel(cid) * 5)
local mp = (getCreatureMaxMana(cid)+ getPlayerLevel(cid) * 30)
setCreatureMaxHealth(cid, hp)
setCreatureMaxMana(cid, mp)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), false)
doCreatureAddMana(cid, getCreatureMaxMana(cid), false)

Thank you so much!

One last thing:
Did you know a function to save player, i scare to server crash and player get a bugged health / mana
 
I think setCreatureMaxHealth is working, but setCreatureHealth not
setCreatureMaxHealth(cid, hp)
setCreatureHealth(cid, hp)

Code:
[16:17:53.356] [Error - NpcScript Interface]
[16:17:53.356] data/npc/scripts/oracle.lua:onCreatureSay
[16:17:53.356] Description:
[16:17:53.357] data/npc/scripts/oracle.lua:43: attempt to call global 'setCreatureHealth' (a nil value)
[16:17:53.357] stack traceback:
[16:17:53.357]    data/npc/scripts/oracle.lua:43: in function 'callback'
[16:17:53.357]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[16:17:53.357]    data/npc/scripts/oracle.lua:13: in function <data/npc/scripts/oracle.lua:13>



Where can i found this stuffs?

tfs-old-svn/luascript.cpp at 0.4 · otland/tfs-old-svn · GitHub

Thank you so much!

One last thing:
Did you know a function to save player, i scare to server crash and player get a bugged health / mana

tfs-old-svn/luascript.cpp at 0.4 · otland/tfs-old-svn · GitHub
 
Back
Top