• 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 !!
 
Remove then, It's also a part of the if statement and remove the end to close the if statement under that aswell.

like this sir? i'm so damn confused with all the codes..... phew...
Code:
if msgcontains(msg, 'demon helmet') 
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') 
    if doPlayerRemoveItem(cid,t.tokens,10) 
        doPlayerAddItem(cid, t.items[2])                             ----- demon helmet
            selfSay("Here you go!", cid) 
    end
        end
 
like this sir? i'm so damn confused with all the codes..... phew...
Code:
if msgcontains(msg, 'demon helmet')
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')
    if doPlayerRemoveItem(cid,t.tokens,10)
        doPlayerAddItem(cid, t.items[2])                             ----- demon helmet
            selfSay("Here you go!", cid)
    end
        end
u should also use talkstates
 
The then here.
Code:
doPlayerAddItem(cid, t.items[2][3], t.items[2][2]) then
if statements should always have then at the end of the line.
now my script look like this gosh....
Code:
if msgcontains(msg, 'demon helmet') then
 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

if msgcontains(msg,'yes') then
    doPlayerRemoveItem(cid,t.tokens,10) 
        doPlayerAddItem(cid, t.items[2])                             ----- demon helmet
            selfSay("Here you go!", cid) 
    end
 
what does this error mean ???
Code:
[20:22:48.149] [Error - NpcScript Interface]
[20:22:48.150] data/npc/scripts/tokentrader.lua
[20:22:48.151] Description:
[20:22:48.152] data/npc/lib/npc.lua:51: attempt to index local 'message' (a nil
value)
 
Code:
if msgcontains(msg, 'demon helmet') then
     selfSay('Did you bring me 10 game tokens?', cid)
elseif msgcontains(msg,'yes') then
     if doPlayerRemoveItem(cid, t.tokens, 10) then
         doPlayerAddItem(cid, t.items[2][3], 1)  ----- demon helmet
         selfSay("Here you go!", cid)
     else
         selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
     end
end
Best is to use talkstate with yes.
http://otland.net/threads/npc-mission.211063/#post-2022375

For that error, post the whole script.
 
Code:
if msgcontains(msg, 'demon helmet') then
     selfSay('Did you bring me 10 game tokens?', cid)
elseif msgcontains(msg,'yes') then
     if doPlayerRemoveItem(cid, t.tokens, 10) then
         doPlayerAddItem(cid, t.items[2][3], 1)  ----- demon helmet
         selfSay("Here you go!", cid)
     else
         selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
     end
end
Best is to use talkstate with yes.
http://otland.net/threads/npc-mission.211063/#post-2022375

For that error, post the whole script.

getting this error with your talkstate
Code:
[21:17:34.589] [Error - LuaInterface::loadFile] data/npc/scripts/tokentrader.lua
:32: unexpected symbol near ']'
[21:17:34.590] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
[21:17:34.591] data/npc/scripts/tokentrader.lua:32: unexpected symbol near ']'
[21:17:34.793] [Notice - Npc::Npc] NPC Name: Frenzy - autowalk has been deprecat
ed, use walkinterval.
[21:17:34.794] [Error - LuaInterface::loadFile] data/npc/scripts/tokentrader.lua
:32: unexpected symbol near ']'
[21:17:34.795] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/tokentrader.lua
[21:17:34.797] data/npc/scripts/tokentrader.lua:32: unexpected symbol near ']'

this is my script with talkstate
Code:
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

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

function creatureSayCallback(cid, type, msg)
   if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
    if msgcontains(msg, 'boots of haste') then
        getPlayerItemCount(cid,t.tokens,10)                 -- 10 Game Tokens
            selfSay('Did you bring me 10 game tokens?', cid)
            talkState[talkUser] = 1
    elseif msgcibtaubs(msg,'yes') and talkState[talkUser] == 1 then
            doPlayerRemoveItem(cid,t.tokens,10) 
                doPlayerAddItem(cid, t.items[1])                             ---- boots of haste
                        selfSay("Here you go!", cid)]
                        talkState[talkUser] = 0
    elseif msgcontains(msg,"no") and talkState[talkUser] == 1 then
                        selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
            end

    end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

