Likes: 0
Results 1 to 5 of 5
Thread: [Lua]World First Kill
-
13-03-10, 08:41 AM #1
[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(pUnit, BossName,TxTFile) --[[Write down in the file you defined]]
AnnounceWorldFirst(pUnit, BossName) --[[Announce it to the world that the boss was killed]]
end
end
function UnitWorldFirst(pUnit, BossName, TxTFile) --[[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(pUnit, BossName)
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
We can use this Lua script this way
PHP Code:function On_HardBossDie(pUnit, Event)
WorldCheck(pUnit,"Hard Boss", "WorldFirstKillHardBoss.Txt")
end
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,BossName, TxTFile)
if io.open(TxTFile, "r") == nil and type(pUnit) == "userdata" and type(BossName) == "string" and type(TxTFile) == "string" then
UnitWorldFirst(pUnit, BossName,TxTFile)
AnnounceWorldFirst(pUnit, BossName)
end
end
function UnitWorldFirst(pUnit, BossName, TxTFile)
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(pUnit, BossName)
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
-
13-03-10, 10:17 AM #2
Never seen this one yet, so good job.
-
13-03-10, 10:34 AM #3
thx for comment
-
13-03-10, 10:48 AM #4
[COLOR="rgb(75, 0, 130)"]Cool, Epic idea [/COLOR]
No touching please.
-
13-03-10, 11:07 AM #5
Register to remove this ad