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

Custom Npc

prav

New Member
Joined
Aug 6, 2014
Messages
61
Reaction score
0
Hey guys im currently trying to make two npcs one that will give you hell promotion and another that will give you heaven promotion however it wont allow me to chose what one i want no matter what npc i talk to it keeps giving me the hell promotion does anyone maybe have a script that allows me to get the correct promotion from the correct npc? Thanks in advance for helping.( Rep++)
 
Npc script
XML:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local vocations =
{
    --[Master sorc] = {Heaven sorc}
    [5] = {13},
    --[Elder Druid] = {Heaven druid}
    [6] = {14},
    --[Royal paladin] = {Heaven paladin}
    [7] = {15},
    --[Elite knight] = {Heaven knight}
    [8] = {16},
}

function onCreatureAppear(cid)           npcHandler:eek:nCreatureAppear(cid)           end
function onCreatureDisappear(cid)       npcHandler:eek:nCreatureDisappear(cid)           end
function onCreatureSay(cid, type, msg)       npcHandler:eek:nCreatureSay(cid, type, msg)       end
function onThink()               npcHandler:eek:nThink()                   end

local node1 = keywordHandler:addKeyword({'Heaven promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to join the league of Gods?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 0, level = 20, promotion = 2, text = 'Welcome to the league of gods my angelic disciple.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Looks like you are ready to join us in our cause to fight evil come back when you grow some balls.', reset = true})


npcHandler:addModule(FocusModule:new())
]

and Vocations.xml

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local vocations =
{
    --[Master sorc] = {Heaven sorc}
    [5] = {13},
    --[Elder Druid] = {Heaven druid}
    [6] = {14},
    --[Royal paladin] = {Heaven paladin}
    [7] = {15},
    --[Elite knight] = {Heaven knight}
    [8] = {16},
}

function onCreatureAppear(cid)           npcHandler:eek:nCreatureAppear(cid)           end
function onCreatureDisappear(cid)       npcHandler:eek:nCreatureDisappear(cid)           end
function onCreatureSay(cid, type, msg)       npcHandler:eek:nCreatureSay(cid, type, msg)       end
function onThink()               npcHandler:eek:nThink()                   end

local node1 = keywordHandler:addKeyword({'Heaven promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to join the league of Gods?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 0, level = 20, promotion = 2, text = 'Welcome to the league of gods my angelic disciple.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Looks like you are ready to join us in our cause to fight evil come back when you grow some balls.', reset = true})


npcHandler:addModule(FocusModule:new())]
 
Last edited:
Sorry and here is my Vocation.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
   <vocation id="0" name="No Vocation" description="No Vocation" needpremium="0" gaincap="1" gainhp="1" gainmana="1" gainhpticks="1" gainhpamount="1" gainmanaticks="1" gainmanaamount="1" manamultiplier="1" attackspeed="1" soulmax="100" gainsoulticks="120" fromvoc="0">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.0" club="1.0" sword="1.0" axe="1.0" distance="1.0" shielding="1.0" fishing="1.0" experience="1.0"/>
   </vocation>
   <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="1" gainmana="3" gainhpticks="6" gainhpamount="25" gainmanaticks="3" gainmanaamount="35" manamultiplier="1.1" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="1" gainmana="3" gainhpticks="6" gainhpamount="25" gainmanaticks="3" gainmanaamount="35" manamultiplier="1.1" attackspeed="900" soulmax="100" gainsoulticks="120" fromvoc="2">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="2" gainmana="2" gainhpticks="4" gainhpamount="30" gainmanaticks="4" gainmanaamount="25" manamultiplier="1.4" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="3">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="3" gainmana="1" gainhpticks="3" gainhpamount="45" gainmanaticks="6" gainmanaamount="15" manamultiplier="3.0" attackspeed="7000" soulmax="100" gainsoulticks="120" fromvoc="4">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="1" gainmana="3" gainhpticks="4" gainhpamount="60" gainmanaticks="2" gainmanaamount="120" manamultiplier="1.1" attackspeed="400" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="6" name="Elder Druid" description="an elder druid" needpremium="1" gaincap="10" gainhp="1" gainmana="3" gainhpticks="4" gainhpamount="60" gainmanaticks="2" gainmanaamount="120" manamultiplier="1.1" attackspeed="400" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="1" gaincap="20" gainhp="2" gainmana="2" gainhpticks="3" gainhpamount="75" gainmanaticks="3" gainmanaamount="65" manamultiplier="1.4" attackspeed="500" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
   </vocation>
   <vocation id="8" name="Elite Knight" description="an elite knight" needpremium="1" gaincap="25" gainhp="2" gainmana="1" gainhpticks="3" gainhpamount="150" gainmanaticks="4" gainmanaamount="40" manamultiplier="3.0" attackspeed="500" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
       <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
       <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
   </vocation>
        <vocation id="9" name="Hell Sorcerer" description="an demonic sorcerer" needpremium="1" gaincap="10" gainhp="1" gainmana="3" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="10" name="Hell Druid" description="an demonic druid" needpremium="1" gaincap="10" gainhp="1" gainmana="3" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="11" name="Hell Paladin" description="an demonic paladin" needpremium="1" gaincap="20" gainhp="2" gainmana="2" gainhpticks="3" gainhpamount="10" gainmanaticks="3" gainmanaamount="10" manamultiplier="1.4" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="12" name="Hell Knight" description="an demonic knight" needpremium="1" gaincap="50" gainhp="3" gainmana="1" gainhpticks="8" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="3.0" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.0" sword="1.0" axe="1.0" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
   </vocation>
        <vocation id="13" name="Heaven Sorcerer" description="an angelic sorcerer" needpremium="1" gaincap="10" gainhp="1" gainmana="3" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="14" name="Heaven Druid" description="an angelic druid" needpremium="1" gaincap="10" gainhp="1" gainmana="3" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="15" name="Heaven Paladin" description="an angelic paladin" needpremium="1" gaincap="20" gainhp="2" gainmana="2" gainhpticks="3" gainhpamount="10" gainmanaticks="3" gainmanaamount="10" manamultiplier="1.4" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="16" name="Heaven Knight" description="an angelic knight" needpremium="1" gaincap="50" gainhp="3" gainmana="1" gainhpticks="8" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="3.0" attackspeed="50" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.0" sword="1.0" axe="1.0" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
</vocations>

Bump
 
Last edited by a moderator:
I beleive you are doing this incorrectly.

For the players it will look like they are getting promoted, but for you, you'll know it's not technically a promotion.

What you'll want to do is set their promotional state back to default, and then change the characters vocation to hell/heaven.

In vocations.xml, you'll want to set "fromvoc" to the same number as "vocation id".


-- alternatively..

You could make heavens promotion like this.
Lua:
Hi -> Hell | elder druid -> hellish druid --(promote x1 in script)
Hi -> Heaven | elder druid -> hellish druid -> heavenly druid --(promote x2 in script)
 
But do i have to make it so that they must go from hell ---> heaven or is there not a way to make two npcs one which gives them one promotion and the other which gives the other promotion?
 
But do i have to make it so that they must go from hell ---> heaven or is there not a way to make two npcs one which gives them one promotion and the other which gives the other promotion?
The promotion system is linear. You cannot make it separate into two paths.

Hence your two options..
Promote once for hell, twice for heaven. (To clarify; the player is only asking for the promotion, but your script promotes them twice.)
or
Remove players promotions, and change their vocation.

Both ways appear the same to a player. Yay I got promoted.
But we as developers know whats truely going on. ;)
 
Alright sweet thanks bro but how would i script the npc if i was to do it that way so lets say if they say hell it promotes them 1s and if they say heaven it promote them twice if thats possible?
 
I'd personally suggest scripting the npc to promote the player using lua functions instead of using the npc nodes.

I always start with a base npc, and starting building from there.

for example, I'd put after this line
Code:
elseif msgcontains(msg, "name") then
something like this...? (I haven't used the promote command before, so idk how it works 'exactly.')
Lua:
elseif msgcontains(msg, "hell promotion") then
   if getPlayerPromotionLevel(cid) == 1 then
       selfSay("Would you like to gain the hell promotion? There is no turning back from this decision.", cid)
       talkState[talkUser] = 1
   elseif getPlayerPromotionLevel(cid) > 1 then
       selfSay("You have already been promoted previously.", cid)
       talkState[talkUser] = 0
   else
       selfSay("You must gain your first promotion before you can descend to hell.", cid)
       talkState[talkUser] = 0
   end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
   doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
   selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
   talkState[talkUser] = 0
elseif talkState[talkUser] == 1 then
   selfSay("Another time then.", cid)
   talkState[talkUser] = 0
 
elseif msgcontains(msg, "heaven promotion") then
   if getPlayerPromotionLevel(cid) == 1 then
       selfSay("Would you like to gain the heaven promotion? There is no turning back from this decision.", cid)
       talkState[talkUser] = 1
   elseif getPlayerPromotionLevel(cid) > 1 then
       selfSay("You have already been promoted previously.", cid)
       talkState[talkUser] = 0
   else
       selfSay("You must gain your first promotion before you can ascend to heaven.", cid)
       talkState[talkUser] = 0
   end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
   doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 2)
   selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
   talkState[talkUser] = 0
elseif talkState[talkUser] == 2 then
   selfSay("Another time then.", cid)
   talkState[talkUser] = 0

Hopefully that works for you.

If not, post any errors / things you've tried.

Xikini
 
Last edited:
Was gunna try it today but i aint had the chance will let you know tomorrow.

When i tryed loading it it said this i must have done something wrong lol here is my error and the script
[3/7/2017 11:23:22] [Error - LuaInterface::loadFile] data/npc/scripts/hdpromotion.lua:32: '=' expected near '==' [3/7/2017 11:23:22] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/hdpromotion.lua [3/7/2017 11:23:22] data/npc/scripts/hdpromotion.lua:32: '=' expected near '=='

XML:
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 greet(cid)   talkState[cid] = 0   return true end
   
function getNpcName()
     return getCreatureName(getNpcId())
end
   
function creatureSayCallback(cid, type, msg)
     if(not npcHandler:isFocused(cid)) then
         return false
     end
     
     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     
     if msgcontains(msg, "help") then
         selfSay("My job is to make you the defender of good or bad please be wise about your decision!", cid)
       
     elseif msgcontains(msg, "name") then
         selfSay("My name is " .. getNpcName() .. ".", cid)
       
     elseif msgcontains(msg, "hell promotion") then
   if getPlayerPromotionLevel(cid) == 1 then
       selfSay("Would you like to gain the hell promotion? There is no turning back from this decision.", cid)
       talkState[talkUser] == 1
   elseif getPlayerPromotionLevel(cid) > 1 then
       selfSay("You have already been promoted previously.", cid)
       talkState[talkUser] == 0
   else
       selfSay("You must gain your first promotion before you can descend to hell.", cid)
       talkState[talkUser] == 0
   end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
   doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
   selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
   talkState[talkUser] == 0
elseif talkState[talkUser] == 1 then
   selfSay("Another time then.", cid)
   talkState[talkUser] == 0
elseif msgcontains(msg, "heaven promotion") then
   if getPlayerPromotionLevel(cid) == 1 then
       selfSay("Would you like to gain the heaven promotion? There is no turning back from this decision.", cid)
       talkState[talkUser] == 1
   elseif getPlayerPromotionLevel(cid) > 1 then
       selfSay("You have already been promoted previously.", cid)
       talkState[talkUser] == 0
   else
       selfSay("You must gain your first promotion before you can ascend to heaven.", cid)
       talkState[talkUser] == 0
   end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
   doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 2)
   selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
   talkState[talkUser] == 0