But that guide you did was really helpful thanks ! yet have another a error yippi....:mad:
 
selfSay("Here you go!", cid)]

~~
Remove that.
I'm got this to work sir, but yet didnt NPC Respone after i saying "yes" im getting no error in my serverlog.
Code:
21:46 Frenzy: Welcome, Own! I have been expecting you.
21:46 Own [665]: Boots of haste
21:46 Own [665]: gametoken
21:46 Own [665]: hi
21:46 Frenzy: Welcome, Own! I have been expecting you.
21:46 Own [665]: Boots of haste
21:46 Frenzy: Did you bring me 10 game tokens?
21:47 Own [665]: yes
21:47 Own [665]: yes
21:47 Own [665]: yes

here its my script now
Code:
if msgcontains(msg, "hi") then
        selfSay("Here can you exchange {Gametoken} for {Boots of haste}, {Demon helmet}.", cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg,"Gametoken") then
        selfSay("You can getting Gametokens from Events and trade gametokens for items or points")
        talkState[talkUser] = 0
    elseif msgcontains(msg, "Boots of haste") then
        getPlayerItemCount(cid,t.tokens,10)                 -- 10 Game Tokens
        selfSay('Did you bring me 10 game tokens?', cid)
        talkState[talkUser] = 1
    elseif msgcibtaubs(msg,"yes") and talkState[talkUser] == 1 then
            doPlayerRemoveItem(cid, t.tokens,10) 
                doPlayerAddItem(cid, t.items[1])                             ---- boots of haste
                        talkState[talkUser] = 0
    elseif msgcontains(msg,"no") and talkState[talkUser] == 1 then
        selfSay("Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.", cid)
        talkState[talkUser] = 0
                end
                return true
    end

REP+++ you are a greatman Limos
 
clerical error?
Code:
msgcibtaubs(msg,"yes")

elseif msgcibtaubs(msg,"yes") and talkState[talkUser] == 1 then
            doPlayerRemoveItem(cid, t.tokens,10) 
                doPlayerAddItem(cid, t.items[1])                             ---- boots of haste
                        talkState[talkUser] = 0

Code:
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
            doPlayerRemoveItem(cid, t.tokens,10) 
                doPlayerAddItem(cid, t.items[1])                             ---- boots of haste
                        talkState[talkUser] = 0
 
clerical error?
Code:
msgcibtaubs(msg,"yes")

elseif msgcibtaubs(msg,"yes") and talkState[talkUser] == 1 then
            doPlayerRemoveItem(cid, t.tokens,10)
                doPlayerAddItem(cid, t.items[1])                             ---- boots of haste
                        talkState[talkUser] = 0

Code:
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
            doPlayerRemoveItem(cid, t.tokens,10)
                doPlayerAddItem(cid, t.items[1])                             ---- boots of haste
                        talkState[talkUser] = 0

haha what a miss :p was to much code for me in one day hahaha!
 
