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

Npc errors

chael

New Member
Joined
Mar 15, 2012
Messages
28
Reaction score
0
many of the npcs I place in RME will not load on the server itself. the few that I can place will not interact with you. if you say hello to them they will not respond and saying key words (trade etc) they do nothing. if you walk away they say their usual line. if you say bye to them the server will crash.
i receive this error in the log for just about every npc upon start up of the server

HTML:
data/npc/scripts/A Ghostly Woman.lua
data/npc/scripts/A Ghostly Woman.lua:11: attempt to index global 'VoiceModule' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/A Ghostly Woman.lua:11: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: A Ghostly Woman.lua
 
many of the npcs I place in RME will not load on the server itself. the few that I can place will not interact with you. if you say hello to them they will not respond and saying key words (trade etc) they do nothing. if you walk away they say their usual line. if you say bye to them the server will crash.
i receive this error in the log for just about every npc upon start up of the server

HTML:
data/npc/scripts/A Ghostly Woman.lua
data/npc/scripts/A Ghostly Woman.lua:11: attempt to index global 'VoiceModule' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/A Ghostly Woman.lua:11: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: A Ghostly Woman.lua

This should help

1. In data\npc\lib\npcsystem create another text file, name it customModules.lua and add the following:
Lua:
-- VoiceModule
VoiceModule = {
   voices = nil,
   voiceCount = 0,
   lastVoice = 0,
   timeout = nil,
   chance = nil,
   npcHandler = nil
}

-- Creates a new instance of VoiceModule
function VoiceModule:new(voices, timeout, chance)
   local obj = {}
   setmetatable(obj, self)
   self.__index = self

   obj.voices = voices
   for i = 1, #obj.voices do
       local voice = obj.voices[i]
       if voice.yell then
           voice.yell = nil
           voice.talktype = TALKTYPE_YELL
       else
           voice.talktype = TALKTYPE_SAY
       end
   end

   obj.voiceCount = #voices
   obj.timeout = timeout or 10
   obj.chance = chance or 25
   return obj
end

function VoiceModule:init(handler)
   return true
end

function VoiceModule:callbackOnThink()
   if self.lastVoice < os.time() then
       self.lastVoice = os.time() + self.timeout
       if math.random(100) < self.chance  then
           local voice = self.voices[math.random(self.voiceCount)]
           Npc():say(voice.text, voice.talktype)
       end
   end
   return true
end

2. In data\npc\lib\npc.lua add this line at the top:
Lua:
dofile('data/npc/lib/npcsystem/customModules.lua')
 
Last edited:
i already had both the file and the code in the npc folder. i replaced it all with the ones you recommended and now the npcs appear on the map :D but now still none of them respond to players other then when you say hi...saying bye no longer crashes the server however
 
i already had both the file and the code in the npc folder. i replaced it all with the ones you recommended and now the npcs appear on the map :D but now still none of them respond to players other then when you say hi...saying bye no longer crashes the server however

Awesome ! :p

Now go to this link and copy everything into your data\npc\lib folder (npc.lua and folder npcsystem with other lua files)

If you still experience issues, post one of your NPCs that doesn't work here (their script)
 
Awesome ! :p

Now go to this link and copy everything into your data\npc\lib folder (npc.lua and folder npcsystem with other lua files)

If you still experience issues, post one of your NPCs that doesn't work here (their script)



When i did that it brought me right back to square one. they all disappeared once more.
 
Back
Top