• 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 please with error in rebirth script!

kaspertje100

Member
Joined
May 8, 2008
Messages
236
Reaction score
7
Okay hi otlanders,

I am using this 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 

        if(msgcontains(msg, 'rebirth')) then 
                selfSay('Are you ready to be reborn?', cid) 
                talkState[talkUser] = 1 

        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
        -------CONFIGS------- 

        local level     =   100
        local cost      =   0 
         
        ------/CONFIGS------- 
        -----LOCALS----- 
        local id = getPlayerGUID(cid) 
        local name = getCreatureName(cid) 
        local vocation = getPlayerVocation(cid) 
        ----/LOCALS----- 

                if getPlayerLevel(cid) >= level then 
                        if doPlayerRemoveMoney(cid,cost) == TRUE then 
                                if vocation == 5 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 500, `manamax` = 500, promotion` = 3 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
                                elseif vocation == 6 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 500, `manamax` = 500, promotion` = 3 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
                                elseif vocation == 7 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 400, `healthmax` = 400, `mana` = 350, `manamax` = 350, promotion` = 3 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
                                elseif vocation == 8 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 500, `healthmax` = 500, `mana` = 250, `manamax` = 250, promotion` = 3 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 

                                else 
                                        selfSay('Please talk with forgotten king and promote first.', cid) 
                                        talkState[talkUser] = 0 
                                end 
                        else 
                                selfSay('You dont have enough money. You need to pay 150m to be rebirthed.', cid) 
                                talkState[talkUser] = 0 
                        end 
                else 
                        selfSay('Only characters of level 100 or higher can be rebirthed.', cid) 
                        talkState[talkUser] = 0 
end 
        elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then 
                selfSay('Okey come back when you are ready.', cid) 
                talkState[talkUser] = 0 
         
                                end 
        return TRUE 
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

and getting this error:
Code:
[08/02/2011 17:06:49] Lua Script Error: [Npc interface] 
[08/02/2011 17:06:49] data/npc/scripts/reset.lua:onCreatureSay
[08/02/2011 17:06:49] data/npc/scripts/reset.lua:61: attempt to index global 'db' (a nil value)
[08/02/2011 17:06:49] stack traceback:
[08/02/2011 17:06:49] 	[C]: in function '__index'
[08/02/2011 17:06:49] 	data/npc/scripts/reset.lua:61: in function 'callback'
[08/02/2011 17:06:49] 	data/npc/lib/npcsystem/npchandler.lua:379: in function 'onCreatureSay'
[08/02/2011 17:06:49] 	data/npc/scripts/reset.lua:15: in function <data/npc/scripts/reset.lua:14>

using tfs 0.210 the newest of tarantulen 8.7

