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

Why does this script not work?

try this login.lua I think I repaired.
Lua:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}      
local town = "Enigma"   --- town name
local townid = 1   --- put the town id
function onLogin(cid)
   local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end
    if getPlayerStorageValue(cid, storage) == FALSE then
            doPlayerSendTextMessage(cid,24,"You have no vip, Purchace VIP to get acces to nice places and unique features!")
            doPlayerSetTown(cid, townid)
        end
    registerCreatureEvent(cid, "PlayerDeath") 
   if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end
    
    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")
    registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "RewardGhastly")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Advanceeffect")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end

Now change Rewardghastly.lua for this:
Lua:
function onKill(cid, target)
setPlayerStorageValue(cid,45459,1)
doPlayerSay(cid, 'Congratulations! You slaughted The Haunted dragon, Get your rewards in the room in the west.', 19)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE, cid)
return true
end

Now try ;)
 
Nope it doesn't work the only difference is when i log always this message comes:
PHP:
12:56 Hello, type 'account' to create an account or type 'recover' to recover an account.
 
try this one af.. xd
Lua:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}
local town = "Enigma" --- town name
local townid = 1 --- put the town id
function onLogin(cid)
 if getPlayerStorageValue(cid, storage) == FALSE then
            doPlayerSendTextMessage(cid,24,"You have no vip, Purchace VIP to get acces to nice places and unique features!")
            doPlayerSetTown(cid, townid)
        end

	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end
 registerCreatureEvent(cid, "PlayerDeath") 
    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")
    registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "RewardGhastly")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Advanceeffect")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	return true
end
 
with cg.lua try this:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function pick_quest(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local level = getPlayerLevel(cid)
    for k, v in pairs(wow_like_quests) do
        local required = tonumber(k)
        if(level >= required) then
            for i, v in ipairs(v) do    
              if getPlayerLevel(cid) >= 80 then
                      setPlayerStorageValue(cid,66226,1)
                    npcHandler:say("Our city keep getting earthquakes please help us go to the larva cave and find out who is responsible for this and kill him!", cid)
                    parameters.quest = v
                    return true
                    end
                    npcHandler:resetNpc()
                    return true
                end
            end
        end
    end
    npcHandler:say("I have no quests to offer you at the moment. Come back when your stronger", cid)
    npcHandler:resetNpc()
    
function accept_quest(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local quest = node:getParent():getParameters().quest
    local storage = quest.storage
    setPlayerStorageValue(cid, storage, 0)
    npcHandler:say("I'm expecting to hear from you again. Don't dissapoint me.", cid)
    if(quest.on_accept) then quest.on_accept(cid, quest) end
    npcHandler:resetNpc()
    return true
end

-- Keyword "Quest" will pick lowest undone quest for you. 
local questNode = keywordHandler:addKeyword({'quest'}, pick_quest, {})
    questNode:addChildKeyword({'yes'}, accept_quest, {})
    questNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too hard for you, eh?'})

    
npcHandler:addModule(FocusModule:new())
And the second error of the console referring NPC is problem with XML file code.
 
onthe xml i found the error on the map editor creatures.xml it wanted a file called peten the dark clown but i changed it now that problem is gone i have edited the problem already
 
OK, for the 1st problem, why do you register an event for players while it's for monsters?
 
I want cg.lua working the error and things got posted.

I want Peten.lua working i also writed the problem and the script.

and onkill haunted dragon get storagevalue and text and effect etc.

added problem 3/4/5

Organized again.
 
Last edited:
Nevermind, for 1st problem do:
change to
Lua:
function onKill(cid, target, lastHit)
    if isPlayer(cid) and getCreatureName(target):lower() == 'the haunted dragon' then
        doCreatureSetStorage(cid, 45459, 1)
        doCreatureSay(cid, 'Congratulations! You slaughted The Haunted dragon, Get your rewards in the room in the west.', 19)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    end
    return true
end
supposing that the haunted dragon is an unique monster
 
your login.lua is bugged aswel..
Lua:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

local VIPstorage = 13243
local town = "Enigma"   --- town name
local townid = 1   --- put the town id

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if getPlayerStorageValue(cid, VIPstorage) == -1 then
        doPlayerSendTextMessage(cid,24,"You have no vip, Purchace VIP to get acces to nice places and unique features!")
        doPlayerSetTown(cid, townid)
    end
    
    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end
    
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")
    registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "RewardGhastly")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Advanceeffect")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end
should not display errors

Once your login.lua is fixed the other script should work
 
Lua:
local config = 
    {
        loginMessage = getConfigValue('loginMessage'),
        useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
    }
    
local town = "Enigma"   --- town name
local townid = 1   --- put the town id

function onLogin(cid)
    
    -- what this for (?)
    if (getPlayerStorageValue(cid, sotrage) ~= 1) then
        doPlayerSendTextMessage(cid, 24, "You have no vip, Purchace VIP to get acces to nice places and unique features!")
        doPlayerSetTown(cid, townid)
    end

    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")
    registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "RewardGhastly")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Advanceeffect")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end
 
Back
Top