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

Token Npc Script....Errors

RockeTBunnYz

Trainee in progress
Joined
Jan 21, 2015
Messages
137
Reaction score
7
Location
sweden
Hey, i was writing and adding this script to my server and got this error but i cant find it anyway and there was some EOF error too...

Code:
[18:34:45.368] [Error - LuaInterface::loadFile] data/npc/scripts/tokentrader.lua
:32: unexpected symbol near '=='
[18:34:45.370] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
[18:34:45.371] data/npc/scripts/tokentrader.lua:32: unexpected symbol near '=='
[18:34:45.580] [Notice - Npc::Npc] NPC Name: Frenzy - autowalk has been deprecat
ed, use walkinterval.
[18:34:45.582] [Error - LuaInterface::loadFile] data/npc/scripts/tokentrader.lua
:32: unexpected symbol near '=='
[18:34:45.583] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
[18:34:45.584] data/npc/scripts/tokentrader.lua:32: unexpected symbol near '=='

here is my scripts can someone please help me make it work .....
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local t = {
tokens = 5468, -- id of tokens
items = {
[1] = {"boots of haste", 10, 2195},
[2] = {"demon helmet", 10, 2493},
}
}

local function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
        end
if msgcontains(msg, 'boots of haste') then
if getPlayerItemCount(cid,t.tokens,10) == true then                 -- 10 Game Tokens
selfSay('Did you bring me 10 game tokens?', cid)
else
selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
    end
        end

if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) == true then
    doPlayerRemoveItem(cid,t.tokens,10) == true then
    doPlayerAddItem(cid,t.items > [1]) then                            ---- boots of haste
        selfSay"Here you go!" 
            end
if msgcontains(msg, 'demon helmet') then
if getPlayerItemCount(cid,t.tokens,10) == true then                 -- 10 Game Tokens
selfSay('Did you bring me 10 game tokens?', cid)
else
selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
end
    end

if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) == true then
    doPlayerRemoveItem(cid,t.tokens,10) == true then
    doPlayerAddItem(cid,t.items > [2]) then                            ----- demon helmet
        selfSay"Here you go!" 
        end
    end

please help !!
 
I'm unsure of this line..
Code:
doPlayerRemoveItem(cid,t.tokens,10) == true then
I've never seen == true then..
You also have another line similar to this further down.
I believe it needs to be like this.
Code:
doPlayerRemoveItem(cid,t.tokens,10)
 
I'm unsure of this line..
Code:
doPlayerRemoveItem(cid,t.tokens,10) == true then
I've never seen == true then..
You also have another line similar to this further down.
I believe it needs to be like this.
Code:
doPlayerRemoveItem(cid,t.tokens,10)

You forgott next line :]

Code:
if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) == true then
    if doPlayerRemoveItem(cid,t.tokens,10) == true then
    if doPlayerAddItem(cid,t.items > [2]) then                            ----- demon helmet
        selfSay"Here you go!"
      end
end
end
    end
 
I'm unsure of this line..
Code:
if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) then
    doPlayerRemoveItem(cid,t.tokens,10) then
    doPlayerAddItem(cid,t.items[2]) then                            ----- demon helmet
        selfSay"Here you go!" 
        end

is this right now i getting unexpect sympol near then and i think it's mean this like
Code:
if getPlayerItemCount(cid,t.tokens,10) then
    doPlayerRemoveItem(cid,t.tokens,10) then
should i put IF before doPlayerRemoveItem(cid,t.tokens,10) then? or what do i need to do ....
 
Your removing the item.
Nothing needs to come after that or before.
Copy my line and you'll be fine.
 
You forgott next line :]

Code:
if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) == true then
    if doPlayerRemoveItem(cid,t.tokens,10) == true then
    if doPlayerAddItem(cid,t.items > [2]) then                            ----- demon helmet
        selfSay"Here you go!"
      end
end
end
    end
i did like you told me and now i getting this error ... if and then...
Code:
[18:53:37.582] [Error - LuaInterface::loadFile] data/npc/scripts/tokentrader.lua
:33: 'then' expected near 'if'
[18:53:37.582] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
[18:53:37.584] data/npc/scripts/tokentrader.lua:33: 'then' expected near 'if'
[18:53:37.778] [Notice - Npc::Npc] NPC Name: Frenzy - autowalk has been deprecat
ed, use walkinterval.
[18:53:37.780] [Error - LuaInterface::loadFile] data/npc/scripts/tokentrader.lua
:33: 'then' expected near 'if'
[18:53:37.781] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
[18:53:37.782] data/npc/scripts/tokentrader.lua:33: 'then' expected near 'if'

here what my scripts look like now
Code:
if msgcontains(msg, 'demon helmet') then
if getPlayerItemCount(cid,t.tokens,10)                            -- 10 Game Tokens
selfSay('Did you bring me 10 game tokens?', cid)
else
selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
end
    end

