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

can you help me fix this NPC

pirulitopiu

New Member
Joined
Sep 22, 2017
Messages
3
Reaction score
0
is giving this error
Lua:
[09/04/2018 08:36:01] [Error - CreatureScript Interface]
[09/04/2018 08:36:01] data/creaturescripts/scripts/player/statsChange.lua:eek:nStatsChange
[09/04/2018 08:36:01] Description:
[09/04/2018 08:36:01] data/creaturescripts/scripts/player/statsChange.lua:112: attempt to index a number value
[09/04/2018 08:36:01] stack traceback:
[09/04/2018 08:36:01]    data/creaturescripts/scripts/player/statsChange.lua:112: in function <data/creaturescripts/scripts/player/statsChange.lua:6>
[09/04/2018 08:41:44] > Broadcasted message: "Para upar mais rapido e so ir dando Cath nos pokemons , mas nao funciona 2 vezes no mesmo pokemon".



<?xml version="1.0" encoding="UTF-8"?>
<npc name="Rulfs" script="Rulfs.lua" walkinterval="2000" floorchange="0">
   <health now="100" max="100"/>
   <look type="594" head="17" body="54" legs="114" feet="0" addons="2"/>
</npc>





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

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
function onPlayerEndTrade(cid)               npcHandler:eek:nPlayerEndTrade(cid)           end
function onPlayerCloseChannel(cid)           npcHandler:eek:nPlayerCloseChannel(cid)       end

local nome = "Rulfs" -- nome do monstro que vai parecer


local function greetCallback(cid)
   local msg = 'Olá '.. getCreatureName(cid) ..", vem me desafiar a um duelo?"
   npcHandler:say(msg,cid)
    npcHandler:addFocus(cid)
   return false
end
function creatureSayCallback(cid, type, msg)
   if string.lower(msg) == 'bye' or string.lower(msg) == 'xau' then
       npcHandler:resetNpc(cid)
       return false
   end
    if(not npcHandler:isFocused(cid)) then
        return false
    end
   if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
       local pos = getCreaturePosition(getNpcId())
       selfSay('Então venha.',cid)
       doCreatureSay(getNpcId(), "MuHuashAUhashSHUuSA", TALKTYPE_MONSTER_YELL)
       npcHandler:resetNpc(cid)
       doRemoveCreature(getNpcId())
       doCreateMonster(nome, pos)
   end
   if (msgcontains(msg, 'nao') or msgcontains(msg, 'no') or msgcontains(msg, 'não')) then
       selfSay('Então tchau.', cid)
       npcHandler:resetNpc(cid)
       return false
   end
      
   return true
end

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

