Lua <eof> ?

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

  1. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    Likes Received:
    0
    Best Answers:
    0
    [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:
    158
    Likes Received:
    1
    Best Answers:
    0
    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
    Likes Received:
    0
    Best Answers:
    0
    post script, thanks :S
     
  4. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    Likes Received:
    0
    Best Answers:
    0
    Code (Text):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.      if getPlayerStorageValue(cid, 9002) == -1 then
    4.           setPlayerStorageValue(cid, 9002, 1)
    5.           local bp1 = doPlayerAddItem(cid, 1991, 1)
    6.                 doAddContainerItem(bp1, 2168, 2)
    7.                 doAddContainerItem(bp1, 2214, 2)
    8.                 doAddContainerItem(bp1, 2197, 2)
    9.                 doAddContainerItem(bp1, 2167, 2)           
    10.         end                
    11.           doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    12.      end
    13.      return TRUE
    14.      end
    15. end
    16.  
     
  5. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    ;o

    here it is fixed:

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

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    Likes Received:
    0
    Best Answers:
    0
    not fixed, same error using ur script
     
  7. nsanee

    nsanee Member

    Joined:
    Apr 13, 2008
    Messages:
    662
    Likes Received:
    16
    Best Answers:
    0
    Code (Lua):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.     if getPlayerStorageValue(cid, 9002) == -1 then
    4.         setPlayerStorageValue(cid, 9002, 1)
    5.         local bp1 = doPlayerAddItem(cid, 1991, 1)
    6.         doAddContainerItem(bp1, 2168, 2)
    7.         doAddContainerItem(bp1, 2214, 2)
    8.         doAddContainerItem(bp1, 2197, 2)
    9.         doAddContainerItem(bp1, 2167, 2)            
    10.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    11.     end
    12.     return TRUE
    13. end
    14.  
     
  8. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Yay i forgot i didnt pasted the right script xD!

    Remember that always an IF ends with Ends.

    As;

    Code (Text):
    1.  
    2. Function...
    3.  
    4.  If...
    5.  
    6.  Else...
    7.  
    8.  End..
    9.  Return...
    10.  
    11.  End..
    12.  
    13.  
    And you got 3 ends without "EOF".

    ;)

    As nsanee posted
    Code (Text):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3. if getPlayerStorageValue(cid, 9002) == -1 then
    4. setPlayerStorageValue(cid, 9002, 1)
    5. local bp1 = doPlayerAddItem(cid, 1991, 1)
    6. doAddContainerItem(bp1, 2168, 2)
    7. doAddContainerItem(bp1, 2214, 2)
    8. doAddContainerItem(bp1, 2197, 2)
    9. doAddContainerItem(bp1, 2167, 2)
    10.  
    11. doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    12. end
    13. return TRUE
    14.  
    15. end
    16.  
     
  9. Delirium

    Delirium OTLand veteran & ex mod Premium User

    Joined:
    May 28, 2007
    Messages:
    3,255
    Likes Received:
    115
    Best Answers:
    0
    Never seen a more horrible tabbing but anyway:
    Code (Lua):
    1. function onUse(cid, item, fromPosition, itemEx, toPosition)
    2.     if getPlayerStorageValue(cid, 9002) == -1 then
    3.         setPlayerStorageValue(cid, 9002, 1)
    4.         local bp1 = doPlayerAddItem(cid, 1991, 1)
    5.        
    6.         doAddContainerItem(bp1, 2168, 2)
    7.         doAddContainerItem(bp1, 2214, 2)
    8.         doAddContainerItem(bp1, 2197, 2)
    9.         doAddContainerItem(bp1, 2167, 2)           
    10.     end
    11.      
    12.     doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    13.     return TRUE
    14. end
    Improved version:
    Code (Lua):
    1. local items = {
    2.     2168,
    3.     2214,
    4.     2197,
    5.     2167
    6. }
    7.  
    8. function onUse(cid, item, fromPosition, itemEx, toPosition)
    9.     if getPlayerStorageValue(cid, 9002) == -1 then
    10.         setPlayerStorageValue(cid, 9002, 1)
    11.         local bp1 = doPlayerAddItem(cid, 1991, 1)
    12.  
    13.         for i = 0, #items do
    14.             doAddContainerItem(bp1, items[i], 2)
    15.         end
    16.        
    17.     end                            
    18.     doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    19.     return TRUE
    20. end
    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
    Likes Received:
    0
    Best Answers:
    0
    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:
    158
    Likes Received:
    1
    Best Answers:
    0
    Code (Lua):
    1.  
    2.   function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.         if getPlayerStorageValue(cid, 9002) == -1 then --If storage is right...
    4.                 setPlayerStorageValue(cid, 9002, 1) -- This will do
    5.                 local bp1 = doPlayerAddItem(cid, 1991, 1)
    6.                
    7.                 doAddContainerItem(bp1, 2168, 2)
    8.                 doAddContainerItem(bp1, 2214, 2)
    9.                 doAddContainerItem(bp1, 2197, 2)
    10.                 doAddContainerItem(bp1, 2167, 2)  
    11.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    12.         else -- If storage is used...
    13.         doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")                    
    14.         end    
    15.          
    16.         return TRUE
    17. end
    18.  
    Also remember the architecture;

    Code (Lua):
    1.  
    2. Function... --Start function
    3.  
    4.  If... --Start condition
    5.  
    6.   Else... --If condition is false or 0 or nil respecting the code...
    7.   --Condition when condition If is false or wrong
    8.  End... --This close the IF
    9.  
    10.  Return... --Return to the main
    11.  
    12. End... --Closes the funcion
    13.  
     
  12. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    Likes Received:
    0
    Best Answers:
    0
    fixed it, working now
     
  13. Gattaca

    Gattaca OTLand's Developer

    Joined:
    Mar 13, 2009
    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Hmm it worked for me and looks fine;

    Code (Lua):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.         if getPlayerStorageValue(cid, 9002) == -1 then --If storage is right...
    4.                 setPlayerStorageValue(cid, 9002, 1) -- This will do
    5.                 local bp1 = doPlayerAddItem(cid, 1991, 1)
    6.                
    7.                 doAddContainerItem(bp1, 2168, 2)
    8.                 doAddContainerItem(bp1, 2214, 2)
    9.                 doAddContainerItem(bp1, 2197, 2)
    10.                 doAddContainerItem(bp1, 2167, 2)  
    11.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    12.         else -- If storage is used...
    13.         doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")                    
    14.         end    
    15.          
    16.         return TRUE
    17. end
    18.  
    [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
    Likes Received:
    0
    Best Answers:
    0
    just tested it and it doesnt say you already recieved...
    just opens the chest

    Code (Lua):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.      if getPlayerStorageValue(cid, 9002) == -1 then
    4.           setPlayerStorageValue(cid, 9002, 1)
    5.           local bp1 = doPlayerAddItem(cid, 1991, 1)
    6.                 doAddContainerItem(bp1, 2168, 1)
    7.                 doAddContainerItem(bp1, 2214, 1)
    8.                 doAddContainerItem(bp1, 2197, 1)
    9.                 doAddContainerItem(bp1, 2167, 1)
    10.                 doAddContainerItem(bp1, 2168, 1)
    11.                 doAddContainerItem(bp1, 2214, 1)
    12.                 doAddContainerItem(bp1, 2197, 1)
    13.                 doAddContainerItem(bp1, 2167, 1)                                             
    14.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    15.     else -- If storage is used...
    16.         doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")                    
    17.         end    
    18.          
    19.         return TRUE
    20. end

    [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 OTLand veteran & ex mod Premium User

    Joined:
    May 28, 2007
    Messages:
    3,255
    Likes Received:
    115
    Best Answers:
    0
    Code (Lua):
    1. function onUse(cid, item, fromPosition, itemEx, toPosition)
    2.     if getPlayerStorageValue(cid, 9002) == -1 then
    3.         setPlayerStorageValue(cid, 9002, 1)
    4.         local bp1 = doPlayerAddItem(cid, 1991, 1)
    5.  
    6.         doAddContainerItem(bp1, 2168, 2)
    7.         doAddContainerItem(bp1, 2214, 2)
    8.         doAddContainerItem(bp1, 2197, 2)
    9.         doAddContainerItem(bp1, 2167, 2)
    10.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    11.     else
    12.         doPlayerSendCancel(cid, 'This chest is empty.')
    13.     end
    14.     return TRUE
    15. end
    And it's doPlayerSendTextMessage not doPlayerSendtextMessage
     
  16. Triggah

    Triggah TrigCore

    Joined:
    Aug 1, 2007
    Messages:
    434
    Likes Received:
    0
    Best Answers:
    0
    ty nikolas, it works
     
  17. Delirium

    Delirium OTLand veteran & ex mod Premium User

    Joined:
    May 28, 2007
    Messages:
    3,255
    Likes Received:
    115
    Best Answers:
    0
    You can also use this version, it's more advanced and more organized:
    Code (Lua):
    1. local items = {
    2.         2168,
    3.         2214,
    4.         2197,
    5.         2167,
    6.     2168,
    7.     2214,
    8.     2197,
    9.     2167
    10. }
    11.  
    12. function onUse(cid, item, fromPosition, itemEx, toPosition)
    13.     if getPlayerStorageValue(cid, 9002) == -1 then
    14.         setPlayerStorageValue(cid, 9002, 1)    
    15.         local bp1 = doPlayerAddItem(cid, 1991, 1)
    16.  
    17.         for i = 0, #items do
    18.             doAddContainerItem(bp1, items[i], 2)
    19.         end
    20.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    21.     else
    22.         doPlayerSendCancel(cid, 'This chest is empty.')
    23.     end
    24.  
    25.     return TRUE
    26. end
    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:
    158
    Likes Received:
    1
    Best Answers:
    0
    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 OTLand veteran & ex mod Premium User

    Joined:
    May 28, 2007
    Messages:
    3,255
    Likes Received:
    115
    Best Answers:
    0
    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:
    158
    Likes Received:
    1
    Best Answers:
    0
    Hmm i really dont know.

    But this is the code i used to;
    Code (Lua):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.         if getPlayerStorageValue(cid, 9002) == -1 then --If storage is right...
    4.                 setPlayerStorageValue(cid, 9002, 1) -- This will do
    5.                 local bp1 = doPlayerAddItem(cid, 1991, 1)
    6.                
    7.                 doAddContainerItem(bp1, 2168, 2)
    8.                 doAddContainerItem(bp1, 2214, 2)
    9.                 doAddContainerItem(bp1, 2197, 2)
    10.                 doAddContainerItem(bp1, 2167, 2)  
    11.         doPlayerSendTextMessage(cid, 24, "You found a bag of supplies.")
    12.         else -- If storage is used...
    13.         doPlayerSendtextMessage(cid, 22, "You already received a bag of supplies.")                    
    14.         end    
    15.          
    16.         return TRUE
    17. end
    18.  
    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

Loading...