ok i got everything working fine now! but yet there is another problem the npc give items even i dont have the tokens...:(:(:(
Code:
getPlayerItemCount(cid,t.tokens,20)                            ---------- cost 20 Gametokens
        selfSay('Did you bring me 20 gametokens?', cid)
    elseif msgcontains(msg,"yes") then
            doPlayerRemoveItem(cid, t.tokens,20)
                doPlayAddItem(cid, t.tokens.[2][2])
This like should check if the player have the request items or not but i think i doesn't even check it.
 
Code:
if msgcontains(msg, 'demon helmet') then
     selfSay('Did you bring me 10 game tokens?', cid)
elseif msgcontains(msg,'yes') then
     if doPlayerRemoveItem(cid, t.tokens, 10) then
         doPlayerAddItem(cid, t.items[2][3], 1)  ----- demon helmet
         selfSay("Here you go!", cid)
     else
         selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
     end
end
Code:
if doPlayerRemoveItem(cid, t.tokens, 10) then
 
Code:
if doPlayerRemoveItem(cid, t.tokens, 10) then

if i have the request items in my bag the npc will take it and give me the items but also i can get items without the requesting items...

i got the
Code:
 getPlayerItemCount(cid, 6527 > [, subType = 10])
how can i do it so count 10 for the request? am i doing it right?
 
Post the script how it looks like now.

Here you go####
Code:
elseif msgcontains(msg, "boots of haste") then
        getPlayerItemCount(cid, 6527 > [, subType = 10])                     ---------- cost 10 Gametokens
        selfSay('Did you bring me 10 gametokens?', cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg,"yes") then
            doPlayerRemoveItem(cid, t.tokens,10) 
                doPlayerAddItem(cid, t.items[1][2])                    ---------- Boots of Haste
                        talkState[talkUser] = 0
    elseif msgcontains(msg,"no") and talkState[talkUser] == 1 then
        selfSay("Sorry, I need you to have atleast {10 Gametokens} . Come back when you have them.", cid)
        talkState[talkUser] = 0
                end
 
Add it with the if statement like I posted.

Just added this if statement its doesnt help i still the same getting items with no tokens

Code:
if msgcontains(msg, "soft boots") then
        if getPlayerItemCount(cid,t.tokens,20) then                            ---------- cost 20 Gametokens
        selfSay('Did you bring me 20 gametokens?', cid)
    elseif msgcontains(msg,"yes") then
            doPlayerRemoveItem(cid, t.tokens,20)
                doPlayAddItem(cid, t.items[2][2])
                        talkstate[talkUser] = 0
    elseif msgcontains(msg,"no") and talkState[talkUser] == 1 then
        selfSay("Sorry, I need you to have atleast {20 Gametokens} . Come back when you have them.", cid)
        talkState[talkUser] = 0
                end
 
This one, instead of doPlayerRemoveItem(cid, t.tokens,20)
Code:
if doPlayerRemoveItem(cid, t.tokens, 10) then
if statements should close with an end btw.

If you look at this post you can see how to do it (talkState isn't added here yet).
Code:
if msgcontains(msg, 'demon helmet') then
     selfSay('Did you bring me 10 game tokens?', cid)
elseif msgcontains(msg,'yes') then
     if doPlayerRemoveItem(cid, t.tokens, 10) then
         doPlayerAddItem(cid, t.items[2][3], 1)  ----- demon helmet
         selfSay("Here you go!", cid)
     else
         selfSay('Sorry, I need you to have atleast {10 game tokens} . Come back when you have them.', cid)
     end
end
 
This one, instead of doPlayerRemoveItem(cid, t.tokens,20)

if statements should close with an end btw.

If you look at this post you can see how to do it (talkState isn't added here yet).
working now thanks you! and yet other problems... the scripts is if i said boots of haste and then yes and the npc will give you boots of haste that how its should work, but when i try my second items exempel "soft boots" and after that i said "yes" i getting the boots of haste..... why does this happen...

Code:
elseif msgcontains(msg, "boots of haste") then
        getPlayerItemCount(cid,t.tokens,10)                         ---------- cost 10 Gametokens
        selfSay('Did you bring me 10 gametokens?', cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg,"yes") then
            if doPlayerRemoveItem(cid, t.tokens, 10) then
                doPlayerAddItem(cid, t.items[1][2])                    ---------- Boots of Haste
                        talkState[talkUser] = 0
    elseif msgcontains(msg,"no") and talkState[talkUser] == 1 then
        selfSay("Sorry, I need you to have atleast {10 Gametokens} . Come back when you have them.", cid)
        talkState[talkUser] = 0
            end
        end
              
    if msgcontains(msg, "soft boots") then
        if getPlayerItemCount(cid,t.tokens,20) then                            ---------- cost 20 Gametokens
            doPlayerRemoveItem(cid, t.tokens,20)
                doPlayAddItem(cid, t.items[2][3])                            ---------- soft boots
                        talkstate[talkUser] = 0
    elseif msgcontains(msg,"no") and talkState[talkUser] == 1 then
        selfSay("Sorry, I need you to have atleast {20 Gametokens} . Come back when you have them.", cid)
        talkState[talkUser] = 0
                end
 
Back
Top Bottom