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

doPlayerAddSkill(cid,skill, n) ???

Virgel

New Member
Joined
Jun 14, 2007
Messages
150
Reaction score
2
Greetings...

i can see there is a function to get the player skill, but there isnt a function to add or remove the skillamount of a player.

getPlayerSkill(cid, skill)
doPlayerAddSkill(cid,skill,n)

So it would be easy to set the skill of a player up or down without adding a skilltry... specialy i need to reduce the skill to an exact number without any trys.

Thx for you help

Baba
Virgel
 
Code:
function setPlayerSkill(cid,skillid,level)
         start_skill = getPlayerSkill(cid,skillid)
         if level > start_skill then
                  while start_skill ~= level do
                           doPlayerAddSkillTry(cid,skillid,1)
                  end
         elseif level < start_skill then
                  while start_skill ~= level do
                           doPlayerAddSkillTry(cid,skillid,-1)
                  end
         end
end

I'm not sure if it'll work, can you tell me after testing it?
 
How i sayd... i dont wish to work with SkillTrys.
I will say why:

On my server players should not be able to train that much, because a lvl 8 player dont need a 100+ skill and now i try to make a border.

That means when a player is lvl 8 the maximum skill he can get when training is lvl*2 (16 at this example). A lvl 20 for example can get skill 40 as maximum and i try to check on login if the skill is actually to high for the player level or if its okay.

If the skill is to high it should be reduced to the max. skill the player can have. I just need a function that reduce the players skill.

Example of my idea:
Code:
local fistSkill = getPlayerSkill(cid,0)
local level = getPlayerLevel(cid)
local maxSkill = level*2

function onLogin(cid)
	if fistSkill > maxSkill then
              newSkill = fistSkill - maxSkill
              doPlayerAddSkill(cid,0,-newSkill)	
	end
 	return TRUE
end

doPlayerAddSkill can be for sure also setPlayerSkill (then you just need to reduce to the maxSkill) but i think doPlayerAddSkill gives more options because you may also add and reduce skillpoints ;)

Baba
Virgel
 
well I think that there is no other way...
Code:
function setPlayerSkill(cid,skillid,level)
         start_skill = getPlayerSkill(cid,skillid)
         if level > start_skill then
                  while start_skill ~= level do
                           doPlayerAddSkillTry(cid,skillid,1)
                           start_skill = getPlayerSkill(cid,skillid)
                  end
         elseif level < start_skill then
                  while start_skill ~= level do
                           doPlayerAddSkillTry(cid,skillid,-1)
                           start_skill = getPlayerSkill(cid,skillid)
                  end
         end
end

function doPlayerAddSkill(cid,skillid,n)
         new_skill = getPlayerSkill(cid,skillid)+n
         setPlayerSkill(cid,skillid,new_skill)
end
I tried the function, but it only worked with setting a higher skill, if you reduce it the server will freeze and crash...
Maybe anybody else knows how to make it work.
 
Thx you :)
I tryd this but i got the same problem like you (freeze)

Code:
function onLogin(cid)
	local fistSkill = getPlayerSkill(cid, 0)
	local playerLevel = getPlayerLevel(cid)
	local maxSkill = playerLevel*2	
	if fistSkill > maxSkill then
		while fistSkill ~= maxSkill do
			doPlayerAddSkillTry(cid,0,-1)
		end
	end
 	return TRUE
end

Baba Virgel
 
Back
Top