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

Player Advance

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
My script don't work:
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
	if ((newlevel == 100) and (getPlayerGroupId(cid) <= 2)) then
	   doBroadcastMessage(getCreatureName(cid).." advanced from Level "..oldlevel.." to Level "..newlevel..".")
	 elseif ((newlevel == 200) and (getPlayerGroupId(cid) <= 2)) then
	   doBroadcastMessage(getCreatureName(cid).." advanced from Level "..oldlevel.." to Level "..newlevel..".")
	 elseif ((newlevel == 300) and (getPlayerGroupId(cid) <= 2)) then
	   doBroadcastMessage(getCreatureName(cid).." advanced from Level "..oldlevel.." to Level "..newlevel..".")
	 elseif ((newlevel == 400) and (getPlayerGroupId(cid) <= 2)) then
	   doBroadcastMessage(getCreatureName(cid).." advanced from Level "..oldlevel.." to Level "..newlevel..".")
	 elseif ((newlevel == 500) and (getPlayerGroupId(cid) <= 2)) then
	   doBroadcastMessage(getCreatureName(cid).." advanced from Level "..oldlevel.." to Level "..newlevel..".")
 end
 return TRUE
end

In login.LUA:
Code:
	   registerCreatureEvent(cid, "playerAdvance")

The xml tag:
Code:
	<event type="advance" name="PlayerAdvance" script="playeradvance.lua"/>
 
I'm not sure but you could try using

PHP:
elseif ((getPlayerLevel(cid) == 200) and (getPlayerGroupId(cid) <= 2)) then

instead of

PHP:
elseif ((newlevel == 200) and (getPlayerGroupId(cid) <= 2)) then
 
I'm not sure but you could try using

PHP:
elseif ((getPlayerLevel(cid) == 200) and (getPlayerGroupId(cid) <= 2)) then

instead of

PHP:
elseif ((newlevel == 200) and (getPlayerGroupId(cid) <= 2)) then
Player on 200 level would get messages ex. when he skill distance up.

#topic:
PHP:
registerCreatureEvent(cid, "PlayerAdvance")
Considier on letter case.
 
I have edited, I will test:
Code:
			---by BomBa---
			--------------

function onAdvance(cid, skill, oldlevel, newlevel)
 local config =
{
   msgAdvance = "The "..getCreatureName(cid).." advanced from Level "..oldlevel.." to Level "..newlevel..".",
   msgType = MESSAGE_STATUS_CONSOLE_RED
}
	if getPlayerGroupId(cid) <= 2 then
	if getPlayerLevel(cid) == 100 then
	   broadcastMessage(config.msgAdvance, config.msgType)
	 elseif getPlayerLevel(cid) == 200 then
	   broadcastMessage(config.msgAdvance, config.msgType)
	 elseif getPlayerLevel(cid) == 300 then
	   broadcastMessage(config.msgAdvance, config.msgType)
	 elseif getPlayerLevel(cid) == 400 then
	   broadcastMessage(config.msgAdvance, config.msgType)
	 elseif getPlayerLevel(cid) == 500 then
	   broadcastMessage(config.msgAdvance, config.msgType)
  end
 end
  return TRUE
end

Code:
	   registerCreatureEvent(cid, "PlayerAdvance")
 
Eh... take mine (by Pitufo):
PHP:
local data = {
    [0] = { "Fist skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [1] = { "Club skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [2] = { "Sword skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [3] = { "Axe skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [4] = { "Distance skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [5] = { "Shield skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [6] = { "Fishing skill UP", 30}, -- 30 = variable[2]  -- Animation effect
    [7] = { "Magic level UP", 30}, -- 30 = variable[2]  -- Animation effect
    [8] = { "Level UP", 30} -- 30 = variable[2]  -- Animation effect
}
local config = {
showAllAdvances = "YES", --(YES/NO) // czy ma pokazywac napis nad postacia przy kazdym awansie? // YES == tak, NO == nie
broadcastOnLevels = {100, 200, 300, 400, 500} -- wpisz poziomy, na ktorych ma oglaszac awans kazdemu graczowi // aby wylaczyc wpisz samo 0
}
function onAdvance(cid, skill, oldlevel, newlevel)
local pos = getPlayerPosition(cid)
local positions = {
        {x=pos.x+1,y=pos.y-1,z=pos.z},
        {x=pos.x-1,y=pos.y-1,z=pos.z},
        {x=pos.x+1,y=pos.y+1,z=pos.z},
        {x=pos.x-1,y=pos.y+1,z=pos.z},
        {x=pos.x+1,y=pos.y,z=pos.z},
        {x=pos.x-1,y=pos.y,z=pos.z},
        {x=pos.x,y=pos.y+1,z=pos.z},
        {x=pos.x,y=pos.y-1,z=pos.z}}
        
	if config.showAllAdvances == "YES" and (isInArray(config.broadcastOnLevels, getPlayerLevel(cid))) == TRUE and skill == 8 then
		broadcastMessage(getPlayerName(cid).." has been advanced on ".. newlevel .." level. Congratulations!", MESSAGE_EVENT_ADVANCE)
	end
	

    for type, variable in pairs(data) do
        if skill == type then
		doCreatureSay(cid, ""..variable[1].." ["..newlevel.."]", TALKTYPE_ORANGE_1)
		for i = 1, table.maxn(positions) do
                    doSendMagicEffect(positions[i],variable[2])
		end
		break
        end
    end    
return TRUE
end

data/creaturescripts/scripts/login.lua
PHP:
registerCreatureEvent(cid, "PlayerAdvance")

data/creaturescripts/creaturescripts.xml
PHP:
<event type="advance" name="PlayerAdvance" script="mine/advance.lua"/>

It works for sure.
 
Last edited:
Back
Top