Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 5 of 5
  1. #1
    Sergeant
    Dr. Fallen's Avatar
    Join Date
    Mar 2010
    Location
    Turkey
    Posts
    74
    Post Thanks / Like
    Rep Power
    15
    Reputation
    64

    [Lua]World First Kill


    Register to remove this ad

    This Lua script will on world first kill of a creature kill write who killed it and how many to a file, and then Announce it to the world that, that boss have now been killed world first.
    This is the Lua
    PHP Code:
    --[[the TxTFile is for so we can Write to a Special file if the boss dies we can't have all bosses have the same worldfirst file because it will only write the first kill of one of the bosses]]
    function WorldCheck(pUnit,BossName, TxTFile) --[[The function we should call]]
        if io.open(TxTFile, "r") == nil and type(pUnit) == "userdata" and type(BossName) == "string" and type(TxTFile) == "string" then --[[Checks if The file exist and if it doesn'
    t then we send the message and writes to the file]]
        
    UnitWorldFirst(pUnitBossName,TxTFile) --[[Write down in the file you defined]]
        
    AnnounceWorldFirst(pUnitBossName) --[[Announce it to the world that the boss was killed]]
        
    end
    end

    function UnitWorldFirst(pUnitBossNameTxTFile) --[[called by WorldCheck]]
    local file io.open(TxTFile"w") --[[Open the file that we will write the names of the players who killed  the boss]]
    file:write("The world first kill of the boss "..BossName.." was made by \n") --[[First line writes that it was the first kill of the boss]]
        for 
    i,v in ipairs(pUnit:GetInRangePlayers()) do --[[loop till we get all players in range]]
        
    file:write("Player number["..i.."] the players name is"..v:GetName()"\n") --[[Writes The number of the player and The name of the player in the file]]
        
    end
    file
    :write("Amount of players in the kill"..#pUnit:GetInRangePlayers()) --[[Writes how many players that was close to the boss when it was killed ]]
    file:flush() --[[saves the file]]
    file:close() --[[close da file!]]
    end

    function AnnounceWorldFirst(pUnitBossName)
        for 
    i,v in ipairs(GetPlayersInWorld()) do --[[Loop all players in world so every one can see it]]
        
    v:SendAreaTriggerMessage(BossName.." have been killed by "..#pUnit:GetInRangePlayers().." players for the first time") --[[sends the message to players online]]
        
    end
    end 
    now how to use it
    We can use this Lua script this way

    PHP Code:
    function On_HardBossDie(pUnitEvent)
    WorldCheck(pUnit,"Hard Boss""WorldFirstKillHardBoss.Txt")
    end 
    Every time the boss dies it will check if the boss have been killed and if it haven't before then it will write all the names of the players that was attacking it and write it to a file and Announce it to the world
    if you have problems reading the commands in the lua script here it is without comments but it is still used the same way without the comments
    PHP Code:
    function WorldCheck(pUnit,BossNameTxTFile
        if 
    io.open(TxTFile"r") == nil and type(pUnit) == "userdata" and type(BossName) == "string" and type(TxTFile) == "string" then 
        UnitWorldFirst
    (pUnitBossName,TxTFile
        
    AnnounceWorldFirst(pUnitBossName
        
    end
    end

    function UnitWorldFirst(pUnitBossNameTxTFile
    local file io.open(TxTFile"w"
    file:write("The world first kill of the boss "..BossName.." was made by \n"
        for 
    i,v in ipairs(pUnit:GetInRangePlayers()) do 
        
    file:write("Player number["..i.."] the players name is"..v:GetName()"\n"
        
    end
    file
    :write("Amount of players in the kill"..#pUnit:GetInRangePlayers()) 
    file:flush()
    file:close()
    end

    function AnnounceWorldFirst(pUnitBossName)
        for 
    i,v in ipairs(pUnit:GetPlayersInWorld()) do 
        
    v:SendAreaTriggerMessage(BossName.." have been killed by "..#pUnit:GetInRangePlayers().." players for the first time") 
        
    end
    end 





    › See More: [Lua]World First Kill



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Banned

    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    652
    Post Thanks / Like
    Rep Power
    0
    Reputation
    103
    Never seen this one yet, so good job.

  4. #3
    Sergeant
    Dr. Fallen's Avatar
    Join Date
    Mar 2010
    Location
    Turkey
    Posts
    74
    Post Thanks / Like
    Rep Power
    15
    Reputation
    64
    thx for comment

  5. #4
    Elite Member
    Dimman's Avatar
    Join Date
    Apr 2009
    Posts
    1,091
    Post Thanks / Like
    Rep Power
    21
    Reputation
    319
    [COLOR="rgb(75, 0, 130)"]Cool, Epic idea [/COLOR]
    No touching please.

  6. #5
    Sergeant
    Dr. Fallen's Avatar
    Join Date
    Mar 2010
    Location
    Turkey
    Posts
    74
    Post Thanks / Like
    Rep Power
    15
    Reputation
    64

    Register to remove this ad
    Quote Originally Posted by «Dimman» View Post
    [COLOR="rgb(75, 0, 130)"]Cool, Epic idea [/COLOR]
    hehe thank you so much for ur comment mate

 

 

Visitors found this page by searching for:

flush function lua arcemu

SEO Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 06:07 PM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org