switch dont work properly ? how to fix it ?

Discussion in 'Support' started by clario, Feb 12, 2018.

  1. clario

    clario New Member

    Joined:
    Feb 4, 2018
    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    i will show by images and scripts !
    First of all i want coffin open by using switch
    i add :
    in the data\actions
    then i add
    in data\actions\scripts\quests
    how its look in game?

    [​IMG]
    Imgur: The magic of the Internet

    OT serv application:

    [​IMG]
    Imgur: The magic of the Internet
     
  2. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
    change

    Code (Text):
    1.  
    2. if item.uid = 2222 and item.itemid ==>1945 then
    3.  
    to

    Code (Text):
    1.  
    2. if getItemAttribute(item, 'aid') == 2222 and item.itemid == 1945 then
    3.  
     
  3. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
    Code (Lua):
    1.  
    2. local switchIds = {
    3.     [1945] = {trans = 1946, coffinId = 7524},
    4.     [1946] = {trans = 1945, coffinId = 7522}
    5. }
    6.  
    7. local coffinPos = {x = 684, y = 858, z = 7, stackpos = 1}
    8.  
    9. function onUse(cid, item, frompos, item2, topos)
    10.     if getItemAttribute(item.uid, 'aid') ~= 2222 then
    11.         return false
    12.     end
    13.  
    14.     local SWITCH = switchIds[item.itemid]
    15.  
    16.     if not SWITCH then
    17.         return false
    18.     end
    19.  
    20.     local COFFIN = getThingFromPos(coffinPos)
    21.  
    22.     if not COFFIN then
    23.         return doPlayerSendCancel(cid, "Could not find coffin.")
    24.     end
    25.  
    26.     doTransformItem(item.uid, SWITCH.trans)
    27.     doTransformItem(COFFIN.uid, SWITCH.coffinId)
    28. return true
    29. end
    30.  
     
    Last edited: Feb 13, 2018
    webtimize likes this.
  4. webtimize

    webtimize ::1/64 Premium User

    Joined:
    Oct 3, 2011
    Messages:
    321
    Likes Received:
    70
    Best Answers:
    4
    It's also worth mentioning that you're using wrong operator in your if-statement (==>)

    > Lua Operators
     
  5. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
    There are so many things wrong I didn't want to get into all of it. Hopefully he will look how I did it figure it all out. The very first thing I would mention is, he shouldn't have removed the levers from their original script with would make it so he didn't have to transform the switch himself everytime.
     
    webtimize likes this.
  6. clario

    clario New Member

    Joined:
    Feb 4, 2018
    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
  7. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
    Did you use my above code?
     
  8. clario

    clario New Member

    Joined:
    Feb 4, 2018
    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    this one
     
  9. webtimize

    webtimize ::1/64 Premium User

    Joined:
    Oct 3, 2011
    Messages:
    321
    Likes Received:
    70
    Best Answers:
    4
    Replace line 6 with
    Code (Lua):
    1. local coffinPos = {x = 684, y = 858, z = 7, stackpos = 1}
     
  10. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
  11. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
    What did I miss i dont see it?


    nvm i see it now. I just copied his positions.
     
    webtimize likes this.
  12. clario

    clario New Member

    Joined:
    Feb 4, 2018
    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
  13. webtimize

    webtimize ::1/64 Premium User

    Joined:
    Oct 3, 2011
    Messages:
    321
    Likes Received:
    70
    Best Answers:
    4
    This has nothing to do with the switch script, however it's an easy fix.
    The message is says; It cannot load house/spawn file. Make sure both these files exist in the `/data/world/` folder.
     
  14. Itutorial

    Itutorial Well-Known Member

    Joined:
    Dec 23, 2014
    Messages:
    1,303
    Likes Received:
    266
    Best Answers:
    22
    It says item not found at the bottom.

    Change

    Code (Text):
    1.  
    2. if getItemAttribute(item, 'aid') ~= 2222 then
    3.         return false
    4.     end
    5.  
    to

    Code (Text):
    1.  
    2. if getItemAttribute(item.uid, 'aid') ~= 2222 then
    3.         return false
    4.     end
    5.  
     
    clario likes this.
  15. clario

    clario New Member

    Joined:
    Feb 4, 2018
    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0

Share This Page

Loading...