• 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 Mana script

JoccE

CopyLeft (ɔ)
Joined
Aug 26, 2007
Messages
3,418
Solutions
1
Reaction score
92
Location
Sweden, Stockholm
Why does not this script work o_O

No error message and no mana given to the player.
Lua:
local LifeStorage = 12001
local ManaStorage = 12002
local ManaAmount = 25
local HealthAmount = 25
local GiveMana = { -- Sorcerers and Druids
	1,
	2,
	5,
	6
}
local GiveHealth = { -- Paladins and Kights
	3,
	4,
	7,
	8
}

function onUse(cid, item, toPosition, itemEx, fromPosition)
if getPlayerVocation(cid) == isInArray(GiveMana) then
	if getCreatureStorage(cid, ManaStorage) > 5 then 
		setCreatureMaxMana(cid, getCreatureMaxMana(cid) + ManaAmount)
		doRemoveItem(uid)
		doCreatureSetStorage(cid, ManaStorage, 1)
	end
end
if getPlayerVocation(cid) == isInArray(GiveHealth) then
	if getCreatureStorage(cid, LifeStorage) > 5 then 
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HealthAmount)
		doRemoveItem(uid)
		doCreatureSetStorage(cid, LifeStorage, 1)
	end
end

end

And btw :p why doesn´t the mana max update until you relog ?
 
Why does not this script work o_O

No error message and no mana given to the player.
Lua:
local LifeStorage = 12001
local ManaStorage = 12002
local ManaAmount = 25
local HealthAmount = 25
local GiveMana = { -- Sorcerers and Druids
	1,
	2,
	5,
	6
}
local GiveHealth = { -- Paladins and Kights
	3,
	4,
	7,
	8
}

function onUse(cid, item, toPosition, itemEx, fromPosition)
if getPlayerVocation(cid) == isInArray(GiveMana) then
	if getCreatureStorage(cid, ManaStorage) > 5 then 
		setCreatureMaxMana(cid, getCreatureMaxMana(cid) + ManaAmount)
		doRemoveItem(uid)
		doCreatureSetStorage(cid, ManaStorage, 1)
	end
end
if getPlayerVocation(cid) == isInArray(GiveHealth) then
	if getCreatureStorage(cid, LifeStorage) > 5 then 
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HealthAmount)
		doRemoveItem(uid)
		doCreatureSetStorage(cid, LifeStorage, 1)
	end
end

end

And btw :p why doesn´t the mana max update until you relog ?

This script will not work if the player doesnt have the storages

local LifeStorage = 12001
local ManaStorage = 12002

or this storages values is less than 6.

Regards,
 
This script will not work if the player doesnt have the storages

local LifeStorage = 12001
local ManaStorage = 12002

or this storages values is less than 6.

Regards,

Its ment to be that you only get mana when you have used it less then 5 times o_O

- - - Updated - - -

Change the > to a <

Still nothing
 
TO do like you want (only get mana if they used less than 5 times) use this modified script:

PHP:
local LifeStorage = 12001
local ManaStorage = 12002
local ManaAmount = 25
local HealthAmount = 25
local GiveMana = { -- Sorcerers and Druids
	1,
	2,
	5,
	6
}
local GiveHealth = { -- Paladins and Kights
	3,
	4,
	7,
	8
}
 
function onUse(cid, item, toPosition, itemEx, fromPosition)
if getPlayerVocation(cid) == isInArray(GiveMana) then
	if getCreatureStorage(cid, ManaStorage) >= 4 then 
		doPlayerSendTextMessage(cid, 22, "You already have used this Mana 5 times!")
	else	
		setCreatureMaxMana(cid, getCreatureMaxMana(cid) + ManaAmount)
		doRemoveItem(uid)
		doCreatureSetStorage(cid, ManaStorage, getCreatureStorage(cid, ManaStorage) + 1)
	end
end
if getPlayerVocation(cid) == isInArray(GiveHealth) then
	if getCreatureStorage(cid, LifeStorage) >= 4 then 
		doPlayerSendTextMessage(cid, 22, "You already have used this Life 5 times!")
	else		
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HealthAmount)
		doRemoveItem(uid)
		doCreatureSetStorage(cid, LifeStorage, getCreatureStorage(cid, LifeStorage) + 1)
	end