elseif talkState[talkUser] == 2 then
   selfSay("Another time then.", cid)
   talkState[talkUser] == 0
   
     end
     return true  
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited by a moderator:
When i tryed loading it it said this i must have done something wrong lol here is my error and the script
[3/7/2017 11:23:22] [Error - LuaInterface::loadFile] data/npc/scripts/hdpromotion.lua:32: '=' expected near '==' [3/7/2017 11:23:22] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/hdpromotion.lua [3/7/2017 11:23:22] data/npc/scripts/hdpromotion.lua:32: '=' expected near '=='

XML:
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 greet(cid)   talkState[cid] = 0   return true end
 
function getNpcName()
     return getCreatureName(getNpcId())
end
 
function creatureSayCallback(cid, type, msg)
     if(not npcHandler:isFocused(cid)) then
         return false
     end
  
     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  
     if msgcontains(msg, "help") then
         selfSay("My job is to make you the defender of good or bad please be wise about your decision!", cid)
    
     elseif msgcontains(msg, "name") then
         selfSay("My name is " .. getNpcName() .. ".", cid)
    
     elseif msgcontains(msg, "hell promotion") then
   if getPlayerPromotionLevel(cid) == 1 then
       selfSay("Would you like to gain the hell promotion? There is no turning back from this decision.", cid)
       talkState[talkUser] = 1
   elseif getPlayerPromotionLevel(cid) > 1 then
       selfSay("You have already been promoted previously.", cid)
       talkState[talkUser] = 0
   else
       selfSay("You must gain your first promotion before you can descend to hell.", cid)
       talkState[talkUser] = 0
   end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
   doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
   selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
   talkState[talkUser] = 0
