CreatureEvent [TFS 1.1] Fast Travel To Unlocked Locations, modalwindow

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by RazorBlade, Apr 4, 2015.

  1. RazorBlade

    RazorBlade Retired Snek

    Joined:
    Nov 7, 2009
    Messages:
    2,027
    Likes Received:
    606
    Best Answers:
    1
    Code (Text):
    1.  
    2. if item.actionid > 37100 and item.actionid < 38000 or item.actionid > 5000 and item.actionid < 5005 then
    3. player:sendLocationWindow()
    4. else
    5. player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You cannot fast travel while in combat.")
    6. end
    7.  
    Might want to remove the else statement entirely, as there is not actually a check for battle in this case.
     
  2. HeberPcL

    HeberPcL [PowerOT.com.br]

    Joined:
    Aug 21, 2007
    Messages:
    1,279
    Likes Received:
    41
    Best Answers:
    0
    Nicee!!
     
  3. BugaS

    BugaS Donżuan

    Joined:
    Mar 12, 2009
    Messages:
    1,205
    Likes Received:
    9
    Best Answers:
    0
    Is it possible for 0.4? Or something similar?
     
  4. RazorBlade

    RazorBlade Retired Snek

    Joined:
    Nov 7, 2009
    Messages:
    2,027
    Likes Received:
    606
    Best Answers:
    1
    No. Modalwindows didn't exist in 0.4. Stop using outdated distros.
     
  5. elnelson

    elnelson Lunaria World developer

    Joined:
    Jun 20, 2009
    Messages:
    265
    Likes Received:
    7
    Best Answers:
    1
    Is there anyway to translate this to tfs 0.4?
     
  6. Static_

    Static_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,657
    Likes Received:
    1,604
    Best Answers:
    265
    no
    modal windows is 10.x client
     
  7. Nekiro

    Nekiro worst coder Support Team

    Joined:
    Sep 7, 2015
    Messages:
    1,646
    Likes Received:
    500
    Best Answers:
    63
    I wish people would finally drop old 0.x tfs :/
     
    hellboy and Static_ like this.
  8. demon088

    demon088 #088 in the Horde

    Joined:
    Jun 17, 2009
    Messages:
    133
    Likes Received:
    10
    Best Answers:
    3
    I don't know why it's not working, it shows locations but when I choose one modalwindow doesn't show sublocations and just closes. I have scripts exactly like your post.
     
  9. ivpz

    ivpz New Member

    Joined:
    Jan 15, 2018
    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Is it possible to use this script without discover?
     
  10. RazorBlade

    RazorBlade Retired Snek

    Joined:
    Nov 7, 2009
    Messages:
    2,027
    Likes Received:
    606
    Best Answers:
    1
    one of two ways
    1. in your talkaction you could add the following code to ensure the player has access to all
    Code (Text):
    1.  
    2. for i = 1, #tlocations do
    3.     if not player:getStorage(tlocations[i].storage) == 1 then
    4.         player:setStorageValue(tlocations[i].storage, 1)
    5.     end
    6.     for j = 1, #tlocations[i].sublocations do
    7.         if not player:getStorageValue(tlocations[i].sublocations[j].storage) == 1 then
    8.             player:setStorageValue(tlocations[i].sublocations[j].storage, 1)
    9.         end
    10.     end
    11. end
    12.  
    13.  
    2. change the sendLocationWindow and sendTravelWindow functions to these:
    Code (Text):
    1.  
    2. function Player:sendLocationWindow()
    3.     local window = ModalWindow(modalId, "Fast Travel", "You can fast travel to any of the below locations.")
    4.     local choices = 0
    5.    
    6.     for i = 1, #tlocations do
    7.         window:addChoice(i, tlocations[i]["name"])
    8.         choices = choices + 1
    9.     end
    10.     if choices > 0 then
    11.         window:addButton(1, "Expand")
    12.         window:setDefaultEnterButton(1)
    13.     end
    14.     window:addButton(2, "Exit")
    15.     window:setDefaultEscapeButton(2)
    16.     window:sendToPlayer(self)
    17.     return true
    18. end
    19.  
    20. function Player:sendTravelWindow(location)
    21.     local window = ModalWindow(modalId + 1, location["name"], "You can fast travel to any of the below locations.")
    22.     local choices = 0
    23.     for i = 1, #location["sublocations"] do
    24.         window:addChoice(i, location["sublocations"][i]["name"])
    25.         choices = choices + 1
    26.     end
    27.     if choices > 0 then
    28.         window:addButton(1, "Travel")
    29.         window:setDefaultEnterButton(1)
    30.     end
    31.     window:addButton(2, "Back")
    32.     window:setDefaultEscapeButton(2)
    33.     window:sendToPlayer(self)
    34.     return true
    35. end
    36.  
    option 2 is the cleaner and faster way of doing it.
     

Share This Page

Loading...