Advertisement
Guest User

ToP - PlayerRebirth Function

a guest
Aug 7th, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.35 KB | None | 0 0
  1. function PlayerRebirth(Player, Level, Class)
  2.     local PlayerName = GetChaDefaultName(Player)
  3.     LG("Player Rebirth", "")
  4.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Starting Rebirth.")
  5.     local RB_Var = {}
  6.     RB_Var.Class = {}
  7.     RB_Var.Class[8] = 455
  8.     RB_Var.Class[9] = 453
  9.     RB_Var.Class[12] = 456
  10.     RB_Var.Class[13] = 458
  11.     RB_Var.Class[14] = 457
  12.     RB_Var.Class[16] = 454
  13.     local CharType = GetChaTypeID(Player)
  14.     -- Checking in they have their equipment off.
  15.     if IsEquip(Player) == LUA_TRUE then
  16.         SystemNotice(Player, "You must remove your equipment.")
  17.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Equipment OFF = FALSE.")
  18.         return 0    
  19.     end
  20.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Equipment OFF = TRUE")
  21.     -- Checking if their inventory is not locked.
  22.     if KitbagLock(Player, 0) ~= LUA_TRUE then
  23.         SystemNotice(Player, "Your inventory must be unlocked.")
  24.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Inventory Locked = TRUE")
  25.         return 0
  26.     end
  27.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Inventory Locked = FALSE")
  28.     -- Checking if they have at least 5 free inventory slots.
  29.     if GetChaFreeBagGridNum(Player) < 5 then
  30.         SystemNotice(Player, "You must have 5 slots free for Rebirth.")
  31.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Free Inventory Slots = FALSE")
  32.         return 0
  33.     end
  34.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Free Inventory Slots = TRUE")
  35.     -- Lets see if they meet the character type for their desired class.
  36.     if Class == 8 then
  37.         if CharType ~= 2 then
  38.             SystemNotice(Player, "Only Carsise can become Champion.")
  39.             return 0
  40.         end
  41.     elseif Class == 9 then
  42.         if CharType ~= 1 then
  43.             SystemNotice(Player, "Only Lance can become Crusader.")
  44.             return 0
  45.         end
  46.     elseif Class == 12 then
  47.         if CharType == 2 or CharType == 4 then
  48.             SystemnNotice(Player, "Only Lance and Phyllis can become Sharpshooter.")
  49.             return 0
  50.         end
  51.     elseif Class == 13 then
  52.         if CharType == 1 or CharType == 2 then
  53.             SystemnNotice(Player, "Only Ami and Phyllis can become Cleric.")
  54.             return 0
  55.         end
  56.     elseif Class == 14 then
  57.         if CharType == 1 or CharType == 2 then
  58.             SystemnNotice(Player, "Only Ami and Phyllis can become Seal Master.")
  59.             return 0
  60.         end
  61.     elseif Class == 16 then
  62.         if CharType == 2 then
  63.             SystemNotice(Player, "Only Lance, Phyllis and Ami can become Voyager.")
  64.             return 0
  65.         end
  66.     end
  67.     -- Lets see more specific requirements.
  68.     if Level == 1 then
  69.         if GetChaAttr(Player, ATTR_CSAILEXP) ~= 0 then
  70.             SystemNotice(Player, "You are already have done Rebirth.")
  71.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Before = TRUE")
  72.             return 0
  73.         end
  74.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Before = FALSE")
  75.         if CheckBagItem(Player, 2235) < 1 then
  76.             SystemNotice(Player, "You do not have Rebirth Stone.")
  77.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone = FALSE")
  78.             return 0
  79.         end
  80.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone = TRUE")
  81.         if TakeItem(Player, 0, 2235, 1) == 0 then
  82.             SystemNotice(Player, "Failed to remove Rebirth Stone, please check again.")
  83.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone Taken = FALSE")
  84.             return 0
  85.         end
  86.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone Taken = TRUE")
  87.     elseif Level == 2 then
  88.         if GetChaAttr(Player, ATTR_CSAILEXP) < 9500 then
  89.             SystemNotice(Player, "You need at least 9500 SEXP to do Second Rebirth.")
  90.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Low SEXP = TRUE")
  91.             return 0
  92.         end
  93.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Low SEXP = FALSE")
  94.         if GetChaAttr(Player, ATTR_CSAILEXP) >= 10000 then
  95.             SystemNotice(Player, "You already have done Second Rebirth.")
  96.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: High SEXP = TRUE")
  97.             return 0
  98.         end
  99.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: High SEXP = FALSE")
  100.         if CheckBagItem(Player, 5765) < 1 then
  101.             SystemNotice(Player, "You do not have Rebirth Stone.")
  102.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone = FALSE")
  103.             return 0
  104.         end
  105.         if CharType == 1 then
  106.             if CheckBagItem(Player, 134) == 0 then
  107.                 SystemNotice(Player, "You do not have Rebirth Wings in your inventory.")
  108.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = FALSE")
  109.                 return 0
  110.             end
  111.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = TRUE")
  112.             if TakeItem(Player, 0, 134, 1) == 0 then
  113.                 SystemNotice(Player, "Failed to remove Rebirth Wings, please check again.")
  114.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = FALSE")
  115.                 return 0
  116.             end
  117.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = TRUE")
  118.         elseif CharType == 2 then
  119.             if CheckBagItem(Player, 138) == 0 then
  120.                 SystemNotice(Player, "You do not have Rebirth Wings in your inventory.")
  121.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = FALSE")
  122.                 return 0
  123.             end
  124.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = TRUE")
  125.             if TakeItem(Player, 0, 138, 1) == 0 then
  126.                 SystemNotice(Player, "Failed to remove Rebirth Wings, please check again.")
  127.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = FALSE")
  128.                 return 0
  129.             end
  130.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = TRUE")
  131.         elseif CharType == 3 then
  132.             if CheckBagItem(Player, 128) == 0 then
  133.                 SystemNotice(Player, "You do not have Rebirth Wings in your inventory.")
  134.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = FALSE")
  135.                 return 0
  136.             end
  137.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = TRUE")
  138.             if TakeItem(Player, 0, 128, 1) == 0 then
  139.                 SystemNotice(Player, "Failed to remove Rebirth Wings, please check again.")
  140.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = FALSE")
  141.                 return 0
  142.             end
  143.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = TRUE")
  144.         elseif CharType == 4 then
  145.             if CheckBagItem(Player, 131) == 0 then
  146.                 SystemNotice(Player, "You do not have Rebirth Wings in your inventory.")
  147.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = FALSE")
  148.                 return 0
  149.             end
  150.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings = TRUE")
  151.             if TakeItem(Player, 0, 131, 1) == 0 then
  152.                 SystemNotice(Player, "Failed to remove Rebirth Wings, please check again.")
  153.                 LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = FALSE")
  154.                 return 0
  155.             end
  156.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Taken = TRUE")
  157.         end
  158.         if TakeItem(Player, 0, 5765, 1) == 0 then
  159.             SystemNotice(Player, "Failed to remove Rebirth Stone, please check again.")
  160.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone Taken = FALSE")
  161.             return 0
  162.         end
  163.         LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Stone Taken = FALSE")
  164.     end
  165.     local SK_POINTS = {}
  166.     SK_POINTS[0] = GetChaAttr(Player, ATTR_TP)
  167.     for i = 540, 542, 1 do
  168.         SK_POINTS[i] = 0
  169.         if GetSkillLv(Player, i) == 1 then
  170.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Custom Skill Taken = "..i)
  171.             SK_POINTS[0] = SK_POINTS[0] - 1
  172.             SK_POINTS[i] = 1
  173.         end
  174.     end
  175.     SK_POINTS[0] = SK_POINTS[0] + ClearFightSkill(Player)
  176.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Skill Point Reset = TRUE")
  177.     for k = 540, 542, 1 do
  178.         if SK_POINTS[k] == 1 then
  179.             AddChaSkill(Player, k, 1, 1, 0)
  180.             LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Custom Skill Added = "..k)
  181.         end
  182.     end
  183.     SetChaAttr(Player, ATTR_TP, SK_POINTS[0])
  184.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Skill Points Assigned = TRUE")
  185.     local STATS = (GetChaAttr(Player, ATTR_AP) + GetChaAttr(Player, ATTR_BSTR) + GetChaAttr(Player, ATTR_BDEX) + GetChaAttr(Player, ATTR_BAGI) + GetChaAttr(Player, ATTR_BCON) + GetChaAttr(Player, ATTR_BSTA)) - 25
  186.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Attribute Points = "..(STATS+25))
  187.     SetChaAttr(Player, ATTR_BSTR, 5)
  188.     SyncChar(Player, 4)
  189.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Strength Attribute Reset = TRUE ")
  190.     SetChaAttr(Player, ATTR_BDEX, 5) 
  191.     SyncChar(Player, 4)
  192.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Accuracy Attribute Reset = TRUE")
  193.     SetChaAttr(Player, ATTR_BAGI, 5) 
  194.     SyncChar(Player, 4)
  195.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Agility Attribute Reset = TRUE")
  196.     SetChaAttr(Player, ATTR_BCON, 5) 
  197.     SyncChar(Player, 4)
  198.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Constitution Attribute Reset = TRUE")
  199.     SetChaAttr(Player, ATTR_BSTA, 5) 
  200.     SyncChar(Player, 4)
  201.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Spirit Attribute Reset = TRUE")
  202.     SetChaAttr(Player, ATTR_AP, STATS)
  203.     SyncChar(Player, 4)
  204.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Attribute Points Left = "..STATS)
  205.     SetChaAttr(Player, ATTR_JOB, Class)
  206.     RefreshCha(Player)
  207.     if Level == 1 then
  208.         AddChaSkill(Player, 459, 1, 1, 0)
  209.         AddChaSkill(Player, RB_Var.Class[Class], 1, 1, 0)
  210.         if CharType == 1 then
  211.             GiveItem(Player, 0, 134, 1, 4)
  212.         elseif CharType == 2 then
  213.             GiveItem(Player, 0, 138, 1, 4)
  214.         elseif CharType == 3 then
  215.             GiveItem(Player, 0, 128, 1, 4)
  216.         elseif CharType == 4 then
  217.             GiveItem(Player, 0, 131, 1, 4)
  218.         end
  219.         SetChaAttr(Player, ATTR_CSAILEXP, 1)
  220.         ScrollNotice("Extreme celebration, "..PlayerName.." has done Phoenix Rebirth successful. Blessing from the whole server! "..PlayerName.." hope you have a safe journey and everything goes your way!", 1)
  221.     elseif Level == 2 then
  222.         AddChaSkill(Player, 459, 2, 2, 0)
  223.         AddChaSkill(Player, RB_Var.Class[Class], 2, 2, 0)
  224.         if CharType == 1 then
  225.             GiveItem(Player, 0, 135, 1, 4)
  226.         elseif CharType == 2 then
  227.             GiveItem(Player, 0, 139, 1, 4)
  228.         elseif CharType == 3 then
  229.             GiveItem(Player, 0, 129, 1, 4)
  230.         elseif CharType == 4 then
  231.             GiveItem(Player, 0, 132, 1, 4)
  232.         end
  233.         SetChaAttr(Player, ATTR_CSAILEXP, 10000)
  234.         ScrollNotice("Extreme celebration, "..PlayerName.." has done Second Rebirth successful. Blessing from the whole server! "..PlayerName.." hope you have a safe journey and everything goes your way!", 1)
  235.     end
  236.     RefreshCha(Player)
  237.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Passive Rebirth Skill Added = TRUE")
  238.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Active Rebirth Skill Added = TRUE")
  239.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Wings Added = TRUE")
  240.     LG("Player Rebirth", "["..PlayerName.."]["..Level.."]["..Class.."]: Rebirth Successful.")
  241.     LG("Player Rebirth", "")
  242.     return 1
  243. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement