• 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 C++ Maxmana problem REP+

Status
Not open for further replies.

Hesham16

New Member
Joined
Jul 1, 2011
Messages
63
Reaction score
0
hi .. i have problem when people got more than 2 mi liar mana they got 0 mana if they got more lvls
and at database the maxmana changed to -xxxx and when i remove the (-) it works fine
so could someone help me please ?
REP+++
 
so i make it like soul in phpmyadmin right?
ok i tried it on new server but it is not working player didn't gain mana
if its not annoying could you put some pics and write on them?
 
It's not annoying.
But try executing (after removing mana column):
SQL:
ALTER TABLE `players` add `mana` UNSIGNED INT NOT NULL;
It's either Unsigned int or UINT
 
Code:
function onLogin(cid)
   if getCreatureMana(cid) < 0 then
      doCreatureAddMana(cid, getCreatureMana(cid) * -1 + getCreatureMaxMana(cid))
   end
   return true
end

the thing its happening with you is exactly what Korrex signature image shows

like people said, its impossible to have infinite mana, so the best thing you can do is try to work around it, with this code if your player has negative mana(it went over the limit) it'll simply make him have the max mana he can have
 
Code:
function onLogin(cid)
   if getCreatureMana(cid) < 0 then
      doCreatureAddMana(cid, getCreatureMana(cid) * -1 + getCreatureMaxMana(cid))
   end
   return true
end

the thing its happening with you is exactly what Korrex signature image shows

like people said, its impossible to have infinite mana, so the best thing you can do is try to work around it, with this code if your player has negative mana(it went over the limit) it'll simply make him have the max mana he can have

Y2K38 Bug ;).
Anyways Hesham, this is the only solution until mana value in Tibia becomes 64 bit.
 
Yeah, can't wait to see the panic and every outdated program that uses dates stop working xD

This'll fix the current mana problem, but I still dont understand, how the hell is the current mana bugging and the max mana isnt? they are both ints..
 
Yeah, can't wait to see the panic and every outdated program that uses dates stop working xD

This'll fix the current mana problem, but I still dont understand, how the hell is the current mana bugging and the max mana isnt? they are both ints..

MaxMana was probably compiled as uint_t(64)...
 
Lua:
function onLogin(cid)
   if (getCreatureMana(cid) =< 0) and (getPlayerLevel(cid) ~= 1) then
      doCreatureAddMana(cid, getCreatureMana(cid) * -1 + getCreatureMaxMana(cid))
   end
   return true
end

Use this script, credits to Scarlet Ayleid who posted it previously in your thread, but fixed. :)
 
why doesn't it work, what happens, what errors it shows on console
You have to give us something to help you on, just saying "It doesn't work" its like asking to someone "Where's the statue of 'something'?" and they reply "its in this city" and walk away

gosh, I hate it when people ask for help and don't tell us the errors
 
@Scarlet Ayleid
it must be fixed in c++ not lua
in creature.cpp
Code:
void Creature::changeHealth(int32_t healthChange)
{
	if(healthChange > 0)
		health += std::min(healthChange, getMaxHealth() - health);
	else
		health = std::max((int32_t)0, health + healthChange);
Code:
int32_t health, healthMax;
int32_t must be uint64_t or int64_t
but when i change it i found many errors
so if would be nice if you try to make it on a test server and when it successful tell me what exactly i change :p
 
Status
Not open for further replies.
Back
Top