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

Lua Really misterious problem with a creature script

Raiden

Developer
Joined
Sep 16, 2008
Messages
486
Reaction score
32
Location
Venezuela
Hello guys, today i got a strange problem, i have made a simple dragon task, but it simple don't want to work, i already have done another creature script an works fine, i think that this should be fine too, check it out

dragontask.lua
Code:
function onKill(cid, target)

if getPlayerStorageValue(cid, 18001) == 5 then
setPlayerStorageValue(cid, 17012, 19)
end

if getCreatureName(target) == "Dragon" then
if getPlayerStorageValue(cid, 18000) == 1 then
if getPlayerStorageValue(cid, 18001) <= 4 then
setPlayerStorageValue(cid, 18001, getPlayerStorageValue(cid, 18001)+1)
doPlayerSendTextMessage(cid, 24, "You have killed " .. getPlayerStorageValue(cid, 18001) .. " of 5 dragons")
end
end
end
return true
end

creaturescripts.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
   <event type="login" name="PlayerLogin" script="login.lua"/>
   <event type="login" name="FirstItems" script="firstitems.lua"/>
   <event type="death" name="PlayerDeath" script="playerdeath.lua"/>
   <event type="kill" name="dragontask" script="dragontask.lua"/>
   <event type="kill" name="killamalus" script="amalus.lua"/>
</creaturescripts>

login.lua
Code:
function onLogin(cid)
local storage = 5001
local message = [[Welcome to RonWorld!
Here are some commands that you will need:
- !buypremium = 10k for 30 days
- !promotion = 20k for a promotion
- !cd = Check Your cooldown spells
- Protection level = 30
- !help = see this again
Any dude talk in HELP CHANNEL
Enjoy your stay.]]
  if getPlayerStorageValue(cid, storage) == -1 then
   doPlayerPopupFYI(cid, message)
   doPlayerAddSoul(cid, 100)
   doPlayerAddItem(cid, 2120, 1)
   doPlayerAddItem(cid, 2554, 1)
  setPlayerStorageValue(cid, storage, 1)
  end
     
   registerCreatureEvent(cid, "PlayerDeath")
   registerCreatureEvent(cid, "dragontask")
   registerCreatureEvent(cid, "killamalus")
   return TRUE
end

The creature event "killamalus" works perfectly, but when i kill some dragon it simply don't work, and i have all the storages and all that, i already test changing the script to a simple message and it don't show me too (that means that when i kill the dragon the script is never executed)
 
everything looks good, Any errors ?

also tried it like that?

Code:
function onKill(cid, target)
    doBroadcastMessage("Just a test if its executed")

    if getPlayerStorageValue(cid, 18001) == 5 then
        setPlayerStorageValue(cid, 17012, 19)
    end

    if getCreatureName(target) == "Dragon" then
        if getPlayerStorageValue(cid, 18000) == 1 then
            if getPlayerStorageValue(cid, 18001) <= 4 then
                setPlayerStorageValue(cid, 18001, getPlayerStorageValue(cid, 18001)+1)
                doPlayerSendTextMessage(cid, 24, "You have killed " .. getPlayerStorageValue(cid, 18001) .. " of 5 dragons")
            end
        end
    end
   
    return true
end
 
Yeah, and nothing happens, and no, no erroes showed up, thats why i call this misterious, maybe something is worng in my sources?, i tgot a 7.6 TFS based on 0.3.X
 
some early alpha sources maybe?
because they do not support buffering same events in different scripts.

try this:
add this at top of your "amalus.lua" file
Code:
dofile("dragontask.lua")
and remove
Code:
registerCreatureEvent(cid, "dragontask")
<event type="kill" name="dragontask" script="dragontask.lua"/>
 
No mate, this is really annoying, the only one that works is amalus.lua, check that file too

Code:
dofile(getDataDir() .. 'creaturescripts/scripts/dragontask.lua')

function onKill(cid, target)

function transporte()
local pos = {x=1291,y=1401,z=9}
doTeleportThing(cid, pos)
doPlayerSendTextMessage(cid, 22, "You have killed the wizard, now report back to Mathias")
doSendMagicEffect(pos, 10)
end

if getCreatureName(target) == "Amalus The Wizard" then
doPlayerSendTextMessage(cid, 22, "You have 15 seconds to take the loot from the wizards body")
setPlayerStorageValue(cid, 17012, 16)
setPlayerStorageValue(cid, 17015, -1)
addEvent(transporte, 15000, cid)
end
return true
end

Everything with this scripts goes well, but the dragontask not, really don't know why =(
 
The way I told you fixed the issue back then for me dunno why it doesn't work for you.
Just combine them then.
Code:
local function transporte(cid)
local pos = {x=1291,y=1401,z=9}
doTeleportThing(cid, pos)
doPlayerSendTextMessage(cid, 22, "You have killed the wizard, now report back to Mathias")
doSendMagicEffect(pos, 10)
end

function onKill(cid, target)
   if getCreatureName(target) == "Amalus The Wizard" then
     doPlayerSendTextMessage(cid, 22, "You have 15 seconds to take the loot from the wizards body")
     setPlayerStorageValue(cid, 17012, 16)
     setPlayerStorageValue(cid, 17015, -1)
     addEvent(transporte, 15000, cid)
   end
   if getPlayerStorageValue(cid, 18001) == 5 then
     setPlayerStorageValue(cid, 17012, 19)
   end
   if getCreatureName(target) == "Dragon" then
     if getPlayerStorageValue(cid, 18000) == 1 then
       if getPlayerStorageValue(cid, 18001) <= 4 then
         setPlayerStorageValue(cid, 18001, getPlayerStorageValue(cid, 18001)+1)
         doPlayerSendTextMessage(cid, 24, "You have killed " .. getPlayerStorageValue(cid, 18001) .. " of 5 dragons")
       end
     end
   end
   return true
end
 
I advise you to add "if (isMonster(target)) then". It will prevent players from killing their noobchars with same nickname as the task creature.
 
Back
Top