elseif talkState[talkUser] == 1 then
   selfSay("Another time then.", cid)
   talkState[talkUser] = 0
elseif msgcontains(msg, "heaven promotion") then
   if getPlayerPromotionLevel(cid) == 1 then
       selfSay("Would you like to gain the heaven promotion? There is no turning back from this decision.", cid)
       talkState[talkUser] = 1
   elseif getPlayerPromotionLevel(cid) > 1 then
       selfSay("You have already been promoted previously.", cid)
       talkState[talkUser] = 0
   else
       selfSay("You must gain your first promotion before you can ascend to heaven.", cid)
       talkState[talkUser] = 0
   end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
   doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 2)
   selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
   talkState[talkUser] = 0
elseif talkState[talkUser] == 2 then
   selfSay("Another time then.", cid)
   talkState[talkUser] = 0
 
     end
     return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Was my fault.
Lua:
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 greet(cid)   talkState[cid] = 0   return true end

function getNpcName()
    return getCreatureName(getNpcId())
end
  
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, "help") then
        selfSay("My job is to make you the defender of good or bad please be wise about your decision!", cid)
      
    elseif msgcontains(msg, "name") then
        selfSay("My name is " .. getNpcName() .. ".", cid)
      
    elseif msgcontains(msg, "hell promotion") then
        if getPlayerPromotionLevel(cid) == 1 then
            selfSay("Would you like to gain the hell promotion? There is no turning back from this decision.", cid)
            talkState[talkUser] = 1
        elseif getPlayerPromotionLevel(cid) > 1 then
            selfSay("You have already been promoted previously.", cid)
            talkState[talkUser] = 0
        else
            selfSay("You must gain your first promotion before you can descend to hell.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
        selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
        talkState[talkUser] = 0
    elseif talkState[talkUser] == 1 then
        selfSay("Another time then.", cid)
        talkState[talkUser] = 0

    elseif msgcontains(msg, "heaven promotion") then
        if getPlayerPromotionLevel(cid) == 1 then
            selfSay("Would you like to gain the heaven promotion? There is no turning back from this decision.", cid)
            talkState[talkUser] = 1
        elseif getPlayerPromotionLevel(cid) > 1 then
            selfSay("You have already been promoted previously.", cid)
            talkState[talkUser] = 0
        else
            selfSay("You must gain your first promotion before you can ascend to heaven.", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
        doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 2)
        selfSay("Congratulations, you have been promoted to " .. getPlayerVocationName(cid) .. ".", cid)
        talkState[talkUser] = 0
    elseif talkState[talkUser] == 2 then
        selfSay("Another time then.", cid)
        talkState[talkUser] = 0

    end

    return true 
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Im still getting an error using that script pal.
This is the error.

[3/7/2017 13:29:31] [Error - LuaInterface::loadFile] data/npc/scripts/hdpromotion.lua:31: '=' expected near '==' [3/7/2017 13:29:31] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/hdpromotion.lua [3/7/2017 13:29:31] data/npc/scripts/hdpromotion.lua:31: '=' expected near '=='
 
Im still getting an error using that script pal.
This is the error.

[3/7/2017 13:29:31] [Error - LuaInterface::loadFile] data/npc/scripts/hdpromotion.lua:31: '=' expected near '==' [3/7/2017 13:29:31] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/hdpromotion.lua [3/7/2017 13:29:31] data/npc/scripts/hdpromotion.lua:31: '=' expected near '=='
well, here's line 31.
Tell me if you see an "=" sign in it.
Lua:
selfSay("Would you like to gain the hell promotion? There is no turning back from this decision.", cid)
To be clear, I don't see any error's in the code that are popping out at me.
 
Ye im not sure there seems to be nothing wrong ill probly just find a different way to give the promotion to players thanks for all your help though.
 
Ye im not sure there seems to be nothing wrong ill probly just find a different way to give the promotion to players thanks for all your help though.
Well problem is you don't know what to look for, and you always reply like 24 - 36 hours later.
I'm always at work and I have no way to test the code man.

It's a pretty easy script, and the error's you give make no sense for the lines you post with.
But w/e.
 
Last edited:
Back
Top