• 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 Crashes with my task script.

Lunarzz

New Member
Joined
Jan 23, 2015
Messages
45
Reaction score
0
Hello I am currently getting some kind of errors when using my script.


This is the script:
Code:
local config = {
        ['souleater'] = {amount = 30, storage = 29000, startstorage = 60027, startvalue = 1}
}

function onKill(cid, target)

        local monster = config[getCreatureName(target):lower()]

        if isPlayer(target) or not monster or isSummon(target) then
            return true
        end

        if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
            setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
        end
        if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
            setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
        end
        return true
end



And the error i'm getting is:


[26/02/2015 02:48:45] [Error - CreatureScript Interface]
[26/02/2015 02:48:45] data/creaturescripts/scripts/souleater.lua:eek:nKill
[26/02/2015 02:48:45] Description:
[26/02/2015 02:48:45] data/creaturescripts/scripts/souleater.lua:9: attempt to call global 'isSummon' (a nil value)
[26/02/2015 02:48:45] stack traceback:
[26/02/2015 02:48:45] data/creaturescripts/scripts/souleater.lua:9: in function <data/creaturescripts/scripts/souleater.lua:5>
 
Last edited by a moderator:
Hello I am currently getting some kind of errors when using my script.


This is the script:

local config = {
['souleater'] = {amount = 30, storage = 29000, startstorage = 60027, startvalue = 1}
}

function onKill(cid, target)

local monster = config[getCreatureName(target):lower()]

if isPlayer(target) or not monster or isSummon(target) then
return true
end

if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end


And the error i'm getting is:


[26/02/2015 02:48:45] [Error - CreatureScript Interface]
[26/02/2015 02:48:45] data/creaturescripts/scripts/souleater.lua:eek:nKill
[26/02/2015 02:48:45] Description:
[26/02/2015 02:48:45] data/creaturescripts/scripts/souleater.lua:9: attempt to call global 'isSummon' (a nil value)
[26/02/2015 02:48:45] stack traceback:
[26/02/2015 02:48:45] data/creaturescripts/scripts/souleater.lua:9: in function <data/creaturescripts/scripts/souleater.lua:5>
Code:
local config = {
['souleater'] = {amount = 30, storage = 29000, startstorage = 60027, startvalue = 1}
}

function onKill(cid, target)

local monster = config[getCreatureName(target):lower()]

if isPlayer(target) or not monster or getCreatureMaster(target) > 0 then
return true
end

if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end
 
Code:
local config = {
['souleater'] = {amount = 30, storage = 29000, startstorage = 60027, startvalue = 1}
}

function onKill(cid, target)

local monster = config[getCreatureName(target):lower()]

if isPlayer(target) or not monster or getCreatureMaster(target) > 0 then
return true
end

if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end
Thanks alot for help, I appreciate it alot! :)

Also if you can, you don't have to but if you could explain what was the problem, it would be great, as I have begun scripting now again and I didn't really understand what was wrong there.


Yours, Lunarzz!
 
Thanks alot for help, I appreciate it alot! :)

Also if you can, you don't have to but if you could explain what was the problem, it would be great, as I have begun scripting now again and I didn't really understand what was wrong there.


Yours, Lunarzz!
Your server apparently doesn't have the function isSummon
 
Last edited:
isSummon is a Lua made function, it should be added in libs (data/lib/050-function.lua or global.lua, depense on server version).
This is often already added and if not you can add it yourself. If a function doesn't exist it will give a nil value error, which basicly says it means nothing.
Since isSummon is not defined as a function anywhere in your server or datapack, it will be the same as writing for example: fvhdjbsdjhdbsjh(target), which will also result in a nil value since fvhdjbsdjhdbsjh does not exist.
So an other alternative to solve the error would be adding the function.

function isSummon (from TFS 0.2 global.lua)
Code:
function isSummon(cid)
   return (isCreature(cid) == TRUE and (getCreatureMaster(cid) ~= cid)) and TRUE or FALSE
end
Next time post your server version, since alot of things are different on different servers, this function for example should be written different for TFS 0.4 or 1.x.
 
isSummon is a Lua made function, it should be added in libs (data/lib/050-function.lua or global.lua, depense on server version).
This is often already added and if not you can add it yourself. If a function doesn't exist it will give a nil value error, which basicly says it means nothing.
Since isSummon is not defined as a function anywhere in your server or datapack, it will be the same as writing for example: fvhdjbsdjhdbsjh(target), which will also result in a nil value since fvhdjbsdjhdbsjh does not exist.
So an other alternative to solve the error would be adding the function.

function isSummon (from TFS 0.2 global.lua)
Code:
function isSummon(cid)
   return (isCreature(cid) == TRUE and (getCreatureMaster(cid) ~= cid)) and TRUE or FALSE
end
Next time post your server version, since alot of things are different on different servers, this function for example should be written different for TFS 0.4 or 1.x.
The version is 0.3.6, I found another problem sorry if I am puting my problems onto you. It was ages ago I used to do some basic lua, well I found another problem I have so many troubles on this.


I am using same as owned posted, but it seem like it doesn't count the kill counter.
I been trying using the same codes on a auto started task aswell, it didn't work so it's something i'm doing wrong. Like I can kill 5000 souleaters but when i'm trying to hand it in to the npc it just says I am not finished, actually what I try to make is that it counts in like a text on localchat for yourself with counting etc :)

By any chance if you could help me with this I would be really glad!
Yours, Lunar
 
Back
Top