Lua <eof> ?

Discussion in 'Support' started by Triggah, Jul 21, 2009.

  1. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    [21/07/2009 13:41:12] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/rings.lua)
    [21/07/2009 13:41:12] data/actions/scripts/quests/rings.lua:13: '<eof>' expected near 'end'

    what does <eof> mean?
  2. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    It means that you forget to put an END.

    Try adding another end to the script.

    Maybe EOF is the end of the if, that is not found, and is not expected.
  3. Epic

    Epic Banned User

    Joined:
    Mar 30, 2009
    Messages:
    1,142
    post script, thanks :S
  4. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    Code:
    function onUse(cid, item, fromPosition, itemEx, toPosition)
         if getPlayerStorageValue(cid, 9002) == -1 then
              setPlayerStorageValue(cid, 9002, 1)
    		  local bp1 = doPlayerAddItem(cid, 1991, 1)
                    doAddContainerItem(bp1, 2168, 2)
    				doAddContainerItem(bp1, 2214, 2)
    				doAddContainerItem(bp1, 2197, 2)
    				doAddContainerItem(bp1, 2167, 2)			
            end					
              doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
         end
         return TRUE
         end
    end 
    
  5. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    ;o

    here it is fixed:

    Code:
    function onUse(cid, item, fromPosition, itemEx, toPosition)
         if getPlayerStorageValue(cid, 9002) == -1 then
              setPlayerStorageValue(cid, 9002, 1)
    		  local bp1 = doPlayerAddItem(cid, 1991, 1)
                    doAddContainerItem(bp1, 2168, 2)
    				doAddContainerItem(bp1, 2214, 2)
    				doAddContainerItem(bp1, 2197, 2)
    				doAddContainerItem(bp1, 2167, 2)			
            end					
              doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
         end
         return TRUE
    end
    
    Just deleted one of the unussefull ends, that doesnt end anything.
  6. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    not fixed, same error using ur script
  7. nsanee

    nsanee Member

    Joined:
    Apr 13, 2008
    Messages:
    661
    [lua]
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)
    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    end
    return TRUE
    end
    [/lua]
  8. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    Yay i forgot i didnt pasted the right script xD!

    Remember that always an IF ends with Ends.

    As;

    Code:
    Function...
    
     If...
    
     Else...
    
     End..
     Return...
    
     End..
    
    
    And you got 3 ends without "EOF".

    ;)

    As nsanee posted
    Code:
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)
    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    end
    return TRUE
    
    end 
    
  9. Delirium

    Delirium Deception - Illuminatus Staff Member Global Moderator

    Joined:
    May 28, 2007
    Messages:
    3,246
    Never seen a more horrible tabbing but anyway:
    [lua]function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    end

    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    return TRUE
    end[/lua]

    Improved version:
    [lua]local items = {
    2168,
    2214,
    2197,
    2167
    }

    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    for i = 0, #items do
    doAddContainerItem(bp1, items, 2)
    end

    end
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    return TRUE
    end[/lua]

    Edit: Damn nsanee was faster :( Didn't see you posted cause I was typing xD
  10. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    i can use the chest as many times as i want and get "you found a bag of supplies" but only get bag once, how would i put 'else' "this chest is empty"

    tried and got errors
  11. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    [lua]
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then --If storage is right...
    setPlayerStorageValue(cid, 9002, 1) -- This will do
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    else -- If storage is used...
    doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")
    end

    return TRUE
    end
    [/lua]

    Also remember the architecture;

    [lua]
    Function... --Start function

    If... --Start condition

    Else... --If condition is false or 0 or nil respecting the code...
    --Condition when condition If is false or wrong
    End... --This close the IF

    Return... --Return to the main

    End... --Closes the funcion
    [/lua]
  12. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    fixed it, working now
  13. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    Hmm it worked for me and looks fine;

    [lua]
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then --If storage is right...
    setPlayerStorageValue(cid, 9002, 1) -- This will do
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    else -- If storage is used...
    doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")
    end

    return TRUE
    end
    [/lua]

    [21/07/2009 15:12:31] Reloaded actions.
    [21/07/2009 15:12:47] Reloaded actions.

    And the update of an screenshot i made for see it worked;

    [​IMG]
    Last edited: Jul 21, 2009
  14. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    just tested it and it doesnt say you already recieved...
    just opens the chest

    [lua]
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)
    doAddContainerItem(bp1, 2168, 1)
    doAddContainerItem(bp1, 2214, 1)
    doAddContainerItem(bp1, 2197, 1)
    doAddContainerItem(bp1, 2167, 1)
    doAddContainerItem(bp1, 2168, 1)
    doAddContainerItem(bp1, 2214, 1)
    doAddContainerItem(bp1, 2197, 1)
    doAddContainerItem(bp1, 2167, 1)
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    else -- If storage is used...
    doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")
    end

    return TRUE
    end [/lua]


    [21/07/2009 14:14:55] Lua Script Error: [Action Interface]
    [21/07/2009 14:14:55] data/actions/scripts/quests/rings.lua:eek:nUse

    [21/07/2009 14:14:55] data/actions/scripts/quests/rings.lua:12: attempt to call global 'doPlayerSendtextMessage' (a nil value)
    [21/07/2009 14:14:55] stack traceback:
    [21/07/2009 14:14:55] data/actions/scripts/quests/rings.lua:12: in function <data/actions/scripts/quests/rings.lua:1>
  15. Delirium

    Delirium Deception - Illuminatus Staff Member Global Moderator

    Joined:
    May 28, 2007
    Messages:
    3,246
    [lua]function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    else
    doPlayerSendCancel(cid, 'This chest is empty.')
    end
    return TRUE
    end[/lua]

    And it's doPlayerSendTextMessage not doPlayerSendtextMessage
  16. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    ty nikolas, it works
  17. Delirium

    Delirium Deception - Illuminatus Staff Member Global Moderator

    Joined:
    May 28, 2007
    Messages:
    3,246
    You can also use this version, it's more advanced and more organized:
    [lua]local items = {
    2168,
    2214,
    2197,
    2167,
    2168,
    2214,
    2197,
    2167
    }

    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then
    setPlayerStorageValue(cid, 9002, 1)
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    for i = 0, #items do
    doAddContainerItem(bp1, items, 2)
    end
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    else
    doPlayerSendCancel(cid, 'This chest is empty.')
    end

    return TRUE
    end[/lua]

    I also added the new items you added in the newer version you posted.
  18. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    HAHAHHA!

    It doesnt matter if is a "T or a t" is the same character.

    And it worked with the code i say;

    [​IMG]
  19. Delirium

    Delirium Deception - Illuminatus Staff Member Global Moderator

    Joined:
    May 28, 2007
    Messages:
    3,246
    Then explain me why my own version worked with a capital T whilst yours didn't? Also the picture you posted doesn't prove that the script you posted works, it's just the message you get when you receive the reward and the function is written with a capital T.

    T and t is not the same character technically, they have different ASCII code.
  20. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    157
    Hmm i really dont know.

    But this is the code i used to;
    [lua]
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 9002) == -1 then --If storage is right...
    setPlayerStorageValue(cid, 9002, 1) -- This will do
    local bp1 = doPlayerAddItem(cid, 1991, 1)

    doAddContainerItem(bp1, 2168, 2)
    doAddContainerItem(bp1, 2214, 2)
    doAddContainerItem(bp1, 2197, 2)
    doAddContainerItem(bp1, 2167, 2)
    doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    else -- If storage is used...
    doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")
    end

    return TRUE
    end
    [/lua]

    And is working nice and nice, on the if to the end of the script. And liked it, maybe he is using an old version or dont know. But it worked with me ;S

    I saw that the error he got was cuz the character he put was:

    " ' " and not ".

    '/".

    See it by yours xD

Share This Page