and his monster
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Rulfs" nameDescription="a rulfs" race="blood" experience="900" speed="220" manacost="0">
   <health now="1000" max="1000"/>
   <look type="569" head="17" body="54" legs="114" feet="0" addons="2" corpse="6080"/>
   <targetchange interval="5000" chance="8"/>
   <strategy attack="100" defense="0"/>
   <flags>
       <flag summonable="0"/>
       <flag attackable="1"/>
       <flag hostile="1"/>
       <flag illusionable="0"/>
       <flag convinceable="0"/>
       <flag pushable="0"/>
       <flag canpushitems="1"/>
       <flag canpushcreatures="1"/>
       <flag targetdistance="1"/>
       <flag staticattack="90"/>
       <flag runonhealth="500"/>
   </flags>
   <attacks>
       <attack name="melee" interval="2000" skill="30" attack="50" poison="150"/>
       <attack name="speed" interval="1000" chance="10" range="7" speedchange="-600" duration="20000">
           <attribute key="areaEffect" value="redshimmer"/>
       </attack>
       <attack name="lifedrain" interval="1000" chance="40" radius="4" target="0" min="-120" max="-250">
           <attribute key="areaEffect" value="rednote"/>
       </attack>
   </attacks>
   <defenses armor="15" defense="20">
       <defense name="healing" interval="1000" chance="25" min="113" max="187">
           <attribute key="areaEffect" value="blueshimmer"/>
       </defense>
   </defenses>
   <elements>
       <element firePercent="100"/>
       <element deathPercent="100"/>
       <element earthPercent="100"/>
       <element holyPercent="-20"/>
   </elements>
   <immunities>
       <immunity lifedrain="1"/>
       <immunity paralyze="1"/>
       <immunity invisible="1"/>
   </immunities>
   <voices interval="5000" chance="10">
       <voice sentence="HAHAHAHAHA"/>

   </voices>
   <loot>
       <item id="2148" countmax="60" chance="11250"/><!-- gold coin -->
       <item id="2148" countmax="40" chance="11250"/><!-- gold coin -->
       <item id="2144" chance="2000"/><!-- black pearl -->
       <item id="2656" chance="650"/><!-- blue robe -->
       <item id="2047" chance="70000"/><!-- candle stick -->
       <item id="2237" chance="19000"/><!-- dirty cape -->
       <item id="2177" chance="50"/><!-- life crystal -->
       <item id="2071" chance="1333"/><!-- lyre -->
       <item id="2560" chance="7250"/><!-- mirror -->
       <item id="2411" chance="1600"/><!-- poison dagger -->
       <item id="2655" chance="800"/><!-- red robe -->
       <item id="2214" chance="860"/><!-- ring of healing -->
       <item id="2170" chance="8300"/><!-- silver amulet -->
       <item id="2134" chance="1750"/><!-- silver brooch -->
       <item id="2657" chance="60000"/><!-- simple dress -->
       <item id="2197" chance="1100"/><!-- stone skin amulet -->
       <item id="7589" chance="650"/><!-- strong mana potion -->
       <item id="2175" chance="900"/><!-- spellbook -->
       <item id="2143" chance="410"/><!-- white pearl -->
       <item id="7884" chance="240"/><!-- terra mantle -->
       <item id="2121" chance="410"/><!-- wedding ring -->
       <item id="2124" chance="100"/><!-- crystal ring -->
   </loot>
</monster>

Code:
[09/04/2018 08:36:01] [Error - CreatureScript Interface]
[09/04/2018 08:36:01] data/creaturescripts/scripts/player/statsChange.lua:eek:nStatsChange
[09/04/2018 08:36:01] Description:
[09/04/2018 08:36:01] data/creaturescripts/scripts/player/statsChange.lua:112: attempt to index a number value
[09/04/2018 08:36:01] stack traceback:
[09/04/2018 08:36:01]    data/creaturescripts/scripts/player/statsChange.lua:112: in function <data/creaturescripts/scripts/player/statsChange.lua:6>
 
Last edited by a moderator:
I'm really dumb in this area I do more maper and sprites spi well little dude for this already I tried to change some things more without his if I send to you you try to help me there

Lua:
local damages = {GROUNDDAMAGE, ELECTRICDAMAGE, ROCKDAMAGE, FLYDAMAGE, BUGDAMAGE, FIGHTINGDAMAGE, DRAGONDAMAGE, POISONDAMAGE, DARKDAMAGE, STEELDAMAGE}
local fixdmgs = {PSYCHICDAMAGE, COMBAT_PHYSICALDAMAGE, GRASSDAMAGE, FIREDAMAGE, WATERDAMAGE, ICEDAMAGE, NORMALDAMAGE, GHOSTDAMAGE}
local ignored = {POISONEDDAMAGE, BURNEDDAMAGE}                --alterado v1.6
local cannotkill = {BURNEDDAMAGE, POISONEDDAMAGE}

function onStatsChange(cid, attacker, type, combat, value)
if isWatchingTv(cid) then return false end -- TV Block
--------------------- healarea ---------------------
if type == STATSCHANGE_HEALTHGAIN then
    if cid == attacker then
    return true
    end
    if isSummon(cid) and isSummon(attacker) and canAttackOther(cid, attacker) == "Cant" then
    return false
    end
    if isWild(cid) and isWild(attacker) then -- monstros se curarem
    return true
    end
