Hi Guys
Quest:
PHP Code:
----------------------------------------------------------
--- Character Swap System
--- HaveBeen™ - NRY WORK
--- www.elitepvpers.com
----------------------------------------------------------
quest swap begin
state start begin
function load_settings()
local data = {
{}
}
data.Settings = {activate = 1,get_time = 86400,minimum_level = 50, maximum_level = 105,Use_To_GM = false}
return data
end
function swap(sname,name)
local find = find_pc_by_name(sname)
local old = pc.select(find)
local id = pc.get_account_id()
pc.select(old)
local data = swap.load_settings()
local s = mysql_query("select * from account.account where id = '"..id.."'")
local m = mysql_query("select * from account.account where id = '"..pc.get_account_id().."'")
data.Sname = {accountname = s.login[1],password = s.password[1]}
data.My = {accountname = m.login[1],password = m.password[1]}
mysql_query("update from account.account password = '"..data.Sname.password.."' where id = '"..pc.get_account_id().."'")
mysql_query("update from account.account password = '"..data.My.password.."' where id = '"..id.."' ")
local x = pc.select(find)
say_title("Information:")
say("")
---
say("Accountname: "..data.My.accountname)
say("")
say_reward("Your password is same.")
say_reward("Thanks. Good day!")
pc.setqf("time",get_global_time())
command("quit")
pc.select(x)
say_title("Information:")
say("")
---
say("Accountname: "..data.Sname.accountname)
say("")
say_reward("Your password is same.")
say_reward("Thanks. Good day!")
pc.setqf("time",get_global_time())
command("quit")
end
when 9006.chat."Character Swap" begin
say_title(mob_name(npc.get_race())..":")
say("")
---
local data = swap.load_settings()
if(pc.is_gm() and data.Settings.Use_To_GM == false) then
say_reward("You don't use to this system.")
return
elseif(data.Settings.get_time > get_global_time() - pc.getqf("time")) then
say_reward("Unfortunately you can't swap characters.")
say_reward("")
return
elseif(not pc.get_level() > data.Settings.minimum_level and not pc.get_level() <= data.Settings.maximum_level) then
say_reward("You can't swap characters.")
say_reward("Level isn't enough / "..data.Settings.maximum_level.." levels is higher for.")
return
end
say("Enter name of your character swap.")
say("")
local sname = input()
local find = find_pc_by_name(sname)
say_title(mob_name(npc.get_race())..":")
say("")
--
if(sname == "" or tostring(sname) == nil) then
say_reward("You need to write a name.")
say_reward("If you don't , you can't swap characters.")
elseif(find == 0) then
say_reward("This person is someone that isn't open or doesn't exists.")
say_reward("")
return
end
say("Please wait while request is being transmitted.")
say("")
local agree = confirm(find,"Do you want to swap with "..pc.name.." character",30)
say_title(mob_name(npc.get_race())..":")
say("")
--
if(agree != CONFIRM_OK) then
say(sname.." didn't accept your request.")
say("")
return
end
swap.swap(sname,pc.name)
end
end
end
PHP Code:
function split(str, delim, maxNb)
if str == nil then return str end
if string.find(str, delim) == nil then return { str } end
if maxNb == nil or maxNb < 1 then maxNb = 0 end
local result = {}
local pat = "(.-)" .. delim .. "()"
local nb = 0
local lastPos
for part, pos in string.gfind(str, pat) do
nb = nb + 1
result[nb] = part
lastPos = pos
if nb == maxNb then break end
end
if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end
return result
end
mysql_query = function(query)
local rt = io.open('CONFIG','r'):read('*all')
local pre= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
math.randomseed(os.time())
local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi)
for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
out[i-1] = out[i-1] or {}
out[i-1][a] = b
out[t[1][a]] = out[t[1][a]] or {}
out[t[1][a]][i-1] = b
end) end
return out
end
Mfg HaveBeen™
King Regards