Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- We need a custom DB to store the data in:
- -- Columns:
- -- CreatureID (Primary Key) // Handles the ID of the creature for that guild which is killed --
- -- Power (Not NULL) (Default 0) // Stores the 'power' the guild has --
- -- GuildID (Not NULL) (Default 0) // Stores the real guild ID --
- ]]
- -- The name of the custom table we create within the Character DB
- local TableName = "Guild_Power_Store"
- function Guild_Leader_Death(pUnit, Event)
- -- Get the ID of the creature killed
- local entry = pUnit:GetEntry()
- -- Now to return the person who dealt the killing blow in Lua is hard
- -- We could search through all the players within say, 100 yards, and then use the faction with the most members
- -- Or we could use my 'hack fix' which is just... The closest player.
- local player = pUnit:GetClosestPlayer()
- if player ~= nil -- you never know
- -- Award the guild who won
- local guild = player:GetGuildId()
- if guild ~= nil then
- CharDBQuery("UPDATE `"..TableName.."` SET `power` = power + 20 WHERE `GuildID` = '"..tostring(guild).."';")
- end
- -- Make the guild who lost lose points
- CharDBQuery("UPDATE `"..TableName.."` SET `power` = power - 15 WHERE `CreatureID` = '"..entry.."';")
- end
- end
- -- Get the creature ID's we need to register
- local data = CharDBQuery("SELECT `CreatureID` FROM `"..TableName.."`;")
- -- For the amount of guilds found
- while (data:NextRow()) do
- -- Register the unit for a on death event
- -- Just get the string value then cast it to a number, since I don't know the method to directly get a integer
- RegisterUnitEvent(tonumber(data:GetColumn(0):GetString()), 4, "Guild_Leader_Death")
- end
Advertisement
Add Comment
Please, Sign In to add comment