MOD perfect Svargrond Arena System!

Discussion in 'Mods & Lua Functions' started by TomCrusher, Jan 20, 2010.

  1. TomCrusher

    TomCrusher Jeg er ingenting

    Joined:
    Dec 31, 2008
    Messages:
    655
    Likes Received:
    15
    Best Answers:
    0
    Being tired about all of complaining not acting arena Svargrond script's I was created MOD for running on the TFS 0.3.5pl1, TFS above it should work! So installing:
    Create into MOD folder file called arena.xml and set into this script:
    PHP:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <mod name="Arena Svargrond"
    3.  
    4. version="1.0" author="Tommy" contact="[email protected]" enabled="yes">
    5.  
    6. <config name="arenaFunctions"><![CDATA[
    7. KickPosition = {x=1273, y=881, z=6} --if the player leave the arena or time is over, where he go.
    8. RewardsRoom = {x=1255, y=831, z=6} --rewards room position.
    9. arenaRoomMaxTime = 240 --max time for each room 240 = 4 min.
    10. OpenDoorsID = 5127 --if you change doors item ids, change me =D
    11.  
    12.  
    13. TimeStor = 42350 --here will be saved the time.
    14. myArenaLevel = 45450 --here will be saved the arena level.
    15. talkNPC = 45451 --Storage to check if the player have paid to the npc and can enter to the arena.
    16. RewardsStor = {42361, 42371, 42381} --Storage for greenshore, scrapper, warlord.
    17. isIN = 42352 --to check if the player is in the arena.
    18. myRoom = 46000 --here will be saved the current room.
    19. MonStor = 47000 --here will be saved the monster uid.
    20.  
    21.  
    22. DoorsActID = 42357 --Doors near the npc.
    23. LeavePortals = 42321 --The action id of the portal to leave the rooms (south portals).
    24. GobletTiles = {42360, 42370, 42380} --Action ids of the tiles for Bronze, Silver and Gold Goblets.
    25.  
    26. Cancel = {
    27.     --message when use door and have not paid to the npc.
    28.     [1] = "You have not paid NPC yet.",
    29.     --message when leave arena.
    30.     [2] = "You have been kicked.!",
    31.     --message when the player can't get the reward.
    32.     [3] = "You can\'t get this item",
    33.     --message when already got any reward.
    34.     [4] = "It is empty.",
    35.     --when try to open a reward door and haven't completed the level.
    36.     [5] = "You have not finished this arena level.",
    37.     --NPC answer if the player completed all arena levels.
    38.     [6] = "You already did all the arena levels.",
    39.     --message when time is over
    40.     [7] = "The time is over.",
    41.     --message when you can go to the next room, LoL >_> this is not a cancel btw.
    42.     [8] = "You can go to the next room.",
    43.     --when try to go to the next room and not killed the monster yet.
    44.     [9] = "Kill the monster first",
    45.     --when try to go to the next room but there is a player yet...this text will be PLAYERNAME + this text
    46.     [10] = "is in the room yet."
    47.     }
    48.  
    49. Completed = {
    50.     [1] = "Congatulations! you have completed the arena in",
    51.     --HERE WILL BE THE ARENA NAME.
    52.     [2] = "difficulty!, now go and take your reward."}
    53.     --then the message will be "Congatulations! you have completed the arena in greenshore/scrapper/warlord difficulty!, now go and take your reward."
    54.    
    55.  
    56. Arena = {
    57.     --greenshore
    58.     [0] = {
    59.         Cost = 10000,
    60.         LevelName = 'greenshore',
    61.         LevelNeeded = 30,
    62.         Goblet = 5807
    63.         },
    64.     --scrapper
    65.     [1] = {
    66.         Cost = 50000,
    67.         LevelName = 'scrapper',
    68.         LevelNeeded = 50,
    69.         Goblet = 5806
    70.         },
    71.     --warlord
    72.     [2] = {
    73.         Cost = 100000,
    74.         LevelName = 'warlord', 
    75.         LevelNeeded = 80,
    76.         Goblet = 5805
    77.         }
    78.     }
    79.  
    80.  
    81. Rewards = {
    82.     --greenshore
    83.     --present with items.
    84.     [42361] = {
    85.         Stor = RewardsStor[1],
    86.         Cont = 1990,
    87.         items = {7372, 6569, 6574, 2114},
    88.         count = {1, 10, 1, 1}
    89.         },
    90.     --blacksteel sword.
    91.     [42362] = {
    92.         Stor = RewardsStor[1],
    93.         Cont = nil,
    94.         item = 7406
    95.         },
    96.     --headchopper.
    97.     [42363] = {
    98.         Stor = RewardsStor[1],
    99.         Cont = nil,
    100.         item = 7380
    101.         },
    102.     --orcish maul.
    103.     [42364] = {
    104.         Stor = RewardsStor[1],
    105.         Cont = nil,
    106.         item = 7392
    107.         },
    108.     --backpack with items.
    109.     [42365] = {
    110.         Stor = RewardsStor[1],
    111.         Cont = 7342,
    112.         items = {7365, 7364},
    113.         count = {100, 100}
    114.         },
    115.     --scrapper
    116.     --present with items.
    117.     [42371] = {
    118.         Stor = RewardsStor[2],
    119.         Cont = 1990,
    120.         items = {7372, 6569, 6574, 7183},
    121.         count = {1, 10, 1, 1}
    122.         },
    123.     --mystic blade.
    124.     [42372] = {
    125.         Stor = RewardsStor[2],
    126.         Cont = nil,
    127.         item = 7384
    128.         },
    129.     --heroic axe.
    130.     [42373] = {
    131.         Stor = RewardsStor[2],
    132.         Cont = nil,
    133.         item = 7389
    134.         },
    135.     --cranial basher
    136.     [42374] = {
    137.         Stor = RewardsStor[2],
    138.         Cont = nil,
    139.         item = 7415
    140.         },
    141.     --backpack with items.
    142.     [42375] = {
    143.         Stor = RewardsStor[2],
    144.         Cont = 7342,
    145.         items = {7365, 2547, 2547, 2311, 2304},
    146.         count = {100, 100, 100, 50, 50}
    147.         },
    148.     --warlord
    149.     --present with items.
    150.     [42381] = {
    151.         Stor = RewardsStor[3],
    152.         Cont = 1990,
    153.         items = {7372, 6569, 6574, 6568},
    154.         count = {1, 10, 1, 1}
    155.         },
    156.     --justice seeker
    157.     [42382] = {
    158.         Stor = RewardsStor[3],
    159.         Cont = nil,
    160.         item = 7390
    161.         },
    162.     --royal axe.
    163.     [42383] = {
    164.         Stor = RewardsStor[3],
    165.         Cont = nil,
    166.         item = 7434
    167.         },
    168.     --blessed sceptre.
    169.     [42384] = {
    170.         Stor = RewardsStor[3],
    171.         Cont = nil,
    172.         item = 7429
    173.         },
    174.     --backpack with items.
    175.     [42385] = {
    176.         Stor = RewardsStor[3],
    177.         Cont = 7342,
    178.         items = {2273, 2268, 7443, 7440, 7529},
    179.         count = {50, 50, 1, 1, 100}
    180.         }
    181.     }
    182.  
    183. arena_monsters = {
    184.     --greenshore                            -scrapper                           --warlord
    185.     [45300] = "Frostfur",               [45310] = "Avalanche",          [45320] = "Webster",
    186.     [45301] = "Bloodpaw",               [45311] = "Kreebosh the Exile", [45321] = "Darakan the Executioner",
    187.     [45302] = "Bovinus",                [45312] = "The Dark Dancer",    [45322] = "Norgle Glacierbeard",
    188.     [45303] = "Achad",                  [45313] = "The Hag",            [45323] = "The Pit Lord",
    189.     [45304] = "Colerian The Barbarian", [45314] = "Slim",               [45324] = "Svoren the Mad",
    190.     [45305] = "The Hairy One",          [45315] = "Grimgor Guteater",   [45325] = "The Masked Marauder",
    191.     [45306] = "Axeitus Headbanger",     [45316] = "Drasilla",           [45326] = "Gnorre Chyllson",
    192.     [45307] = "Rocky",                  [45317] = "Spirit of Earth",    [45327] = "Fallen Mooh'tah Master Ghar",
    193.     [45308] = "Cursed Gladiator",       [45318] = "Spirit of Water",    [45328] = "Deathbringer",
    194.     [45309] = "Orcus the Cruel",        [45319] = "Spirit of Fire",     [45329] = "The Obliverator"}
    195.  
    196. Checking = false
    197.  
    198. RoomsACT = {42301, 42302, 42303, 42304, 42305, 42306, 42307, 42308, 42309}
    199.  
    200. Goblets = {
    201.     [42360] = {Id=Arena[0].Goblet, txt="It is given to the courageous victor of the barbarian arena "..Arena[0].LevelName.." difficulty."},
    202.     [42370] = {Id=Arena[1].Goblet, txt="It is given to the courageous victor of the barbarian arena "..Arena[1].LevelName.." difficulty."},
    203.     [42380] = {Id=Arena[2].Goblet, txt="It is given to the courageous victor of the barbarian arena "..Arena[2].LevelName.." difficulty."}}
    204.  
    205. RewardsDoors = {[42366] = 1, [42376] = 2, [42386] = 3}
    206.  
    207. ArenaAdding = {[0] = 3000, [1] = 3010, [2] = 3020}
    208.  
    209. function myArenaLevelIs(cid)
    210.     Stor = getPlayerStorageValue(cid, myArenaLevel)
    211.     if Stor == -1 then
    212.         setPlayerStorageValue(cid, myArenaLevel, 0)
    213.         Stor = 0
    214.     elseif Stor == 3 then Stor = 2
    215.     end
    216.     return {
    217.         RC = Arena[Stor].Cost,
    218.         LN = Arena[Stor].LevelName,
    219.         RLV = Arena[Stor].LevelNeeded,
    220.         LV = getPlayerStorageValue(cid, myArenaLevel)
    221.     }
    222. end
    223.  
    224. function getDirectionMove(cid, itempos)
    225.     --function by Nahruto
    226.     p = getCreaturePosition(cid)
    227.     i = itempos
    228.     if p.x > i.x then
    229.         if p.y > i.y then
    230.             ret = NORTHWEST
    231.         elseif p.y < i.y then
    232.             ret = SOUTHWEST
    233.         else
    234.             ret = WEST
    235.         end
    236.     elseif p.x < i.x then
    237.         if p.y > i.y then
    238.             ret = NORTHEAST
    239.         elseif p.y < i.y then
    240.             ret = SOUTHEAST
    241.         else
    242.             ret = EAST
    243.         end
    244.     else
    245.         if p.y > i.y then
    246.             ret = NORTH
    247.         elseif p.y < i.y then
    248.             ret = SOUTH
    249.         else
    250.             ret = nil
    251.         end
    252.     end
    253.     return ret
    254. end
    255.  
    256. function LeaveArena(cid)
    257.     for i = 45300, 45329 do
    258.         setPlayerStorageValue(cid, i, 0)
    259.     end
    260.     if isCreature(getPlayerStorageValue(cid, MonStor)) == TRUE then
    261.         doRemoveCreature(getPlayerStorageValue(cid, MonStor))
    262.     end
    263.     setGlobalStorageValue(getPlayerStorageValue(cid, myRoom), 0)
    264.     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, Cancel[2])
    265.     doTeleportThing(cid, KickPosition, FALSE)
    266.     setPlayerStorageValue(cid, TimeStor, 0)
    267.     setPlayerStorageValue(cid, isIN, 0)
    268. end
    269.  
    270. function CheckRooms()
    271.     addEvent(CheckRooms, 1000)
    272.     for i = 42300, 42309 do
    273.         local Player = getGlobalStorageValue(i)
    274.         if isPlayer(Player) == TRUE then
    275.             local PlayerTime = getPlayerStorageValue(Player, TimeStor)
    276.             if PlayerTime <= os.time() then
    277.                 doTeleportThing(Player, KickPosition, FALSE)
    278.                 setPlayerStorageValue(Player, TimeStor, 0)
    279.                 setGlobalStorageValue(i, 0)
    280.                 doPlayerSendTextMessage(Player,MESSAGE_STATUS_CONSOLE_ORANGE, Cancel[7])
    281.                 if isCreature(getPlayerStorageValue(Player, MonStor)) == TRUE then
    282.                     doRemoveCreature(getPlayerStorageValue(Player, MonStor))
    283.                 end
    284.             elseif PlayerTime - 10 <= os.time() then
    285.                 doPlayerSendTextMessage(Player, MESSAGE_EVENT_DEFAULT, "you have "..PlayerTime - os.time().." seconds left.!")
    286.             end
    287.         else
    288.             setGlobalStorageValue(i, 0)
    289.         end
    290.     end
    291. end
    292.  
    293. function getArenaMonsterIdByName(name)
    294.     for i = 45300, 45329 do
    295.         if tostring(arena_monsters[i]) == string.lower(tostring(name)) then
    296.             return i
    297.         end
    298.     end
    299.     return false
    300. end]]></config>
    301.         <event type="login" name="arenaRegister" event="script"><![CDATA[
    302.         domodlib('arenaFunctions')
    303.         function onLogin(cid)
    304.     registerCreatureEvent(cid, "PlayerArena")
    305.     registerCreatureEvent(cid, "ArenaKill")
    306.         return true
    307. end]]></event>
    308.  
    309. <event type="death" name="PlayerArena" event="script"><![CDATA[
    310.     domodlib('arenaFunctions')
    311.     function onDeath(cid, corpse, deathList)
    312.         if getPlayerStorageValue(cid, isIN) == 1 then
    313.             I = 0        
    314.             for i = 45300, 45329 do
    315.                 if getPlayerStorageValue(cid, i) == 1 then
    316.                     I = i
    317.                 end
    318.             end
    319.             GlobalStor = I - ArenaAdding[myArenaLevelIs(cid).LV]
    320.             setGlobalStorageValue(GlobalStor, 0)
    321.             setPlayerStorageValue(cid, isIN, 0)
    322.             if isCreature(getPlayerStorageValue(cid, MonStor)) then
    323.                 doRemoveCreature(getPlayerStorageValue(cid, MonStor))
    324.             end
    325.         end
    326.         return true
    327.     end
    328. ]]></event>
    329.  
    330.         <event type="kill" name="ArenaKill" event="script"><![CDATA[
    331.         domodlib('arenaFunctions')
    332. function onKill(cid, target, lastHit)
    333.     if getPlayerStorageValue(cid, isIN) == 1 then
    334.         local Room = getArenaMonsterIdByName(getCreatureName(target))
    335.         if Room ~= 0 then
    336.             setPlayerStorageValue(cid, Room, 1)
    337.             doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, Cancel[8])
    338.         end
    339.        end
    340.         return true
    341. end]]></event>
    342.  
    343.         <action fromaid="42357" toaid="42386" event="script"><![CDATA[
    344.         domodlib('arenaFunctions')
    345. function onUse(cid, item, fromPosition, itemEx, toPosition)
    346.     local myMove = getDirectionMove(cid, fromPosition)
    347.  
    348.     if myMove == nil then
    349.  
    350.         return FALSE
    351.  
    352.     end
    353.  
    354.     local Reward = Rewards[item.actionid]
    355.  
    356.     if Reward then
    357.  
    358.         if getPlayerStorageValue(cid, Reward.Stor) ~= 1 then
    359.  
    360.             local reward = nil
    361.  
    362.             if Reward.Cont ~= nil then
    363.  
    364.                 reward = doCreateItemEx(Reward.Cont, 1)
    365.  
    366.                 for i = 1, #Reward.items do
    367.  
    368.                     doAddContainerItem(reward, Reward.items[i], Reward.count[i])
    369.  
    370.                 end
    371.  
    372.             else
    373.  
    374.                 reward = doCreateItemEx(Reward.item, 1)
    375.  
    376.             end
    377.  
    378.             if reward ~= nil then
    379.  
    380.                 if doPlayerAddItemEx(cid, reward, FALSE) == RETURNVALUE_NOERROR then
    381.  
    382.                     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,'You have found a '..getItemNameById(getThing(reward).itemid)..'.')
    383.  
    384.                     setPlayerStorageValue(cid, Reward.Stor, 1)
    385.  
    386.                                 addPlayerRep(cid, 5, TEXTCOLOR_LIGHTBLUE)
    387.  
    388.                 else
    389.  
    390.                     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, Cancel[3])
    391.  
    392.                 end
    393.  
    394.             end
    395.  
    396.         else
    397.  
    398.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, Cancel[4])
    399.  
    400.         end
    401.  
    402.     elseif RewardsDoors[item.actionid] then
    403.  
    404.         if myArenaLevelIs(cid).LV >= RewardsDoors[item.actionid] then
    405.  
    406.             doTransformItem(item.uid, OpenDoorsID)
    407.  
    408.             doMoveCreature(cid, myMove)
    409.  
    410.         else
    411.  
    412.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, Cancel[5])
    413.  
    414.         end
    415.  
    416.     elseif item.actionid == DoorsActID and getPlayerStorageValue(cid, talkNPC) == 1 then
    417.  
    418.         doTransformItem(item.uid, OpenDoorsID)
    419.  
    420.         doMoveCreature(cid, myMove)
    421.  
    422.     else
    423.  
    424.         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, Cancel[1])
    425. end
    426.  
    427.     return TRUE
    428.  
    429. end]]></action>
    430.  
    431.     <movevent type="StepIn" fromaid="42300" toaid="42380" event="script"><![CDATA[
    432.         domodlib('arenaFunctions')
    433. function onStepIn(cid, item, position, fromPosition)
    434.     local ArenaRoom = item.actionid
    435.  
    436.     if item.actionid == LeavePortals then
    437.  
    438.         LeaveArena(cid)
    439.  
    440.     elseif isInArray(GobletTiles, item.actionid) == TRUE then
    441.  
    442.         local gobletPos = getThingPos(item.uid)
    443.  
    444.         if getPlayerStorageValue(cid, item.actionid) ~= 1 then
    445.  
    446.             setPlayerStorageValue(cid, item.actionid, 1)
    447.  
    448.             local Goblet = doCreateItemEx(Goblets[item.actionid].Id, 1)
    449.  
    450.             doItemSetAttribute(Goblet, "description", ""..Goblets[item.actionid].txt.."\nAwarded to "..getCreatureName(cid)..".")
    451.  
    452.             gobletPos.y = gobletPos.y - 1
    453.  
    454.             doTileAddItemEx(gobletPos, Goblet)
    455.  
    456.         end
    457.  
    458.         doTransformItem(item.uid, item.itemid - 1)
    459.  
    460.     elseif isInArray(RoomsACT, ArenaRoom) == TRUE or ArenaRoom == 42300 then
    461.  
    462.         if Checking == FALSE then Checking = TRUE CheckRooms() end
    463.  
    464.         local myLevelArena = myArenaLevelIs(cid).LV
    465.  
    466.         if ArenaAdding[myLevelArena] then
    467.  
    468.             Mons = ArenaRoom + ArenaAdding[myLevelArena]
    469.  
    470.         end
    471.  
    472.         if getGlobalStorageValue(ArenaRoom) == 0 then
    473.  
    474.             if isCreature(getPlayerStorageValue(cid, MonStor)) == FALSE then
    475.  
    476.                 if ArenaRoom == 42300 and getPlayerStorageValue(cid, talkNPC) == 1 then
    477.  
    478.                     setPlayerStorageValue(cid, talkNPC, 0)
    479.  
    480.                     setPlayerStorageValue(cid, isIN, 1)
    481.  
    482.                     P = 1
    483.  
    484.                 elseif ArenaRoom ~= 42300 and getPlayerStorageValue(cid, isIN) == 1 then
    485.  
    486.                     P = 1
    487.  
    488.                 else
    489.  
    490.                     P = nil
    491.  
    492.                 end    
    493.  
    494.                 if P ~= nil then
    495.  
    496.                     local SpawnPos = getThingPos(ArenaRoom)
    497.  
    498.                     doTeleportThing(cid, SpawnPos, FALSE)
    499.  
    500.                     SpawnPos.x = SpawnPos.x - 1
    501.  
    502.                     SpawnPos.y = SpawnPos.y - 1
    503.  
    504.                     local Monster = doSummonCreature(arena_monsters[Mons], SpawnPos)
    505.  
    506.                     setGlobalStorageValue(ArenaRoom, cid)
    507.  
    508.                     setGlobalStorageValue(ArenaRoom - 1, 0)
    509.  
    510.                     setPlayerStorageValue(cid, TimeStor, os.time()+arenaRoomMaxTime)
    511.  
    512.                     setPlayerStorageValue(cid, MonStor, Monster)
    513.  
    514.                     setPlayerStorageValue(cid, myRoom, ArenaRoom)
    515.  
    516.                 else
    517.  
    518.                     LeaveArena(cid)
    519.  
    520.                 end
    521.  
    522.             else
    523.  
    524.                 doTeleportThing(cid, fromPosition, TRUE)
    525.  
    526.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, Cancel[9])
    527.  
    528.             end
    529.  
    530.         else
    531.  
    532.             doTeleportThing(cid, fromPosition, TRUE)
    533.  
    534.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..getCreatureName(getGlobalStorageValue(cid, ArenaRoom)).." "..Cancel[10].."")
    535.  
    536.         end
    537.  
    538.     elseif ArenaRoom == 42310 then
    539.  
    540.         if isCreature(getPlayerStorageValue(cid, MonStor)) == FALSE then
    541.  
    542.             doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,""..Completed[1].." "..myArenaLevelIs(cid).LN.." "..Completed[2].."")
    543.  
    544.             setPlayerStorageValue(cid, myArenaLevel, getPlayerStorageValue(cid, myArenaLevel) + 1)
    545.  
    546.             setGlobalStorageValue(ArenaRoom - 1, 0)
    547.  
    548.             setPlayerStorageValue(cid, TimeStor, 0)
    549.  
    550.             setPlayerStorageValue(cid, isIN, 0)
    551.  
    552.             doTeleportThing(cid, RewardsRoom, TRUE)
    553.  
    554.         else
    555.  
    556.             doTeleportThing(cid, fromPosition, TRUE)
    557.  
    558.             doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,'Najpierw zabij potwora!')
    559.  
    560.         end
    561.  
    562.     end
    563.  
    564.     return TRUE
    565.  
    566. end]]></movevent>
    567.  
    568.     <movevent type="StepOut" fromaid="42357" toaid="42387" event="script"><![CDATA[
    569.         domodlib('arenaFunctions')
    570. function onStepOut(cid, item, position, fromPosition)
    571.  
    572.     if item.actionid == DoorsActID or RewardsDoors[item.actionid] then
    573.  
    574.         doTransformItem(item.uid, item.itemid - 2)
    575.  
    576.     elseif isInArray(GobletTiles, item.actionid) == TRUE then
    577.  
    578.         doTransformItem(item.uid, item.itemid + 1)
    579.         end
    580.  
    581.     return TRUE
    582.  
    583. end]]></movevent>
    584.  
    585. </mod>
    do reload MOD's and of course change your positions on the map into "arenaFunctions"!!!
    If not work do restart a server, please and remove all old arena script's. :p

    Do you need NPC? Than:
    PHP:
    1. <npc name="Halvar" script="data/npc/scripts/arena.lua" floorchange="0" access="5" level="1" maglevel="1">
    2.     <health now="150" max="150"/>
    3.     <look type="129" head="114" body="119" legs="114" feet="114" corpse="2212"/>
    4. <parameters>
    5. <parameter key="message_greet" value="Hello |PLAYERNAME|. Im leader of the Svargrond Arena." />
    6. </parameters>
    7. </npc>
    and arena.lua :
    PHP:
    1.         domodlib('arenaFunctions')
    2. local keywordHandler = KeywordHandler:new()
    3. local npcHandler = NpcHandler:new(keywordHandler)
    4. NpcSystem.parseParameters(npcHandler)
    5. local talkState = {}
    6.  
    7. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
    8. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
    9. function onCreatureSay(cid, type, msg)          npcHandler:onCreatureSay(cid, type, msg)        end
    10. function onThink()                  npcHandler:onThink()                    end
    11. local focus = 0
    12.  
    13. local talk_start = 0
    14.  
    15. local TS = 0
    16.  
    17.  
    18.  
    19. function onCreatureDisappear(cid, pos)
    20.  
    21.     if focus == cid then
    22.  
    23.         selfSay('Good bye then.')
    24.  
    25.         focus = 0
    26.  
    27.         talk_start = 0
    28.  
    29.     end
    30.  
    31.  
    32.  
    33.  
    34. local function BYE()
    35.  
    36.     focus = 0
    37.  
    38.     talk_start = 0
    39.  
    40.     TS = 0
    41.  
    42.  
    43.  
    44.  
    45. function msgcontains(txt, str)
    46.  
    47.     return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
    48.  
    49.  
    50.  
    51.  
    52. function onCreatureSay(cid, type, msg)
    53.  
    54.  
    55.  
    56.     msg = string.lower(msg)
    57.  
    58.     if (msgcontains(msg, 'hi') and (focus == 0)) then
    59.  
    60.         selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')
    61.  
    62.         focus = cid
    63.  
    64.         talk_start = os.clock()
    65.  
    66.         TS = 1
    67.  
    68.     elseif msgcontains(msg, 'hi') and (focus ~= cid) then
    69.  
    70.         selfSay('Im Bussy')
    71.  
    72.     elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then
    73.  
    74.         if getPlayerStorageValue(cid, myArenaLevel) < 3 then
    75.  
    76.             local enterArena = myArenaLevelIs(cid)
    77.  
    78.             if getPlayerLevel(cid) >= enterArena.RLV then
    79.  
    80.                 if getPlayerMoney(cid) >= enterArena.RC then
    81.  
    82.                     setPlayerStorageValue(cid, talkNPC, 1)
    83.  
    84.                     doPlayerRemoveMoney(cid, enterArena.RC)
    85.  
    86.                     selfSay("Now you can go to test... ".. enterArena.LN .."")
    87.  
    88.                     BYE()
    89.  
    90.                 else
    91.  
    92.                     selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")
    93.  
    94.                     BYE()
    95.  
    96.                 end
    97.  
    98.             else
    99.  
    100.                 selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")
    101.  
    102.                 BYE()
    103.  
    104.             end
    105.  
    106.         else
    107.  
    108.             selfSay(Cancel[6])
    109.  
    110.             BYE()
    111.  
    112.         end
    113.  
    114.     elseif TS == 1 and msgcontains(msg, 'no') then
    115.  
    116.         selfSay("Bye!.")
    117.  
    118.         BYE()
    119.  
    120.     elseif msgcontains(msg, 'bye') then
    121.  
    122.         selfSay("Bye!.")
    123.  
    124.         BYE()
    125.  
    126.     end
    127.  
    128.     return true
    129.  
    130.  
    131.  
    132.  
    133. function onThink()
    134.  
    135.     doNpcSetCreatureFocus(focus)
    136.  
    137.     if (os.clock() - talk_start) > 60 then
    138.  
    139.         if focus > 0 then
    140.  
    141.             selfSay('Good bye then.')
    142.  
    143.         end
    144.  
    145.         focus = 0
    146.  
    147.     end
    148.  
    149. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    150. npcHandler:addModule(FocusModule:new())
    Searching map than go to link:Svargrond Arena

    Special thanks to Nahruto for a idea and functions!

    I hope you will like and appreciate my work REP + acceptable!
     
    Last edited: Mar 14, 2010
    BeniS and Dankoo like this.
  2. barker

    barker HHHHH

    Joined:
    Nov 23, 2007
    Messages:
    1,298
    Likes Received:
    29
    Best Answers:
    0
    Really good mate =) I like it
     
  3. zkum

    zkum corruption

    Joined:
    May 9, 2009
    Messages:
    2,300
    Likes Received:
    52
    Best Answers:
    0
    looks sexy.. nice release!
     
  4. Khanio

    Khanio [XHTML/CSS]

    Joined:
    May 4, 2009
    Messages:
    512
    Likes Received:
    3
    Best Answers:
    0
    Nice release. Where should i config the monsters spawn positions
     
  5. TomCrusher

    TomCrusher Jeg er ingenting

    Joined:
    Dec 31, 2008
    Messages:
    655
    Likes Received:
    15
    Best Answers:
    0
    As old release mark center of room with this actionid's to each room from first to last:
    PHP:
    1. RoomsACT = {42301, 42302, 42303, 42304, 42305, 42306, 42307, 42308, 42309}
    all informations you can find into script..
     
    Last edited: Jan 21, 2010
  6. Hermes

    Hermes dziwki kola gramy w lola

    Joined:
    Nov 17, 2007
    Messages:
    1,867
    Likes Received:
    13
    Best Answers:
    0
    Script could be 3 times shorter. For example, why you are using:
    Code (Text):
    1. Cont = nil,
    when you can check if it's there, and if so, use it (if cont then)

    etc. You can make it in this way (little example with operations on array):
    Code (Text):
    1. local t = {
    2.     [storage1] = {items = {2160, 10}},
    3.     [storage2] = {items = {2160, 10, 2640, 1}, container = 1988}
    4. }
    5. local g = t[getPlayerStorageValue(cid, storage)]
    6. if t then
    7.     if t[getPlayerStorageValue(cid, storage)].container then
    8.         local c, y = doPlayerAddItem(cid, 1988, 1), 1
    9.         while y < #g.items do
    10.             --don't remember exact name of the function
    11.             doPlayerAddContainerItem(c, g.items[i], g.items[i+1])
    12.             i = i + 2
    13.         end
    14.     else
    15.         doPlayerAddItem(cid, g.items[1], g.items[2])
    16.     end
    17. end
    It makes difference :p
     
  7. Snow

    Snow Member

    Joined:
    Jan 16, 2008
    Messages:
    381
    Likes Received:
    0
    Best Answers:
    0
    post it shorter plax!!!
     
  8. Hermes

    Hermes dziwki kola gramy w lola

    Joined:
    Nov 17, 2007
    Messages:
    1,867
    Likes Received:
    13
    Best Answers:
    0
    Well, it would take some time. Let's give TomCrusher a chance to extend his scripting abilities :)
     
  9. TomCrusher

    TomCrusher Jeg er ingenting

    Joined:
    Dec 31, 2008
    Messages:
    655
    Likes Received:
    15
    Best Answers:
    0
    I have no free time just now to rewrite scripts made six months ago, but I will take your comments Hermes to my education...
    About included
    PHP:
    1. addPlayerRep(cid, 5, TEXTCOLOR_LIGHTBLUE)
    this is function to reputation system if somebody will know:p
     
    Last edited: Jan 21, 2010
    Kudzu likes this.
  10. Grehy

    Grehy Killroy

    Joined:
    Nov 21, 2008
    Messages:
    2,626
    Likes Received:
    32
    Best Answers:
    0
    What about the NPC?
     
    Snakie likes this.
  11. Kiman

    Kiman Reality OT Staff

    Joined:
    Aug 18, 2009
    Messages:
    518
    Likes Received:
    2
    Best Answers:
    0
    Thanks for this :)
     
  12. TomCrusher

    TomCrusher Jeg er ingenting

    Joined:
    Dec 31, 2008
    Messages:
    655
    Likes Received:
    15
    Best Answers:
    0
    As you wish, you welcome:
    PHP:
    1. <npc name="Halvar" script="data/npc/scripts/arena.lua" floorchange="0" access="5" level="1" maglevel="1">
    2.     <health now="150" max="150"/>
    3.     <look type="129" head="114" body="119" legs="114" feet="114" corpse="2212"/>
    4. <parameters>
    5. <parameter key="message_greet" value="Hello |PLAYERNAME|. Im leader of the Svargrond Arena." />
    6. </parameters>
    7. </npc>
    and arena.lua :
    PHP:
    1. local focus = 0
    2. local talk_start = 0
    3. local TS = 0
    4.  
    5. function onCreatureDisappear(cid, pos)
    6.     if focus == cid then
    7.         selfSay('Good bye then.')
    8.         focus = 0
    9.         talk_start = 0
    10.     end
    11.  
    12. local function BYE()
    13.     focus = 0
    14.     talk_start = 0
    15.     TS = 0
    16.  
    17. function msgcontains(txt, str)
    18.     return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
    19.  
    20. function onCreatureSay(cid, type, msg)
    21.  
    22.     msg = string.lower(msg)
    23.     if (msgcontains(msg, 'hi') and (focus == 0)) then
    24.         selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')
    25.         focus = cid
    26.         talk_start = os.clock()
    27.         TS = 1
    28.     elseif msgcontains(msg, 'hi') and (focus ~= cid) then
    29.         selfSay('Im Bussy')
    30.     elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then
    31.         if getPlayerStorageValue(cid, myArenaLevel) < 3 then
    32.             local enterArena = myArenaLevelIs(cid)
    33.             if getPlayerLevel(cid) >= enterArena.RLV then
    34.                 if getPlayerMoney(cid) >= enterArena.RC then
    35.                     setPlayerStorageValue(cid, talkNPC, 1)
    36.                     doPlayerRemoveMoney(cid, enterArena.RC)
    37.                     selfSay("Now you can go to test... ".. enterArena.LN .."")
    38.                     BYE()
    39.                 else
    40.                     selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")
    41.                     BYE()
    42.                 end
    43.             else
    44.                 selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")
    45.                 BYE()
    46.             end
    47.         else
    48.             selfSay(Cancel[6])
    49.             BYE()
    50.         end
    51.     elseif TS == 1 and msgcontains(msg, 'no') then
    52.         selfSay("Bye!.")
    53.         BYE()
    54.     elseif msgcontains(msg, 'bye') then
    55.         selfSay("Bye!.")
    56.         BYE()
    57.     end
    58.     return true
    59.  
    60. function onThink()
    61.     doNpcSetCreatureFocus(focus)
    62.     if (os.clock() - talk_start) > 60 then
    63.         if focus > 0 then
    64.             selfSay('Good bye then.')
    65.         end
    66.         focus = 0
    67.     end
    I'm only forget it:$
     
  13. Grehy

    Grehy Killroy

    Joined:
    Nov 21, 2008
    Messages:
    2,626
    Likes Received:
    32
    Best Answers:
    0
    Thanks, thats all that was missing. Great job, rep++
     
  14. Xal

    Xal New Member

    Joined:
    Jul 28, 2009
    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    It work on TFS 0.3.6 ?
     
  15. TomCrusher

    TomCrusher Jeg er ingenting

    Joined:
    Dec 31, 2008
    Messages:
    655
    Likes Received:
    15
    Best Answers:
    0
    Should work I have TFS above it and work... take test it!
     
  16. Meferot

    Meferot New Member

    Joined:
    Jan 28, 2008
    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    NPC don't working.
     
  17. Helga

    Helga GZH

    Joined:
    Feb 19, 2009
    Messages:
    622
    Likes Received:
    3
    Best Answers:
    0
    thanks :) working fine, but you need to fix this bug:
    Code (Text):
    1. <movement type="StepIn" fromaid="42300" toaid="42370" event ="script">
    it should be toaid="42380", else the golden goblet tile wont work ;P

    And the NPC-script arena.lua doesn't work, use this instead:
    Code (Text):
    1. local keywordHandler = KeywordHandler:new()
    2. local npcHandler = NpcHandler:new(keywordHandler)
    3. NpcSystem.parseParameters(npcHandler)
    4.  
    5. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
    6. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
    7. function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
    8. function onThink()                          npcHandler:onThink()                        end
    9.  
    10. function enterArena(cid, message, keywords, parameters, node)
    11.     if(not npcHandler:isFocused(cid)) then
    12.         return false
    13.     end
    14.     local cost = 0
    15.     local levelname = ''
    16.     if getPlayerStorageValue(cid, 45450) < 1 then
    17.         cost = 1000
    18.         levelname = 'greenshore'
    19.         levelneeded = 30
    20.     elseif getPlayerStorageValue(cid, 45450) == 1 then
    21.         cost = 5000
    22.         levelname = 'scrapper'
    23.         levelneeded = 50
    24.     elseif getPlayerStorageValue(cid, 45450) == 2 then
    25.         cost = 10000
    26.         levelname = 'warlord'
    27.         levelneeded = 80
    28.     end
    29.     if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
    30.         if(getPlayerLevel(cid) >= levelneeded) then
    31.             if(getPlayerMoney(cid) >= cost) then
    32.                 doPlayerRemoveMoney(cid, cost)
    33.                 npcHandler:say('Now you can go to test.', cid)
    34.                 setPlayerStorageValue(cid, 45451, 1)
    35.             else
    36.                 npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
    37.             end
    38.         else
    39.             npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
    40.         end
    41.         npcHandler:resetNpc()
    42.     elseif string.lower(keywords[1]) == 'no' then
    43.         npcHandler:say('Come back later then!', cid)
    44.         npcHandler:resetNpc()
    45.     else
    46.         if getPlayerStorageValue(cid, 45450) < 3 then
    47.             npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp and have ' .. levelneeded .. ' level. Wanna try?', cid)
    48.         else
    49.             npcHandler:say('You did all arena levels.',cid)
    50.         end
    51.     end
    52.     return true
    53. end
    54.  
    55. npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Do you want to make arena?')
    56.  
    57. local yesNode = KeywordNode:new({'yes'}, enterArena, {})
    58. local noNode = KeywordNode:new({'no'}, enterArena, {})
    59.  
    60. local node1 = keywordHandler:addKeyword({'arena'}, enterArena, {prepare=1})
    61.     node1:addChildKeywordNode(yesNode)
    62.     node1:addChildKeywordNode(noNode)
    63.    
    64. local node1 = keywordHandler:addKeyword({'fight'}, enterArena, {prepare=1})
    65.     node1:addChildKeywordNode(yesNode)
    66.     node1:addChildKeywordNode(noNode)
    67. local node1 = keywordHandler:addKeyword({'yes'}, enterArena, {prepare=1})
    68.     node1:addChildKeywordNode(yesNode)
    69.     node1:addChildKeywordNode(noNode)
    70. npcHandler:addModule(FocusModule:new())
     
    Last edited: Jan 24, 2010
  18. Kiman

    Kiman Reality OT Staff

    Joined:
    Aug 18, 2009
    Messages:
    518
    Likes Received:
    2
    Best Answers:
    0
    I got a problem with this script. When someone dies in a room with a monster inside, the monster is still there, So If someone else enters. He'll face two monsters.

    Is it just me, or is someone else having this bug ?
     
  19. Helga

    Helga GZH

    Joined:
    Feb 19, 2009
    Messages:
    622
    Likes Received:
    3
    Best Answers:
    0
    Having the same bug, trying to solve it atm ;P
     
  20. Kiman

    Kiman Reality OT Staff

    Joined:
    Aug 18, 2009
    Messages:
    518
    Likes Received:
    2
    Best Answers:
    0
    Be sure to post the solution :)
     

Share This Page

Loading...