dofile("scripts/plugins/RPGPlugin/tableapi.lua")
RPG = {}
RPG.Enable = false
function exists(fname)
local f = io.open(fname, "r")
if (f and f:read()) then
io.close(f)
return true end
return false
end
local function enablerpg( Source)
RPG.Enable = true
return "RPG Mod has been enabled", Source.Channel, MESSAGE_NORMAL
end
command.Register("-enablerpg", enablerpg, 500, "Usage: -enablerpg", true)
local function disablerpg( Source)
RPG.Enable = false
return "RPG Mod has been disabled", Source.Channel, MESSAGE_NORMAL
end
command.Register("-disablerpg", disablerpg, 500, "Usage: -disablerpg", true)
local function rpgstatus( Source)
if (RPG.Enable == false) then
return "RPG Mod is not currently running", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
return "RPG Mod is up and running", Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-rpgstatus", rpgstatus, 0, "Usage: -rpgstatus", true)
local function register( Source, Args)
if #Args < 2 or #Args > 2 then return -1,Source.Channel, MESSAGE_NORMAL; end -- returning -1 prints the usage string
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua")) then
return "You are already registered if you want a character wipe contact an admin.", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true)then
local templayer = {}
templayer.items = {}
templayer.spells = {}
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
templayer.name = Args[1]
templayer.lvl = 1
templayer.race = Args[2]
templayer.str = 2
templayer.spd = 2
templayer.mgc = 2
templayer.xp = 0
templayer.coin = 10
templayer.items = {}
templayer.items.hat = 1
templayer.items.gloves = 1
templayer.items.shirt = 1
templayer.items.trousers = 1
templayer.items.shoes = 1
templayer.items.weapon = 1
templayer.items.shield = 1
templayer.items.hppot = 0
templayer.items.mppot = 0
templayer.spells.cure = 0
templayer.spells.enchant = 0
templayer.spells.attack = 0
templayer.sleep = 0
templayer.maxhp = (templayer.str * 8) + 40 + templayer.lvl
templayer.maxmp = (templayer.mgc * 8) + 10 + templayer.lvl
templayer.curhp = (templayer.str * 8) + 40 + templayer.lvl
templayer.curmp = (templayer.mgc * 8) + 10 + templayer.lvl
table.save( templayer, profilename )
return "RPG Mod profile created", Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-register", register, 0, "Usage: -register name race", true)
local function myinfo( Source, Args)
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
local tempstring = "Name: "..templayer.name.." Race: "..templayer.race.." Level: "..templayer.lvl.." XP: "..templayer.xp
return tempstring , Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-myinfo", myinfo, 0, "Usage: -myinfo", true)
local function mystats( Source, Args)
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
local tempstring = "Name: "..templayer.name.." Level: "..templayer.lvl.." Strength: "..templayer.str.." Speed: "..templayer.spd.." Magic: "..templayer.mgc
return tempstring , Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-mystats", mystats, 0, "Usage: -mystats", true)
local function mystatus( Source, Args)
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
local temsleep
if templayer.sleep == 0 then
temsleep = "Awake"
end
if templayer.sleep == 1 then
temsleep = "Sleeping"
end
if templayer.curhp == 0 then
temsleep = "Dead"
end
local tempstring = "Name: "..templayer.name.." HP: "..templayer.curhp.."/"..templayer.maxhp.." MP: "..templayer.curmp.."/"..templayer.maxmp.. " Status: "..temsleep
return tempstring , Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-mystatus", mystatus, 0, "Usage: -mystatus", true)
local function sleep( Source, Args)
if #Args ~= 1 then return -1,Source.Channel, MESSAGE_NORMAL; end -- returning -1 prints the usage string
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
if Args[1] == "1" then
templayer.sleep = 1
table.save( templayer, profilename )
local tempstring = templayer.name.." has gone to sleep and is now unable to battle."
return tempstring , Source.Channel, MESSAGE_NORMAL
end
if Args[1] == "0" then
templayer.sleep = 0
table.save( templayer, profilename )
local tempstring = templayer.name.." is awake and ready for battle."
return tempstring , Source.Channel, MESSAGE_NORMAL
end
if Args[1] ~="1" and Args[1] ~="0" then
return -1,Source.Channel, MESSAGE_NORMAL;
end
end
end
command.Register("-sleep", sleep, 0, "Usage: -sleep 1 or 0", true)
local function pvp( Source, Args)
if #Args ~= 1 then return -1,Source.Channel, MESSAGE_NORMAL; end -- returning -1 prints the usage string
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (exists("scripts/plugins/RPGPlugin/profiles/"..Args[1]..".lua") == false) then
return "Player does not exist or may not be registered please try again", Source.Channel, MESSAGE_NORMAL
end
if (Source.Nick == Args[1] ) then
return "You can't pvp yourself idiot.", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local profilename2 = "scripts/plugins/RPGPlugin/profiles/"..Args[1]..".lua"
local templayer = table.load(profilename)
local templayer2 = table.load(profilename2)
if templayer.sleep == 1 then
return "You are sleeping and can't PVP", Source.Channel, MESSAGE_NORMAL
end
if templayer2.sleep == 1 then
return "That player is sleeping and can't PVP", Source.Channel, MESSAGE_NORMAL
end
if templayer.curhp == 1 then
return "You are dead and can't PVP use a potion to live once again", Source.Channel, MESSAGE_NORMAL
end
if templayer2.curhp == 1 then
return "That player is dead and can't PVP", Source.Channel, MESSAGE_NORMAL
end
local hit
local hitpower
local oldxp
if templayer2.spd > (templayer.spd + math.random(-templayer.spd,templayer.spd)) then
hit = "templayer2"
else
hit = "templayer"
end
if hit == "templayer" then
hitpower = templayer.str * templayer.items.weapon
templayer2.curhp = templayer2.curhp - hitpower
if templayer2.curhp <= 0 then
templayer2.curhp = 0
IRCBot:SendMessage(BotConfig.DefaultChannel, "The Loser has Died!!")
end
local beef = (math.random(0-25)
local beef2 = (math.random(0-10)
if (beef == 22) then
templayer.items.weapon = templayer.items.weapon + math.random (0,3)
IRCBot:SendMessage(BotConfig.DefaultChannel, "Weapon recieved by winner!")
end
if (beef2 == 5) then
templayer.coin = templayer.coin + math.random (0,20)
IRCBot:SendMessage(BotConfig.DefaultChannel, "Coin recieved by winner!")
end
oldxp = templayer.xp
templayer.xp = templayer.xp + (templayer2.lvl + 5)
if templayer.xp >= 100 and oldxp < 100 and templayer.xp < 250 then
templayer.lvl = 2
templayer.str = templayer.str + math.random(0,3)
templayer.spd = templayer.spd + math.random(0,3)
templayer.mgc = templayer.mgc + math.random(0,3)
templayer.maxhp = (templayer.str * 8) + 40 + templayer.lvl
templayer.maxmp = (templayer.mgc * 8) + 10 + templayer.lvl
end
if templayer.xp >= 250 and oldxp < 250 and templayer.xp < 500 then
templayer.lvl = 3
templayer.str = templayer.str + math.random(0,3)
templayer.spd = templayer.spd + math.random(0,3)
templayer.mgc = templayer.mgc + math.random(0,3)
templayer.maxhp = (templayer.str * 8) + 40 + templayer.lvl
templayer.maxmp = (templayer.mgc * 8) + 10 + templayer.lvl
end
if templayer.xp >= 500 and oldxp < 500 and templayer.xp < 1000 then
templayer.lvl = 4
templayer.str = templayer.str + math.random(0,3)
templayer.spd = templayer.spd + math.random(0,3)
templayer.mgc = templayer.mgc + math.random(0,3)
templayer.maxhp = (templayer.str * 8) + 40 + templayer.lvl
templayer.maxmp = (templayer.mgc * 8) + 10 + templayer.lvl
end
if templayer.xp >= 1000 and oldxp < 1000 and templayer.xp < 2000 then
templayer.lvl = 5
templayer.str = templayer.str + math.random(0,3)
templayer.spd = templayer.spd + math.random(0,3)
templayer.mgc = templayer.mgc + math.random(0,3)
templayer.maxhp = (templayer.str * 8) + 40 + templayer.lvl
templayer.maxmp = (templayer.mgc * 8) + 10 + templayer.lvl
end
local stringthing = templayer.name.." hit "..templayer2.name.." for "..hitpower.." damage"
table.save(templayer, profilename)
table.save(templayer2, profilename2)
return stringthing,Source.Channel, MESSAGE_NORMAL;
end
if hit == "templayer2" then
hitpower = templayer2.str * templayer2.items.weapon
templayer.curhp = templayer.curhp - hitpower
if templayer.curhp <= 0 then
templayer.curhp = 0
IRCBot:SendMessage(BotConfig.DefaultChannel, "The Loser has Died!!")
end
local beef = (math.random(0-25)
local beef2 = (math.random(0-10)
if (beef == 22) then
templayer2.items.weapon = templayer2.items.weapon + math.random (0,3)
IRCBot:SendMessage(BotConfig.DefaultChannel, "Weapon recieved by winner!")
end
if (beef2 == 5) then
templayer2.coin = templayer2.coin + math.random (0,20)
IRCBot:SendMessage(BotConfig.DefaultChannel, "Coin recieved by winner!")
end
oldxp = templayer2.xp
templayer2.xp = templayer2.xp + (templayer.lvl + 5)
if templayer2.xp >= 100 and oldxp < 100 and templayer2.xp < 250 then
templayer2.lvl = 2
templayer2.str = templayer2.str + math.random(0,3)
templayer2.spd = templayer2.spd + math.random(0,3)
templayer2.mgc = templayer2.mgc + math.random(0,3)
templayer2.maxhp = (templayer2.str * 8) + 40 + templayer2.lvl
templayer2.maxmp = (templayer2.mgc * 8) + 10 + templayer2.lvl
end
if templayer2.xp >= 250 and oldxp < 250 and templayer2.xp < 500 then
templayer2.lvl = 3
templayer2.str = templayer2.str + math.random(0,3)
templayer2.spd = templayer2.spd + math.random(0,3)
templayer2.mgc = templayer2.mgc + math.random(0,3)
templayer2.maxhp = (templayer2.str * 8) + 40 + templayer2.lvl
templayer2.maxmp = (templayer2.mgc * 8) + 10 + templayer2.lvl
end
if templayer2.xp >= 500 and oldxp < 500 and templayer2.xp < 1000 then
templayer2.lvl = 4
templayer2.str = templayer2.str + math.random(0,3)
templayer2.spd = templayer2.spd + math.random(0,3)
templayer2.mgc = templayer2.mgc + math.random(0,3)
templayer2.maxhp = (templayer2.str * 8) + 40 + templayer2.lvl
templayer2.maxmp = (templayer2.mgc * 8) + 10 + templayer2.lvl
end
if templayer2.xp >= 1000 and oldxp < 1000 and templayer2.xp < 2000 then
templayer2.lvl = 5
templayer2.str = templayer2.str + math.random(0,3)
templayer2.spd = templayer2.spd + math.random(0,3)
templayer2.mgc = templayer2.mgc + math.random(0,3)
templayer2.maxhp = (templayer2.str * 8) + 40 + templayer2.lvl
templayer2.maxmp = (templayer2.mgc * 8) + 10 + templayer2.lvl
end
local stringthing = templayer2.name.." hit "..templayer.name.." for "..hitpower.." damage"
table.save(templayer, profilename)
table.save(templayer2, profilename2)
return stringthing,Source.Channel, MESSAGE_NORMAL;
end
end
end
command.Register("-pvp", pvp, 0, "Usage: -pvp nick", true)
local function hppotion( Source, Args)
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
if templayer.items.hppot == 0 then
return "You have no HP potions, tpye -buy 1, to buy one.", Source.Channel, MESSAGE_NORMAL
end
templayer.items.hppot = templayer.items.hppot - 1
templayer.curhp = templayer.curhp + 50
if templayer.curhp > templayer.maxhp then templayer.curhp = templayer.maxhp end
table.save(templayer, profilename)
return "Your HP has been restored by 50!", Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-hppotion", hppotion, 0, "Usage: -hppotion", true)
local function mppotion( Source, Args)
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
if templayer.items.mppot == 0 then
return "You have no MP potions, tpye -buy 2, to buy one.", Source.Channel, MESSAGE_NORMAL
end
templayer.items.mppot = templayer.items.mppot - 1
templayer.curmp = templayer.curmp + 50
if templayer.curmp > templayer.maxmp then templayer.curmp = templayer.maxmp end
table.save(templayer, profilename)
return "Your MP has been restored by 50!", Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-mppotion", mppotion, 0, "Usage: -mppotion", true)
local function buy( Source, Args)
if #Args ~= 1 then return -1,Source.Channel, MESSAGE_NORMAL; end -- returning -1 prints the usage string
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
if templayer.coin < 5 then
return "You do not have enough coin fight more to earn some.", Source.Channel, MESSAGE_NORMAL
end
if Args[1] == "1" then
templayer.items.hppot = templayer.items.hppot + 1
end
if Args[1] == "2" then
templayer.items.mppot = templayer.items.mppot + 1
end
templayer.coin = templayer.coin - 5
table.save(templayer, profilename)
return "Your potion has been added to your inventory.", Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-buy", buy, 0, "Usage: -buy 1 or 2, 1 is HP 2 is MP", true)
local function inv( Source, Args)
if (exists("scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua") == false) then
return "You are not registered, to register type -register name race", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == false) then
return "RPG Mod is not currently running please try again later", Source.Channel, MESSAGE_NORMAL
end
if (RPG.Enable == true) then
local profilename = "scripts/plugins/RPGPlugin/profiles/"..Source.Nick..".lua"
local templayer = table.load(profilename)
local uberstring = templayer.name.." has: Coin: "..templayer.coin.." HP Pots: "..templayer.items.hppot.." MP Pots: "..templayer.items.mppot.." Sword Lvl: "..templayer.items.weapon
return uberstring, Source.Channel, MESSAGE_NORMAL
end
end
command.Register("-inv", inv, 0, "Usage: -inv", true)