if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) then
    if doPlayerRemoveItem(cid,t.tokens,10) then
    if PlayerAddItem(cid,t.items[2]) then                            ----- demon helmet
        selfSay"Here you go!" 
        end
end
end
    end
 
ugh, post entire script and your tfs version. lmao

im using TFS 0.4

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local t = {
tokens = 5468, -- id of tokens
items = {
[1] = {"boots of haste", 10, 2195},
[2] = {"demon helmet", 10, 2493},
}
}

local function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
        end
if msgcontains(msg, 'boots of haste') then
if getPlayerItemCount(cid,t.tokens,10) then                -- 10 Game Tokens
selfSay('Did you bring me 10 game tokens?', cid)
else
selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
    end
        end

if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) then
    if doPlayerRemoveItem(cid,t.tokens,10)
    if doPlayerAddItem(cid,t.items[1]) then                            ---- boots of haste
        selfSay"Here you go!" 
    end
end
end
    end
if msgcontains(msg, 'demon helmet') then
if getPlayerItemCount(cid,t.tokens,10)                            -- 10 Game Tokens
selfSay('Did you bring me 10 game tokens?', cid)
else
selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
end
    end

if msgcontains(msg,'yes') then
    if getPlayerItemCount(cid,t.tokens,10) then
    if doPlayerRemoveItem(cid,t.tokens,10) then
    if PlayerAddItem(cid,t.items[2]) then                            ----- demon helmet
        selfSay"Here you go!" 
        end
end
end
    end
 
Code:
if getPlayerItemCount(cid,t.tokens) >= 10 then

If you only delete 1 stack of items, just using this is enough btw.
Code:
if doPlayerRemoveItem(cid,t.tokens,10) then
 
Code:
if getPlayerItemCount(cid,t.tokens) >= 10 then

If you only delete 1 stack of items, just using this is enough btw.
Code:
if doPlayerRemoveItem(cid,t.tokens,10) then
I don't understand the if's. :eek:
Why are they required multiple times?
 
Sometimes it can be better to have more if statements if different things should happen after each if statement for example.
But if not, you can also just add everything in 1 if statement and use and between them.
 
Code:
if msgcontains(msg,'yes') then
    if doPlayerRemoveItem(cid,t.tokens,10) then
    if PlayerAddItem(cid,t.items[2]) then                            ----- demon helmet
        selfSay"Here you go!"
        end
end
end
i have changed it to this now, it is right?
 
thanks getting the script right now, and now i got this error .... null...

Code:
[19:12:24.611] [Error - NpcScript Interface]
[19:12:24.612] data/npc/scripts/tokentrader.lua
[19:12:24.613] Description:
[19:12:24.614] data/npc/lib/npc.lua:51: attempt to index local 'message' (a nil
value)
[19:12:24.616] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
what does this mean?

Repp+++++
 
For the add item function.
Code:
doPlayerAddItem(cid, t.items[2][3], t.items[2][2])

t.items[2] means second value (which is a table) in the table items, t.items[2][3] means third value in the second table inside items.
 
For the add item function.
Code:
doPlayerAddItem(cid, t.items[2][3], t.items[2][2])

t.items[2] means second value (which is a table) in the table items, t.items[2][3] means third value in the second table inside items.

like this sir?

Code:
if msgcontains(msg,'yes') then
    if doPlayerRemoveItem(cid,t.tokens,10) then
    if doPlayerAddItem(cid, t.items[1][3], t.items[1][2]) then                            ---- boots of haste
        selfSay("Here you go!", cid)
    end
end
end
    end
if msgcontains(msg, 'demon helmet') then
if getPlayerItemCount(cid,t.tokens,10) then                            -- 10 Game Tokens
selfSay('Did you bring me 10 game tokens?', cid)
else
selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
end
    end

if msgcontains(msg,'yes') then
    if doPlayerRemoveItem(cid,t.tokens,10) then
    if doPlayerAddItem(cid, t.items[2][3], t.items[2][2]) then                            ----- demon helmet
        selfSay("Here you go!", cid)
        end
end
end

why this? (cid, t.items[2][3], t.items[2][2]) i dont have number 3 i only have 1 and 2 ... i dont understand this line.
 
The if statement is not needed, so you can just do this.
Code:
doPlayerAddItem(cid, t.items[2][3], t.items[2][2])
Remove the end from that if statement aswell.
 
The if statement is not needed, so you can just do this.
Code:
doPlayerAddItem(cid, t.items[2][3], t.items[2][2])
Remove the end from that if statement aswell.

i did remove the if statement and its told me unexpected symbol near then
Code:
if doPlayerRemoveItem(cid,t.tokens,10) then
doPlayerAddItem(cid, t.items[2][3], t.items[2][2]) then     <<<----- this add item line is unexpected symbol near then...
selfSay("Here you go!", cid)
end
end
 
Back
Top