I would be glad if some1 can help me!!
 
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 

        if(msgcontains(msg, 'rebirth') or msgcontains(msg, 'REBIRTH')) then 
                selfSay('Are you ready to be reborn?', cid) 
                talkState[talkUser] = 1 

        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
        -------CONFIGS------- 

        local level = 100
        local cost = 0 
         
        ------/CONFIGS------- 
        -----LOCALS----- 
        local id = getPlayerGUID(cid) 
        local name = getCreatureName(cid) 
        local vocation = getPlayerVocation(cid) 
        ----/LOCALS----- 

                if getPlayerLevel(cid) >= level then 
                        if doPlayerRemoveMoney(cid,cost) == TRUE then 
                                if vocation == 5 then 
                                        doRemoveCreature(cid,true) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 500, `manamax` = 500, `promotion` = 3 WHERE `id` = "..id) 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
                                elseif vocation == 6 then 
                                        doRemoveCreature(cid,true) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 500, `manamax` = 500, `promotion` = 3 WHERE `id` = "..id) 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
                                elseif vocation == 7 then 
                                        doRemoveCreature(cid,true) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 400, `healthmax` = 400, `mana` = 350, `manamax` = 350, `promotion` = 3 WHERE `id` = "..id) 
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
                                elseif vocation == 8 then 
                                        doRemoveCreature(cid,true) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 500, `healthmax` = 500, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` = "..id)
                                        db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 

                                else 
                                        selfSay('Please talk with forgotten king and promote first.', cid) 
                                        talkState[talkUser] = 0 
                                end 
                        else 
                                selfSay('You dont have enough money. You need to pay '..cost..' gps to be rebirthed.', cid) 
                                talkState[talkUser] = 0 
                        end 
                else 
                        selfSay('Only characters of level '..level..' or higher can be rebirthed.', cid) 
                        talkState[talkUser] = 0 
end 
        elseif msgcontains(msg, 'no') and talkState[talkUser] >= 1 then 
                selfSay('Okey come back when you are ready.', cid) 
                talkState[talkUser] = 0 
         
                                end 
        return TRUE 
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
yo thanks for trying to fix my error:)

but when I use urs i get this:


HTML:
[09/02/2011 20:15:53] Lua Script Error: [Npc interface] 
[09/02/2011 20:15:53] data/npc/scripts/reset.lua:onCreatureSay
[09/02/2011 20:15:53] luaDoRemoveCreature(). Creature not found
[09/02/2011 20:15:53] stack traceback:
[09/02/2011 20:15:53] 	[C]: in function 'doRemoveCreature'
[09/02/2011 20:15:53] 	data/npc/scripts/reset.lua:60: in function 'callback'
[09/02/2011 20:15:53] 	data/npc/lib/npcsystem/npchandler.lua:379: in function 'onCreatureSay'
[09/02/2011 20:15:53] 	data/npc/scripts/reset.lua:15: in function <data/npc/scripts/reset.lua:14>

[09/02/2011 20:15:53] Lua Script Error: [Npc interface] 
[09/02/2011 20:15:53] data/npc/scripts/reset.lua:onCreatureSay
[09/02/2011 20:15:53] data/npc/scripts/reset.lua:61: attempt to index global 'db' (a nil value)
[09/02/2011 20:15:53] stack traceback:
[09/02/2011 20:15:53] 	[C]: in function '__index'
[09/02/2011 20:15:53] 	data/npc/scripts/reset.lua:61: in function 'callback'
[09/02/2011 20:15:53] 	data/npc/lib/npcsystem/npchandler.lua:379: in function 'onCreatureSay'
[09/02/2011 20:15:53] 	data/npc/scripts/reset.lua:15: in function <data/npc/scripts/reset.lua:14>
 
[09/02/2011 20:15:53] luaDoRemoveCreature(). Creature not found

not found?...

test:

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 level = 100
        local id = getPlayerGUID(cid) 
        local name = getCreatureName(cid) 
        local vocation = getPlayerVocation(cid) 

if(msgcontains(msg, 'rebirth') or msgcontains(msg, 'REBIRTH')) then 
selfSay('Are you ready to be reborn? {yes} ', cid) 
talkState[talkUser] = 1 
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if getPlayerLevel(cid) >= level then
if vocation == 5 then 
doRemoveCreature(cid) 
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 500, `manamax` = 500, `promotion` = 3 WHERE `id` = "..id) 
db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
elseif vocation == 6 then 
doRemoveCreature(cid) 
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 500, `manamax` = 500, `promotion` = 3 WHERE `id` = "..id) 
db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
elseif vocation == 7 then 
doRemoveCreature(cid) 
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 400, `healthmax` = 400, `mana` = 350, `manamax` = 350, `promotion` = 3 WHERE `id` = "..id) 
db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
elseif vocation == 8 then 
doRemoveCreature(cid) 
db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 500, `healthmax` = 500, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` = "..id)
db.executeQuery("UPDATE `players` SET `name` = '¥"..name.."' WHERE `id` ='"..id.."';") 
else 
selfSay('Please talk with forgotten king and promote first!', cid) 
talkState[talkUser] = 0 
end
else
selfSay('Only characters of level '..level..' or higher can be rebirthed!', cid) 
talkState[talkUser] = 0 
end
elseif msg == "no" and talkState[talkUser] >= 1 then 
selfSay("Then not", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end 
return TRUE 
end 


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 

Similar threads

Back
Top