• 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!

Knight MAX mlvl, 61

WiLDTuRTLE

Member
Joined
Feb 26, 2011
Messages
478
Reaction score
5
How can i setup max knights magic level, 61?
I know in vocation,xml but what number should i put and where? im not rly sure :/ thanks
 
vocations.xml - not possible

only via creatureevents, in login.lua:
LUA:
if isKnight(cid) == true then
if getPlayerMagicLevel(cid) > 61 then
doPlayerSetMagicLevel(cid, 61)
...

But, if your knights have mlvl 60~ i don't want to play on your server
 
vocations.xml - not possible

only via creatureevents, in login.lua:
LUA:
if isKnight(cid) == true then
if getPlayerMagicLevel(cid) > 61 then
doPlayerSetMagicLevel(cid, 61)
...

But, if your knights have mlvl 60~ i don't want to play on your server


You have no idea of my server sir, but where at im supose to add this, i tried to add it at the end doesnt work, at the beg doesnt work either :|

Or there a way to give a Magic Rate per voc?
 
Last edited:
The best way would be to edit player.cpp, if player is a knight and his mlvl is equal to 61 he should not gain mana spent.
The other way is to check advancement in the onAdvance creature event. If the knight is advancing to mlvl 62, set his mana spent to 0 and return false.
 
make sure that in your data>lib folder you have xxx-vocations.xml x meaning numbers not positive if they are the same in all servers but in mine it's 031

be sure it has that and for the numbers 4, 8 make sure if you have any more promotions you put the ids in that array.
LUA:
function isKnight(cid)
	return isInArray({4, 8}, getPlayerVocation(cid))
end

then go to data>creaturescripts
add this to creaturescripts.xml after your normal login script
XML:
<event type="login" name="PlayerLoginChecks" event="script" value="loginchecks.lua"/>

go to data>creaturescripts>scripts
make a file called loginchecks.lua
add this to it
LUA:
function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isKnight(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true
end
 
Greaaaaaaaaaaaaaaaaaaaaaaaaaaaatttt !!!!!! , as i can see there is also a way to give a magic rate to each voc? ^^'

- - - Updated - - -

If i also want to do the same for paladins , would it be like that?


Code:
function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isKnight(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true

function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isPaladin(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true
end

?
 
The best way would be to edit player.cpp, if player is a knight and his mlvl is equal to 61 he should not gain mana spent.
The other way is to check advancement in the onAdvance creature event. If the knight is advancing to mlvl 62, set his mana spent to 0 and return false.

id like to do that but never used cc+ either lol, :|


STILL DOESNT WORK :| error line 6, around 'players'
 
a lot of people have trouble with compiling such as me, I have issues, I have tryed many different ways to make 64 bit and such I managed to get 32 bit fine and working but took me a lot to do xD, he just wants a fix that he can use for now till he learns.

but anyways
almost Rcedrick, but you added the function onLogin(cid) again which is unnecessary

you would add like this
LUA:
function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isKnight(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end

	if isPaladin(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true
end

because adding local playerid = getPlayerGUID(cid) defines the players id for the whole script. and same with function onLogin(cid)

if you add return true more than once inside of a function it will give you errors, using return true will return what has been read on the script at that point in the script.
 
a lot of people have trouble with compiling such as me, I have issues, I have tryed many different ways to make 64 bit and such I managed to get 32 bit fine and working but took me a lot to do xD, he just wants a fix that he can use for now till he learns.

but anyways
almost Rcedrick, but you added the function onLogin(cid) again which is unnecessary

you would add like this
LUA:
function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isKnight(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end

	if isPaladin(cid) then
		if getPlayerMagicLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagicLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true
end

because adding local playerid = getPlayerGUID(cid) defines the players id for the whole script. and same with function onLogin(cid)

if you add return true more than once inside of a function it will give you errors, using return true will return what has been read on the script at that point in the script.



Problem :/

2hyb7s9.jpg


Ced is my GOD char, every other voc can login but knights and pally :3
 
Try changing getPlayerMagicLevel to getPlayerMagLevel check functions for the function name I forget but if your distro doesn't have the function ill make another one for you I'm on my phone right now so I can't right now
 
Try changing getPlayerMagicLevel to getPlayerMagLevel check functions for the function name I forget but if your distro doesn't have the function ill make another one for you I'm on my phone right now so I can't right now



Triied, gave me this error;

xprj0p.jpg


pd; thanks for your perseverance man, i like it :p
 
LoL like this.

use this.
LUA:
function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isKnight(cid) then
		if getPlayerMagLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
 
	if isPaladin(cid) then
		if getPlayerMagLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true
end
instead of
Code:
getPlayerMagicLevel(cid)
use
Code:
getPlayerMagLevel(cid)
I made the mistake of using the first one. Sorry!

And yes everyone we know that c++ is easier, but nobody has actually provided a proper guide and toolset to compile for people that don't understand the functionality of programming, also, I am just starting to compile and change sources and stuff now, and I still can't figure out how to compile an older distro in 64 bit.

So I imagine someone entirely new to it isn't going to just know what to do.
 
LoL like this.

use this.
LUA:
function onLogin(cid)
	local playerid = getPlayerGUID(cid)
	if isKnight(cid) then
		if getPlayerMagLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
 
	if isPaladin(cid) then
		if getPlayerMagLevel(cid) > 61 then
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `maglevel` = "61" WHERE `id` = "' .. playerid .. '"')
		elseif getPlayerMagLevel(cid) == 61 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
			doPlayerSetMagicRate(cid, 0)
		end
	end
	return true
end
instead of
Code:
getPlayerMagicLevel(cid)
use
Code:
getPlayerMagLevel(cid)
I made the mistake of using the first one. Sorry!

And yes everyone we know that c++ is easier, but nobody has actually provided a proper guide and toolset to compile for people that don't understand the functionality of programming, also, I am just starting to compile and change sources and stuff now, and I still can't figure out how to compile an older distro in 64 bit.

So I imagine someone entirely new to it isn't going to just know what to do.


It works well beside it send a huge ass error when player relog (if ml higher than 61) but player get his ml set back to 61, thanks alot man :) rep for u
 
Back
Top