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

[HELP] Unknown Problem With Npc

Solarium

New Member
Joined
Jul 18, 2009
Messages
30
Reaction score
0
Hello, So i got this script from someone else but there offline so i cant ask them for help so i was hoping someone could help me, so this is my npc script
Code:
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)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
 
local energy = {
new_voc = 9,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
local fire = {
new_voc = 10,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
local ice = {
new_voc = 11,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
if(msgcontains(msg, 'energy wizard') or msgcontains(msg, 'energy')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become an ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become an ' .. getVocationInfo(energy.new_voc).name .. ' for '..energy.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 1
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if energy.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become an ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif energy.need_level == true and getPlayerLevel(cid) < energy.level then
selfSay('You must be at least level '.. energy.level ..' to become an ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif energy.pay == true and doPlayerRemoveMoney(cid, energy.price) == TRUE then
doPlayerSetVocation(cid,energy.new_voc)
selfSay('Congratz, you\'re now a ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..energy.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
elseif(msgcontains(msg, 'fire wizard') or msgcontains(msg, 'fire')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become a ' .. getVocationInfo(fire.new_voc).name .. ' for '..fire.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 2
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if fire.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif fire.need_level == true and getPlayerLevel(cid) < fire.level then
selfSay('You must be at least level '.. fire.level ..' to become a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif fire.pay == true and doPlayerRemoveMoney(cid, fire.price) == TRUE then
doPlayerSetVocation(cid,fire.new_voc)
selfSay('Congratz, you\'re now a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..fire.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
 
elseif(msgcontains(msg, 'ice wizard') or msgcontains(msg, 'ice')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become an ' .. getVocationInfo(ice.new_voc).name .. ' for '..ice.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 3
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
if ice.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif ice.need_level == true and getPlayerLevel(cid) < ice.level then
selfSay('You must be at least level '.. ice.level ..' to become an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif ice.pay == true and doPlayerRemoveMoney(cid, ice.price) == TRUE then
doPlayerSetVocation(cid,ice.new_voc)
selfSay('Congratz, you\'re now an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..ice.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
 
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

and this is my error
Lua Script Error: [Npc interface]
data/npc/scripts/promotion1.lua:eek:nCreatureSay
data/npc/scripts/promotion1.lua:80: attempt to call global 'getVocationInfo' <anil value>
stack traceback:
[C]: in function 'getVocationInfo'
data/npc/scripts/promotion1.lua:80: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
data/npc/scripts/promotion1.lua:8: in function <data/npc/scripts/promotion1.lua:8>

is there anyway this can be fixed? cause i really need this script thank you :)
 
If you're using 0.2, this will not work.
I guess you can replace all of the getVocationInfo with just the name of the vocations.
 
Hello, So i got this script from someone else but there offline so i cant ask them for help so i was hoping someone could help me, so this is my npc script
Code:
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)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
 
local energy = {
new_voc = 9,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
local fire = {
new_voc = 10,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
local ice = {
new_voc = 11,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
if(msgcontains(msg, 'energy wizard') or msgcontains(msg, 'energy')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become an ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become an ' .. getVocationInfo(energy.new_voc).name .. ' for '..energy.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 1
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if energy.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become an ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif energy.need_level == true and getPlayerLevel(cid) < energy.level then
selfSay('You must be at least level '.. energy.level ..' to become an ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif energy.pay == true and doPlayerRemoveMoney(cid, energy.price) == TRUE then
doPlayerSetVocation(cid,energy.new_voc)
selfSay('Congratz, you\'re now a ' .. getVocationInfo(energy.new_voc).name .. '.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..energy.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
elseif(msgcontains(msg, 'fire wizard') or msgcontains(msg, 'fire')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become a ' .. getVocationInfo(fire.new_voc).name .. ' for '..fire.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 2
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if fire.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif fire.need_level == true and getPlayerLevel(cid) < fire.level then
selfSay('You must be at least level '.. fire.level ..' to become a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif fire.pay == true and doPlayerRemoveMoney(cid, fire.price) == TRUE then
doPlayerSetVocation(cid,fire.new_voc)
selfSay('Congratz, you\'re now a ' .. getVocationInfo(fire.new_voc).name .. '.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..fire.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
 
elseif(msgcontains(msg, 'ice wizard') or msgcontains(msg, 'ice')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become an ' .. getVocationInfo(ice.new_voc).name .. ' for '..ice.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 3
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
if ice.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif ice.need_level == true and getPlayerLevel(cid) < ice.level then
selfSay('You must be at least level '.. ice.level ..' to become an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
talkState[talkUser] = 0
 
elseif ice.pay == true and doPlayerRemoveMoney(cid, ice.price) == TRUE then
doPlayerSetVocation(cid,ice.new_voc)
selfSay('Congratz, you\'re now an ' .. getVocationInfo(ice.new_voc).name .. '.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..ice.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
 
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

and this is my error

is there anyway this can be fixed? cause i really need this script thank you :)

I made that script for you, I´m sorry you are getting that error, probably it is because you are using and older server, like evan said...

Use this script and it should work just fine:
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
 
local energy = {
new_voc = 9,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
local fire = {
new_voc = 10,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
local ice = {
new_voc = 11,
need_level = true,
level = 50,
pay = true,
price = 5000,
need_premium = true
}
 
if(msgcontains(msg, 'energy wizard') or msgcontains(msg, 'energy')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become an Energy Wizard.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become an Energy Wizard for '..energy.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 1
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if energy.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become an Energy Wizard.', cid)
talkState[talkUser] = 0
 
elseif energy.need_level == true and getPlayerLevel(cid) < energy.level then
selfSay('You must be at least level '.. energy.level ..' to become an Energy Wizard.', cid)
talkState[talkUser] = 0
 
elseif energy.pay == true and doPlayerRemoveMoney(cid, energy.price) == TRUE then
doPlayerSetVocation(cid,energy.new_voc)
selfSay('Congratz, you\'re now a Energy Wizard.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..energy.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
elseif(msgcontains(msg, 'fire wizard') or msgcontains(msg, 'fire')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become a Fire Wizard.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become a Fire Wizard for '..fire.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 2
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if fire.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become a Fire Wizard.', cid)
talkState[talkUser] = 0
 
elseif fire.need_level == true and getPlayerLevel(cid) < fire.level then
selfSay('You must be at least level '.. fire.level ..' to become a Fire Wizard.', cid)
talkState[talkUser] = 0
 
elseif fire.pay == true and doPlayerRemoveMoney(cid, fire.price) == TRUE then
doPlayerSetVocation(cid,fire.new_voc)
selfSay('Congratz, you\'re now a Fire Wizard.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..fire.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
 
elseif(msgcontains(msg, 'ice wizard') or msgcontains(msg, 'ice')) then
if(getPlayerVocation(cid) == 5) == FALSE then
selfSay('You\'re not a Wizard, therefore you can\'t become an Ice Wizard.', cid)
talkState[talkUser] = 0
 
else
selfSay('Are you sure you want to become an Ice Wizard for '..ice.price..' gold coins? Remind that you can\'t change you choice later.', cid)
talkState[talkUser] = 3
end
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
if ice.need_premium == true and not isPremium(cid) then
selfSay('You must be premium to become an Ice Wizard.', cid)
talkState[talkUser] = 0
 
elseif ice.need_level == true and getPlayerLevel(cid) < ice.level then
selfSay('You must be at least level '.. ice.level ..' to become an Ice Wizard.', cid)
talkState[talkUser] = 0
 
elseif ice.pay == true and doPlayerRemoveMoney(cid, ice.price) == TRUE then
doPlayerSetVocation(cid,ice.new_voc)
selfSay('Congratz, you\'re now an Ice Wizard.', cid)
doSendMagicEffect(getPlayerPosition(cid), 12)
talkState[talkUser] = 0
 
else
selfSay('You don\'t have '..ice.price..' gold coins.', cid)
talkState[talkUser] = 0
end
 
 
 
 
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Hope it helps :D
If you have any problems, just ask....
 
Back
Top