end
 
end

Make sure that the player vocations is the on below arrays (If you have any VIP vocation or any differente vocation will not work):

local GiveMana = { -- Sorcerers and Druids
1,
2,
5,
6
}
local GiveHealth = { -- Paladins and Kights
3,
4,
7,
8
}
 
Forgot the returns, try this one:
PHP:
local LifeStorage = 12001
local ManaStorage = 12002
local ManaAmount = 25
local HealthAmount = 25
local GiveMana = { -- Sorcerers and Druids
    1,
    2,
    5,
    6
}
local GiveHealth = { -- Paladins and Kights
    3,
    4,
    7,
    8
}
 
function onUse(cid, item, toPosition, itemEx, fromPosition)
if getPlayerVocation(cid) == isInArray(GiveMana) then
    if getCreatureStorage(cid, ManaStorage) >= 4 then 
        doPlayerSendTextMessage(cid, 22, "You already have used this Mana 5 times!")
		return TRUE
    else    
        setCreatureMaxMana(cid, getCreatureMaxMana(cid) + ManaAmount)
        doRemoveItem(uid)
        doCreatureSetStorage(cid, ManaStorage, getCreatureStorage(cid, ManaStorage) + 1)
		return TRUE
    end
end
if getPlayerVocation(cid) == isInArray(GiveHealth) then
    if getCreatureStorage(cid, LifeStorage) >= 4 then 
        doPlayerSendTextMessage(cid, 22, "You already have used this Life 5 times!")
		return TRUE
    else        
        setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HealthAmount)
        doRemoveItem(uid)
        doCreatureSetStorage(cid, LifeStorage, getCreatureStorage(cid, LifeStorage) + 1)
		return TRUE
    end
end
return FALSE
end
 
Lua:
local LifeStorage = 12001
local ManaStorage = 12002
local ManaAmount = 25
local HealthAmount = 25
local GiveMana = { -- Sorcerers and Druids
	1,
	2,
	5,
	6
}
local GiveHealth = { -- Paladins and Kights
	3,
	4,
	7,
	8
}
 
function onUse(cid, item, toPosition, itemEx, fromPosition)
	if isInArray(GiveMana, getPlayerVocation(cid)) then
		if getCreatureStorage(cid, ManaStorage) > 5 then 
			setCreatureMaxMana(cid, getCreatureMaxMana(cid) + ManaAmount)
			doRemoveItem(uid)
			doCreatureSetStorage(cid, ManaStorage, 1)
		end
	end
	if isInArray(GiveHealth, getPlayerVocation(cid)) then
		if getCreatureStorage(cid, LifeStorage) > 5 then 
			setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HealthAmount)
			doRemoveItem(uid)
			doCreatureSetStorage(cid, LifeStorage, 1)
		end
	end
return true
end
 
Lua:
local LifeStorage = 12001
local ManaStorage = 12002
local ManaAmount = 25
local HealthAmount = 25
local GiveMana = { -- Sorcerers and Druids
	1,
	2,
	5,
	6
}
local GiveHealth = { -- Paladins and Kights
	3,
	4,
	7,
	8
}
 
function onUse(cid, item, toPosition, itemEx, fromPosition)
	if isInArray(GiveMana, getPlayerVocation(cid)) then
		if getCreatureStorage(cid, ManaStorage) < 5 then 
			setCreatureMaxMana(cid, getCreatureMaxMana(cid) + ManaAmount)
			doRemoveItem(item.uid)
			doCreatureSetStorage(cid, ManaStorage, getCreatureStorage(cid, ManaStorage)+1)
		end
	end
	if isInArray(GiveHealth, getPlayerVocation(cid)) then
		if getCreatureStorage(cid, LifeStorage) < 5 then 
			setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HealthAmount)
			doRemoveItem(item.uid)
			doCreatureSetStorage(cid, LifeStorage, getCreatureStorage(cid, LifeStorare)+1)
		end
	end
return true
end
 
Back
Top