return true
end
--------------------- healarea ---------------------
if isSleeping(attacker) then return false end
if isPlayer(cid) and isSummon(attacker) and canAttackOther(cid, attacker) == "Cant" then return false end
if getPlayerStorageValue(cid, 9658783) == 1 then return false end
if combat == FLYSYSTEMDAMAGE then return false end
if isPlayer(cid) and getCreatureOutfit(cid).lookType == 814 then return false end -- TV
if (isPlayer(cid) and #getCreatureSummons(cid) >= 1 and not getTileInfo(getThingPos(getCreatureSummons(cid)[1])).protection) or isPlayer(attacker) then return false end -- seguranca do player nao atacar
if isGod(cid)  then return false end -- god nao morrer o_O
if isWild(cid) and isWild(attacker) then return false end -- monstro nao atacar monstro, mas deixar pokemons do shared team baterem
if getTileInfo(getThingPos(cid)).protection then return false end
-- duel system e outros
if isSummon(cid) and isSummon(attacker) then
    local p1, p2 = getCreatureMaster(cid), getCreatureMaster(attacker)
    if not CanAttackerInDuel(p1, p2) then
       return false
    end
end
if isSummon(attacker) and isPlayer(cid) then
    return false -- quandotiver pvp colocar storage do pvp aqui
end

if not (isCreature(attacker)) then return true end
local raceCombat = typeTable[getElementByCombat(combat)]
local spellNameFromAttacker = getPlayerStorageValue(attacker, 21102)

    -- player morte e ataques
    if isPlayer(cid) and (#getCreatureSummons(cid) <= 0 or #getCreatureSummons(cid) >= 1 and getTileInfo(getThingPos(getCreatureSummons(cid)[1])).protection) then
 
        local color = 180
        if (combat == 128 or combat == 1) and spellNameFromAttacker == -1  then
            value = -(getOffense(attacker) * 100)
        else
            if not typeTable[getMoveType(getCreatureName(attacker), spellNameFromAttacker)] then
                color = 180
            else
                color = typeTable[getMoveType(getCreatureName(attacker), spellNameFromAttacker)].color or 180
            end
        end


        if value >= getCreatureHealth(cid) then
            value = getCreatureHealth(cid)
        end
     
        value = math.ceil(value)
 
       if (value*-1) >= getCreatureHealth(cid) then
          doKillPlayer(cid, attacker, (value*-1))
          return false
       end
       doSendAnimatedText(getThingPosWithDebug(cid), (value * -1), color)
       doCreatureAddHealth(cid, value)
       setPlayerStorageValue(attacker, 21102, -1) -- reseta a spellName do pokemon atacante
       return false
    end
    -- player morte e ataques


if not isPlayer(cid) then
-- valores do atacante


    if isPokePassive(cid) and isSummon(attacker) then
       doSetPokemonAgressiveToPlayer(cid, getCreatureMaster(attacker))
    end
 
    local myName = doCorrectString(getCreatureName(cid))
    if isInArray(specialabilities["evasion"], myName) and isSummon(cid) then
       local target = cid
       if getCreatureTarget(getCreatureMaster(cid)) == attacker then
           if math.random(1, 100) <= passivesChances["Evasion"][myName] then                                                                                  
              if isCreature(attacker) then  --alterado v1.6
                doSendMagicEffect(getThingPosWithDebug(target), 211)
                doSendAnimatedText(getThingPosWithDebug(target), "TOO BAD", 215)                              
                doTeleportThing(target, getClosestFreeTile(target, getThingPosWithDebug(attacker)), false)
                doSendMagicEffect(getThingPosWithDebug(target), 211)
                doFaceCreature(target, getThingPosWithDebug(attacker))
                return false
              end
            end
        end
    end

    ---- cor do dano
 
        --[[if (combat == 128 or combat == 1) and spellNameFromAttacker == -1  then
         
        else
            raceCombat = typeTable[getMoveType(getCreatureName(attacker), spellNameFromAttacker)]
        end]] -- alterado
     
        raceCombat = typeTable[getPokemonType(attacker).type1]
 
    ---- cor do dano
    local critical, criticalValue = false, 0
    local returnDamage = false

    ------------- Helds
    if isSummon(cid) then
        local heldx = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "xHeldItem")
        if heldx then
        local heldName, heldTier = string.explode(heldx, "|")[1], string.explode(heldx, "|")[2]
     
              if heldName == "X-Block" and isSummon(cid) then          -- bloquear alguns ataques
                local chance = heldBlockChance[tonumber(heldTier)]
                if (math.random(1, 100) <= chance) then
                    doSendAnimatedText(getThingPos(cid), "BLOCKED", 215)
                end
              end
           
              if heldName == "X-Return" and isSummon(cid) then          -- bloquear alguns ataques
                local chance = heldReturn[tonumber(heldTier)]
                if (math.random(1, 100) <= chance) then
                    returnDamage = true
                    returnDamageValue = heldReturn[tonumber(heldTier)]
                end
              end
           
        end
    end
 
    if isSummon(attacker) then
        local heldx = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "xHeldItem")
        if heldx then
        local heldName, heldTier = string.explode(heldx, "|")[1], string.explode(heldx, "|")[2]
     
              if heldName == "X-Critical" then -- dar critico nos ataques
                local chance = heldCriticalChance[tonumber(heldTier)]
                if (math.random(1, 100) <= chance) then
                    critical = true
                    criticalValue = math.random(50, 100)
                end
              end
           
        end
    end
    ------------- Helds
 
    if isReflect(attacker) then
        local valueReflected = getPlayerStorageValue(attacker, 21105)
        if valueReflected > 0 then
           removeReflect(attacker)
           value = valueReflected
           doCreatureAddHealth(cid, -math.floor(value))
           doSendAnimatedText(getThingPos(cid), (value == 0 and "" or value), COLOR_GRASS)
           if isSummon(cid) then doSendLifePokeToOTC(getCreatureMaster(cid)) end
            if value >= getCreatureHealth(cid) then
                if isSummon(cid) then
                    if isInDuel(getCreatureMaster(cid)) then
                       doRemoveCountPokemon(getCreatureMaster(cid))
                    end
                end
            doKillWildPoke(attacker, cid)
            return false
            end
           return false
        end
    end
 
    ------------------------------------POTIONS-------------------------------------------
        if isSummon(cid) then
           if getPlayerStorageValue(cid, 173) >= 1 then
            setPlayerStorageValue(cid, 173, -1)  --alterado v1.6
            doSendAnimatedText(getThingPos(cid), "LOST HEAL", 144)
           end
        end
     
    local boost_def, boost_attk = (0.7 * getPokemonBoost(cid)) / 100, (0.5 * getPokemonBoost(attacker)) / 100
 
    if(combat == 128 or combat == 1) and spellNameFromAttacker == -1 then -- ataque basico
       doSendMagicEffect(getThingPos(cid), 3)
       value = getEffectvineCombat(cid, attacker, value)
        if value == 0 then
           return false
        else
           value = value * getOffense(attacker) -- buff ataque system
           local name = doCorrectString(getCreatureName(attacker))
           if pokes[name] and pokes[name].level <= 5 and value ~= 0 then
              value = -math.random(pokes[name].offense, pokes[name].offense+5)
           end
        end
    else -- magia
       value = getEffectvineSpell(attacker, spellNameFromAttacker, value, cid) -- checagem de efetividades de magia
       if value == 0 then
           return false
        else
           value = value * (1 + getSpecialAttack(attacker) / 100)
        end
    end
 
        if spellNameFromAttacker ~= -1 and value == 0 then value = -doForceDanoSpeel(attacker, spellNameFromAttacker) end
        if value == 0 then value = -getEffectvineCombat(cid, attacker, getOffense(attacker)) end -- rever isto.. colocar dano base do xml
 
        value = value - (value * (getDefense(cid) / 100)) -- buff deff system, defendendo por %
     
        -------- boost system
        value = (value) + (boost_def * (value * -1))
        value = (value - getMasterLevel(attacker)) - (boost_attk * (value * -1))
        -------- boost system
     
        value = math.ceil(value * -1)
        if value >= getCreatureHealth(cid) then value = getCreatureHealth(cid) end
     
        if value < 0 then
           value = value * -1
        end
     
 
        -------- xp por dano
        if isSummon(attacker) and not isSummon(cid) then
            addPlayerDano(cid, getCreatureMaster(attacker), value)
        end
        -------- xp por dano
     
        if critical then -- X-Critical system
            value = value * 2 + criticalValue
            doSendAnimatedText(getThingPos(cid), (value == 0 and "" or value) .. "K", COLOR_BURN)
        else
            doSendAnimatedText(getThingPos(cid), (value == 0 and "" or value), raceCombat.color)
        end
     
        if returnDamage then
            local valueToReturn = math.ceil(value * (returnDamageValue / 100))
            if valueToReturn > getCreatureHealth(attacker) then
                valueToReturn = getCreatureHealth(attacker) -1
            end
         
            if valueToReturn > 1 then
                value = value - valueToReturn
                doSendAnimatedText(getThingPos(attacker), (valueToReturn == 0 and "" or valueToReturn), 31)
                doSendMagicEffect(getThingPos(attacker), 3)
                doCreatureAddHealth(attacker, -valueToReturn)
            end
        end
     
        local spellName = getPlayerStorageValue(attacker, 21102)
        setPlayerStorageValue(attacker, 21102, -1) -- reseta a spellName do pokemon atacante
     
        if(isReflect(cid))then -- reflect system igual GBA
           if spellName ~= -1 then
               if not isInArray({"Team Claw", "Team Slice"}, spellName) then
                  doSendMagicEffect(getThingPosWithDebug(cid), 135)
                  doSendAnimatedText(getThingPosWithDebug(cid), "REFLECT", COLOR_GRASS)
                  addEvent(docastspell, 100, cid, spellName)
                  if getCreatureName(cid) == "Wobbuffet" then
                    doRemoveCondition(cid, CONDITION_OUTFIT)
                  end
                  setPlayerStorageValue(cid, 21099, -1)                    --alterado v1.6
                  setPlayerStorageValue(cid, 21100, 1)
                  setPlayerStorageValue(cid, 21101, attacker)
                  setPlayerStorageValue(cid, 21103, getTableMove(attacker, spellName).f)
                  setPlayerStorageValue(cid, 21104, getCreatureOutfit(attacker).lookType)
                  setPlayerStorageValue(cid, 21105, value)
                  if spellName == "Rollout" then
                    doRolloutReflected(cid, doCorrectString(getCreatureName(attacker)))
                  end
                  return false
               end
            end
        end
     
        if getCreatureName(cid) == "Kangaskhan" and math.random(1, 100) < 25 and isMega(cid) then
           docastspell(cid, "Groundshock", 0, 0)
        end
         
    if value >= getCreatureHealth(cid) then
        if isSummon(cid) then
            if isInArray({"Aggron", "Sudowoodo", "Mega Aggron"}, getCreatureName(cid)) then
               doCreatureAddHealth(cid, -(getCreatureHealth(cid)-1))
               docastspell(cid, "Sturdy", 0, 0)
               if isSummon(cid) then doSendLifePokeToOTC(getCreatureMaster(cid)) end
               return false
            end
        end
        doKillWildPoke(attacker, cid)
        return false
    end
        --------------Passiva Lifesteal Clobat------------
          if isInArray({"crobat", "shiny crobat"}, getCreatureName(attacker):lower())and (combat == 128 or combat == 1) and spellNameFromAttacker == -1 then                
            doCreatureAddHealth(attacker, math.floor(value))
            doSendAnimatedText(getThingPos(attacker), "+ "..math.floor(value), 30)
          end
        --------------------------------------------
    doCreatureAddHealth(cid, -value)
    doCastPassive(cid)
 
    if not isSummon(cid) and not isMega(cid) then -- virar mega
       checkChenceToMega(cid)
    end
 
    if isSummon(cid) then
        -- otclient life
        doSendLifePokeToOTC(getCreatureMaster(cid))
        -- otclient life
    end
end

    return false
end

function getMasterLevel(cid)
    if isSummon(cid) then
       return getPlayerLevel(getCreatureMaster(cid))
    end
    return 0
end
 
Last edited by a moderator:
Code:
else
raceCombat = typeTable[getMoveType(getCreatureName(attacker), spellNameFromAttacker)]
end]] -- alterado

raceCombat = typeTable[getPokemonType(attacker).type1]

I think it's because of this: --> typeTable[getPokemonType(attacker).type1] <--
try to leave it as it was by default
 
Back
Top