• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Task System

zeferu

New Member
Joined
Feb 13, 2010
Messages
5
Reaction score
0
Hiho, i have problem in this task skrypt.
PHP:
local monsters = {
    ["demon"] = 35000,
    ["morgaroth"] = 35001,
    }

function onKill(cid, target)
    if(isPlayer(target) ~= TRUE) then
        local name = getCreatureName(target)
        local monster = monsters[string.lower(name)]
        if(monster) then
            local killedMonsters = getPlayerStorageValue(cid, monster)
            if(killedMonsters == -1) then
                killedMonsters = 1
            end
            if((name == "demon" and getPlayerStorageValue(cid, 66666) == 1) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " of 30 demons.")
                setPlayerStorageValue(cid, monster, killedMonsters + 1)
                if getPlayerStorageValue(cid, 35000)>30 then 
                    setPlayerStorageValue(cid, 66666, 2)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed enough demons.")
                end
            elseif((name == "morgaroth" and getPlayerStorageValue(cid, 66666) == 4) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " of 15 Morgaroths.")
                setPlayerStorageValue(cid, monster, killedMonsters + 1)
                if getPlayerStorageValue(cid, 35001)>15 then 
                    setPlayerStorageValue(cid, 66666, 5)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed enough Morgaroths.")
                        end
                    end
                end
            end            
        end
    end
    return TRUE
end

In console i have this error
PHP:
[04/10/2011 08:17:32] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/kill.lua:15: ')' expected near 'then'
[04/10/2011 08:17:32] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/kill.lua)
[04/10/2011 08:17:32] data/creaturescripts/scripts/kill.lua:15: ')' expected near 'then'
 
Lua:
local monsters = {
    ["demon"] = 35000,
    ["morgaroth"] = 35001,
    }
 
function onKill(cid, target)
    if(isPlayer(target) ~= TRUE) then
        local name = getCreatureName(target)
        local monster = monsters[string.lower(name)]
        if(monster) then
            local killedMonsters = getPlayerStorageValue(cid, monster)
            if(killedMonsters == -1) then
                killedMonsters = 1
            end
            if(name == "demon" and getPlayerStorageValue(cid, 66666) == 1) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " of 30 demons.")
                setPlayerStorageValue(cid, monster, killedMonsters + 1)
                if getPlayerStorageValue(cid, 35000) > 30 then 
                    setPlayerStorageValue(cid, 66666, 2)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed enough demons.")
                end
            elseif(name == "morgaroth" and getPlayerStorageValue(cid, 66666) == 4) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " of 15 Morgaroths.")
                setPlayerStorageValue(cid, monster, killedMonsters + 1)
                if getPlayerStorageValue(cid, 35001) > 15 then 
                    setPlayerStorageValue(cid, 66666, 5)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed enough Morgaroths.")
                        end
                    end
                end
            end            
        end
    end
    return TRUE
end
 
Ok, thanks. I have new problem in npc skrypt
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 say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            local cid = cid or 0
            local nid = getNpcCid()
            addEvent(say, delay, param)


        end
    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 quest = 66666
local getquest = getPlayerStorageValue(cid, quest)
local second = 100
local nagrody = {
    [1] = {royal = 5887}
    [2] = {spirit = 5884, sweat = 5885, redpoc = 5911, greenpoc = 5910, yarn = 5886, ore = 5880, iron = 5892, fang = 5893, liza = 5876}
    }
    if msgcontains(msg, 'mission') then
        if getquest == -1 then
            delayedSay("Cos tam mowi...", second, cid)
            talkState[talkUser] = 1
        elseif getquest == 2 then
            delayedSay("Wykonales misje . . . oto nagroda.", second, cid)
            doPlayerAddItem(cid, nagrody[1].royal, 1)
            setPlayerStorageValue(cid, quest, 3)
        elseif getquest == 3 then    
            delayedSay("Czy chcesz zadanie?", second, cid)
            talkState[talkUser] = 2
        elseif getquest == 5 then
            delayedSay("Wykonales misje . . . oto nagroda.", second, cid)
            doPlayerAddItem(cid, nagrody[2].spirit, 1)
            setPlayerStorageValue(cid, quest, 6)
    
    
    elseif msgcontains(msg, 'yes') then
        if talkState[talkUser] == 1 then
            delayedSay("Misja polega na tym ze masz zabic 30 demonow a otrzymasz royal piece.", 100, cid)
            setPlayerStorageValue(cid, quest, 1)
        elseif talkState[talkUser] == 2 then
            delayedSay("Masz za zadanie zabic 15 morghorotów otrzymasz za to all items do barbariana !!!!", 100, cid)
            setPlayerStorageValue(cid, quest, 4)
            end
        end    
    end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Erron in console
Lua:
[04/10/2011 08:42:38] [Error - LuaScriptInterface::loadFile] data/npc/scripts/mission.lua:44: '}' expected (to close '{' at line 42) near '['
[04/10/2011 08:42:38] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/mission.lua
[04/10/2011 08:42:38] data/npc/scripts/mission.lua:44: '}' expected (to close '{' at line 42) near '['
 
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 say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            local cid = cid or 0
            local nid = getNpcCid()
            addEvent(say, delay, param)
 
 
        end
    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 quest = 66666
local getquest = getPlayerStorageValue(cid, quest)
local second = 100
local nagrody = {
    [1] = {royal = 5887},
    [2] = {spirit = 5884, sweat = 5885, redpoc = 5911, greenpoc = 5910, yarn = 5886, ore = 5880, iron = 5892, fang = 5893, liza = 5876}
    }
    if msgcontains(msg, 'mission') then
        if getquest == -1 then
            delayedSay("Cos tam mowi...", second, cid)
            talkState[talkUser] = 1
        elseif getquest == 2 then
            delayedSay("Wykonales misje . . . oto nagroda.", second, cid)
            doPlayerAddItem(cid, nagrody[1].royal, 1)
            setPlayerStorageValue(cid, quest, 3)
        elseif getquest == 3 then    
            delayedSay("Czy chcesz zadanie?", second, cid)
            talkState[talkUser] = 2
        elseif getquest == 5 then
            delayedSay("Wykonales misje . . . oto nagroda.", second, cid)
            doPlayerAddItem(cid, nagrody[2].spirit, 1)
            setPlayerStorageValue(cid, quest, 6)
 
 
    elseif msgcontains(msg, 'yes') then
        if talkState[talkUser] == 1 then
            delayedSay("Misja polega na tym ze masz zabic 30 demonow a otrzymasz royal piece.", 100, cid)
            setPlayerStorageValue(cid, quest, 1)
        elseif talkState[talkUser] == 2 then
            delayedSay("Masz za zadanie zabic 15 morghorotów otrzymasz za to all items do barbariana !!!!", 100, cid)
            setPlayerStorageValue(cid, quest, 4)
            end
        end    
    end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Oh and btw, next time you need help post the thread in the support board.
 
Back
Top Bottom