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

CreatureEvent Auto-Promote!

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
When you advance to XXX level - script advance you to promoted vocation (for free, for level xxxd)
data/creaturescript/scripts/promotion.lua
PHP:
local config = {
	promoLevel = 1,	-- promotion level : )
	needLevel = 20, -- level to get promotion 
	needPremium = "yes" -- need premium (YES/NO)? :D
}

function onAdvance(cid, skill, oldlevel, newlevel)
	if (skill == 0) and (newlevel >= config.needLevel and getPlayerPromotionLevel(cid)<config.promoLevel) then
		if(string.lower(config.needPremium) == "yes" and isPremium(cid) == TRUE) or (string.lower(config.needPremium) == "no") then 
			setPlayerPromotionLevel(cid, config.promoLevel)
			doPlayerSendTextMessage(cid, 22, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
		end
	end
	return TRUE
end

and creaturescript.xml
PHP:
<event type="advance" name="promotion" script="promotion.lua"/>

:)
 
When you advance to XXX level - script advance you to promoted vocation (for free, for level xxxd)
data/creaturescript/scripts/promotion.lua
PHP:
local config = {
	promoLevel = 1,	-- promotion level : )
	needLevel = 20, -- level to get promotion 
	needPremium = "yes" -- need premium (YES/NO)? :D
}

function onAdvance(cid, skill, oldlevel, newlevel)
	if (skill == 0) and (newlevel >= config.needLevel and getPlayerPromotionLevel(cid)<config.promoLevel) then
		if(string.lower(config.needPremium) == "yes" and isPremium(cid) == TRUE) or (string.lower(config.needPremium) == "no") then 
			setPlayerPromotionLevel(cid, config.promoLevel)
			doPlayerSendTextMessage(cid, 22, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
		end
	end
	return TRUE
end

and creaturescript.xml
PHP:
<event type="advance" name="promotion" script="promotion.lua"/>

:)

Correct me if im wrong, but will this script tell the player they have been promoted? Sorry for being a newbie.
 
Correct me if im wrong, but will this script tell the player they have been promoted? Sorry for being a newbie.

We've all been newbies dont worry ;)

This script will autopromote the player after he reaches lvl 20 (or the lvl you choose in the script's config: "needLevel = ").

So he doesnt need an NPC for the promotion, if he gets lvl 20 he's automatically promoted for free and he receives a message telling him he got it.

Cheers.
 
Try this...
Lua:
local config = 
{
    promoLevel = 1,
    needLevel = 20,
    needPremium = "yes"
}

function onAdvance(cid, skill, oldlevel, newlevel)
    if (skill == SKILL__LEVEL) and (newlevel >= config.needLevel and getPlayerPromotionLevel(cid) < config.promoLevel) then
        if(getBooleanFromString(config.needPremium) == TRUE and isPremium(cid) == TRUE) or (getBooleanFromString(config.needPremium) == FALSE) then 
            setPlayerPromotionLevel(cid, config.promoLevel)
            doPlayerSendTextMessage(cid, 22, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
        end
    end
    return TRUE
end
 
Try this...
Lua:
local config = 
{
    promoLevel = 1,
    needLevel = 20,
    needPremium = "yes"
}

function onAdvance(cid, skill, oldlevel, newlevel)
    if (skill == SKILL__LEVEL) and (newlevel >= config.needLevel and getPlayerPromotionLevel(cid) < config.promoLevel) then
        if(getBooleanFromString(config.needPremium) == TRUE and isPremium(cid) == TRUE) or (getBooleanFromString(config.needPremium) == FALSE) then 
            setPlayerPromotionLevel(cid, config.promoLevel)
            doPlayerSendTextMessage(cid, 22, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
        end
    end
    return TRUE
end

Yeah script work, dont give nothinr error in console, but dont add a promotion, understand?
check my npc, player complete sucessfull but npc dont give promotion to he ;/

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid)                        end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                end
function onThink()                                      npcHandler:onThink()                                    end
function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	--[[
	REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
	]]--
	local storage = 6681
	if(msgcontains(msg, 'quest') or msgcontains(msg, 'crystal')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("Hey, Eu preciso da minha {Medal of Honor}, você trouxe ela para mim? se sim, diga {Quest} novamente!", cid)
			setPlayerStorageValue(cid, storage, 1)
			setPlayerStorageValue(cid, 11214, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			npcHandler:say("Yessssss! você está com ela ? {YES}/{NO}?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("Algo me diz que você já completou esta {Quest}.", cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveItem(cid, 5785, 1) == TRUE) then
			npcHandler:say("Obrigadaaaa! A sim, agora você tem a 2° JOB, e ja pode pegar seu prêmio na minha salinhaaa! {*-*} Obrigada, Obrigada! ", cid)
                        setPlayerPromotionLevel(cid, 1)
			setPlayerStorageValue(cid, storage, 2)
		    setPlayerStorageValue(cid, 11458, 1)
			talkState[talkUser] = 0
		else
			npcHandler:say("Não você não está com minha {Medalha} !.", cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

the error is on "setPlayerPromotionLevel(cid, 1)", any suggestion?
 
Lol i found the poblem,

in config.lua have:

premiumForPromotion = "yes"

just put no, and work :) ty for help dark~~.
 
Try this, a litle bit longer, but it should work.
Lua:
local config = {
    promoLevel = 1,      -- promotion level : )
    needLevel = 20,      -- level to get promotion 
    needPremium = "yes"  -- need premium (YES/NO)? :D
}

function onAdvance(cid, skill, oldlevel, newlevel)
	local promoLevel = nil
	if (skill == 0) and (newlevel >= config.needLevel) and getPlayerPromotionLevel(cid) < config.promoLevel then
		if config.needPremium == "yes" then
			if isPremium(cid) == TRUE then
				promote = TRUE
			end
		elseif config.needPremium == "no" then
			promote = TRUE
		else
			error('AUtoPromote: You have to enter "yes" or "no"')
		end
	end
	if promote ~= nil then
		setPlayerPromotionLevel(cid, config.promoLevel)
		doPlayerSendTextMessage(cid, 22, "You have been promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
        end
	return TRUE
end

Regards,
Shawak
 
or

in data/creaturescripts/scripts/login.lua

under
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)

paste
doPlayerSetPromotionLevel(cid, 1)
 
Back
Top