mirror of
https://github.com/araxiaonline/RandomScriptsforAzerothCore.git
synced 2026-06-13 02:22:19 -04:00
Add files via upload
This commit is contained in:
432
Custom_XP.lua
432
Custom_XP.lua
@@ -1,60 +1,400 @@
|
||||
local enabled = true
|
||||
local spawnslist = {2260,14281,14221,2244,2261} -- npcid's
|
||||
local hpmultiplier = 0.85 -- Spawned npc hp will be multiplied by players hp.
|
||||
local despawntime = 25 --seconds before npc despawns
|
||||
local rnumb = false --output rolled number for testing purposes
|
||||
local GMonly = false --.xp works opens for GM
|
||||
|
||||
local function SpawnEnemy(event, player, killed)
|
||||
|
||||
local x = player:GetX()
|
||||
local y = player:GetY()
|
||||
local z = player:GetZ()
|
||||
local o = player:GetO()
|
||||
local map = player:GetMap()
|
||||
local mapID = map:GetMapId()
|
||||
local areaId = map:GetAreaId( x, y, z )
|
||||
local faction = player:GetFaction()
|
||||
local Target = player:GetSelection()
|
||||
local playername = player:GetName()
|
||||
local isDungeon = map:IsDungeon()
|
||||
local playerHP = player:GetMaxHealth()
|
||||
local spawnedCreature
|
||||
|
||||
local xp01 = "xp 0.1"
|
||||
local xp02 = "xp 0.2"
|
||||
local xp03 = "xp 0.3"
|
||||
local xp04 = "xp 0.4"
|
||||
local xp05 = "xp 0.5"
|
||||
local xp06 = "xp 0.6"
|
||||
local xp07 = "xp 0.7"
|
||||
local xp08 = "xp 0.8"
|
||||
local xp09 = "xp 0.9"
|
||||
|
||||
local xp1 = "xp 1"
|
||||
local xp2 = "xp 2"
|
||||
local xp3 = "xp 3"
|
||||
local xp4 = "xp 4"
|
||||
local xp5 = "xp 5"
|
||||
local xp6 = "xp 6"
|
||||
local xp7 = "xp 7"
|
||||
local xp8 = "xp 8"
|
||||
local xp9 = "xp 9"
|
||||
local xp10 = "xp 10"
|
||||
local xpq = "xp ?"
|
||||
local xpd = "xp reset" -- only gm can use, it will wipe all custom xp rates.
|
||||
|
||||
|
||||
|
||||
local XPSQL = [[ CREATE TABLE IF NOT EXISTS Custom_XP ( CharID int(10) unsigned NOT NULL, Rate float unsigned NOT NULL DEFAULT 1) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]
|
||||
WorldDBExecute(XPSQL)
|
||||
|
||||
local function getPlayerCharacterGUID(player)
|
||||
if player ~= nil then
|
||||
query = CharDBQuery(string.format("SELECT guid FROM characters WHERE name='%s'", player:GetName()))
|
||||
end
|
||||
|
||||
if query then
|
||||
local row = query:GetRow()
|
||||
|
||||
return tonumber(row["guid"])
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
local function SKULY(eventid, delay, repeats, player)
|
||||
player:SendBroadcastMessage("|cff3399FF You can change your XP by typing |cff00cc00 .xp 0.1-0.9 |cff3399FF or |cff00cc00 .xp 1-10 |cff3399FF in chat.")
|
||||
player:SendBroadcastMessage("|cff3399FF You can check your current XP rate by typing |cff00cc00 .xp ? |cff3399FF in chat.")
|
||||
end
|
||||
|
||||
local function OnLogin(event, player)
|
||||
local mingmrank = 3
|
||||
local PUID = getPlayerCharacterGUID(player)
|
||||
if (not GMonly and player:GetGMRank() < mingmrank) then
|
||||
player:RegisterEvent(SKULY, 10000, 1, player)
|
||||
end
|
||||
|
||||
local Taunts = {
|
||||
"Hey "..playername.." u r so uglaaaay!!!! LMAO",
|
||||
"Hey "..playername.."! It's game over for you!",
|
||||
"Hey "..playername.." What's up now!?",
|
||||
"Hey "..playername.." Ready when you are!",
|
||||
"Hey "..playername.." You'll get no sympathy from me!",
|
||||
"Victory or Death!!!",
|
||||
""..playername.." is about to cry like a baby.",
|
||||
"Run "..playername.." run!",
|
||||
"Hey "..playername.." whats that on ur head? oh yea my weapon.",
|
||||
"Hey "..playername.." why don't apple jacks taste like apples?"
|
||||
}
|
||||
if (GMonly and player:GetGMRank() >= mingmrank) then
|
||||
player:RegisterEvent(SKULY, 10000, 1, player)
|
||||
end
|
||||
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function GMONLY(player)
|
||||
player:SendBroadcastMessage("|cff5af304Only a GM can use this command.|r")
|
||||
end
|
||||
|
||||
local chosen = spawnslist[math.random(1, #spawnslist)]
|
||||
local healammount = playerHP * hpmultiplier
|
||||
local r = math.random(1,100)
|
||||
local level = player:GetLevel()
|
||||
if r <= 50 and not isDungeon then
|
||||
local EnemyNear = player:GetNearestCreature( 80, chosen )
|
||||
if EnemyNear == nil then
|
||||
spawnedCreature = player:SpawnCreature( chosen, x-5, y, z, o, 3, despawntime )
|
||||
spawnedCreature:SetLevel(level)
|
||||
spawnedCreature:SetMaxHealth(playerHP * hpmultiplier)
|
||||
spawnedCreature:DealHeal( spawnedCreature, 39334, healammount )
|
||||
spawnedCreature:SendUnitSay(Taunts[math.random(1, #Taunts)], 0)
|
||||
spawnedCreature:AttackStart(player)
|
||||
|
||||
local function SetRate(event, player, msg)
|
||||
--local function SetRate(event, player, message, Type, lang)
|
||||
local PUID = getPlayerCharacterGUID(player)
|
||||
if PUID ~= nil then
|
||||
local Q = WorldDBQuery(string.format("SELECT * FROM custom_xp WHERE CharID=%i", PUID))
|
||||
end
|
||||
local mingmrank = 3
|
||||
|
||||
|
||||
if msg == xp01 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.1)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.1x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if rnumb then
|
||||
player:SendBroadcastMessage("|cff3399FF (Randomly Attacked script) number: |cff00cc00"..r.."|cff3399FF")
|
||||
|
||||
|
||||
if msg == xp02 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.2)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.2x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if msg == xp03 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.3)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.3x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp04 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.4)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.4x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if msg == xp05 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.5)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.5x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if msg == xp06 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.6)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.6x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp07 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.7)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.7x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if msg == xp08 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.8)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.8x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp09 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 0.9)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 0.9x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if msg == xp1 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 1)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 1x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp2 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 2)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 2x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp3 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 3)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 3x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp4 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 4)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 4x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp5 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 5)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 5x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp6 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 6)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 6x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp7 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 7)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 7x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp8 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 8)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 8x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp9 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 9)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 9x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xp10 then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
WorldDBExecute(string.format("DELETE FROM custom_xp WHERE CharID = %i", PUID))
|
||||
WorldDBExecute(string.format("INSERT INTO custom_xp VALUES (%i, 10)", PUID))
|
||||
player:SendBroadcastMessage("|cff5af304You changed your XP rate to 10x|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if msg == xpq then
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
|
||||
if Q then
|
||||
local CharID, Rate = Q:GetUInt32(0), Q:GetFloat(1)
|
||||
player:SendBroadcastMessage(string.format("|cff5af304Your XP rate is curently set to %.1f|r", Rate))
|
||||
return false
|
||||
else
|
||||
player:SendBroadcastMessage(string.format("|cff5af304You haven't set a custom rate yet.|r"))
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
if msg == xpd then
|
||||
if (player:GetGMRank() < mingmrank) then
|
||||
GMONLY(player)
|
||||
return false
|
||||
else
|
||||
local XPSQLDEL = [[ DROP TABLE IF EXISTS Custom_XP]]
|
||||
WorldDBExecute(XPSQLDEL)
|
||||
local XPSQL2 = [[ CREATE TABLE IF NOT EXISTS Custom_XP ( CharID int(10) unsigned NOT NULL, Rate float unsigned NOT NULL DEFAULT 1) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]
|
||||
WorldDBExecute(XPSQL2)
|
||||
player:SendBroadcastMessage("|cff5af304You reset XP table|r")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function OnXP(event, player, amount, victim)
|
||||
local PUID = getPlayerCharacterGUID(player)
|
||||
local Q = WorldDBQuery(string.format("SELECT * FROM custom_xp WHERE CharID=%i", PUID))
|
||||
local mingmrank = 3
|
||||
|
||||
|
||||
if Q then
|
||||
local CharID, Rate = Q:GetUInt32(0), Q:GetFloat(1)
|
||||
Rate = tonumber(string.format("%.1f", Rate))
|
||||
|
||||
|
||||
|
||||
if (GMonly and player:GetGMRank() < mingmrank) then
|
||||
return amount
|
||||
end
|
||||
|
||||
if (GMonly and player:GetGMRank() >= mingmrank) then
|
||||
return amount * Rate
|
||||
end
|
||||
|
||||
if (not GMonly) then
|
||||
return amount * Rate
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
return amount
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
if enabled then
|
||||
RegisterPlayerEvent(7, SpawnEnemy)
|
||||
RegisterPlayerEvent(3, OnLogin)
|
||||
RegisterPlayerEvent(12, OnXP)
|
||||
RegisterPlayerEvent(42, SetRate)
|
||||
end
|
||||
Reference in New Issue
Block a user