PHP Code:
new g_PlayerSkill[33][30];
public SkillGain(id, level)
{
static nextskill; nextskill = random_num(1 ,g_TotalSkill)
if(!IsPlayerHasSkill(id, nextskill))
{
Set_Skill(id, nextskill, true)
g_PlayerSkill[id][level-1] = nextskill
}
else
SkillGain(id, level)
}
public IsPlayerHasSkill(id, skillid)
{
for(new i=0; i<30; i++)
{
if(g_PlayerSkill[id][i] == skillid)
{
return true
}
}
return false
}
While running this part, when the number of player's skill obtained is closer to g_TotalSkill, the random might run into the existed skill id multiple time and costing a lot of resource + lag
Is there better way to check it?
__________________