PDA

View Full Version : [JX] Script Sư Đồ by sangpronhat :| Fixed



kinkina2009
18-11-10, 01:47 PM
Share cái này chứ để chả làm gì , cái này lúc trước có 1 số bug nhỏ nhỏ nhưng Fix rồi mà hồi đó cũng gần 1 năm rồi sang nhỉ :o3
Code
sudo_main.lua


--Dj sangpronhat
--Date : 21/11/2009
--He thong su do
--¡ï¡ï¡ï¡ï¡ï¡ï¡ï
----------------------
SU={}
DO={}
Include("\\script\\lib\\taobang.lua")
Include("\\script\\sudo_sn\\dssu.lua")
Include("\\script\\sudo_sn\\dsdo.lua")
Include("\\script\\sudo_sn\\dssudo.lua")
Include("\\script\\global\\Serverlib.lua")
Include("\\Script\\global\\sourcejx49.lua");
--Khoi tao mang
loithoai=
{
"¡ïThu Nhan Do De/add_dt", --1
"¡ïBai Su./bai_su",--2
"¡ïTruy Tim Su Phu./search_s",--3
"¡ïTruy Tim De Tu./search_dt",--4
"¡ïXuat Su./leave_sd",--5
"¡ïPhan Su Do/leave2_sd",--6
"¡ïTinh Hinh Su Do/LEVS",--7
"¡ï¡ï[Hot] Ban Do [Su Do]/hot",--8
"¡ï¡ï[Hot] Kiem Tra Do De/theodoi",--9
"¡ï¡ï[Hot] Tham Gia Su Do Song Hiep/sdsh",--10
"¡ïHo tro de tu/helps",--11
"¡ïTruc Xuat Do De/bo_dt"--12
}
sudothiep = 215 --
daihongbao = 217 --
function main() ---
Msg2Player(su().." "..do_t())
if su()==1 then su_main() return end
if do_t()==1 then do_main() return end
if GetLevel() >= 80 then
Say("<color=green>Tien Su<color>: Voi dang cap cua nguoi co the giup nhung nhan si moi gia nhap giang ho do !!!",5,loithoai[1],loithoai[12],loithoai[4],loithoai[7],"¡ïKet Thuc./OnEx")
else
Say("<color=green>Tien Su<color>: Nguoi muon nhan su phu thi hoi ho co chap nhan nhan nguoi lam de tu khong neu dong y thi moi su phu den gap ta",1,"¡ïKet Thuc./OnEx")
end
end

function su()
if getn(SU) == 0 then
return 0 end
for i=1,getn(SU) do
name=GetName()
if name == SU[i][1] then
return 1
else
return 0
end
end
end
function search_dt()
Say("<color=green> To Su: <color> Chuc Nang nay van chua cap nhat",1,"Ket Thuc./OnEx")
end;

function su_main()
Say("<color=green>Tien Su<color>: Dang cap lam su phu cua nguoi la "..LEVS().." nguoi co y dinh gi nho ta giup",5,loithoai[1],loithoai[4],loithoai[7],loithoai[8],"Trang ke tiep/next1")
end

function next1()
Say("<color=green>Tien Su<color>: Dang cap lam su phu cua nguoi la "..LEVS().." nguoi co y dinh gi nho ta giup",5,loithoai[9],loithoai[10],loithoai[11],loithoai[12],"Ket thuc doi thoai/OnEx")
end

function do_t()
if getn(DO) == 0 then
return 0 end
for i=1,getn(DO) do
for z=2,getn(DO[i]) do
if DO[i][z]==GetName() then
return 1
end
end
end
return 0
end
function search_s()
Say("<color=green>Tien Su<color>: Nguoi muon tim Su Phu <color=red>"..timsu().."<color> phai khong",1,"Ket Thuc./OnEx")
end;

function do_main()
if GetLevel()>=80 then
Say("<color=green>Tien Su<color>: Su phu cua ban la <color=red>"..timsu().."<color>",5,loithoai[3],loithoai[5],loithoai[6],loithoai[11],"¡ïKet Thuc/OnEx")
else
Say("<color=green>Tien Su<color>: Su phu cua ban la <color=red>"..timsu().."<color>",5,loithoai[3],loithoai[6],loithoai[7],loithoai[11],"¡ïKet Thuc/OnEx")
end
end

function OnEx()
Msg2Player("Sever mang ten Jx50 version 1.0")
end

function add_dt()
sdt_count = GetItemCount(sudothiep)
tz = GetTeamSize()
if su()~=1 then
if sdt_count >= 1 then
if tz == 2 then
DelItem(sudothiep)
SU[getn(SU)+1] = {GetName(),1,1,0}
bien = TaoBang(SU,"SU")
LuuBang("script/sudo_sn/dssu.lua",bien)
pl = PlayerIndex
team=GetTeam()
name=GetName()
lev=GetLevel()
do_a=nil
for i=1,GetPlayerCount() do
PlayerIndex = i
if team==GetTeam() then
if name~=GetName() then
if GetLevel()>=lev then
PlayerIndex = pl
Msg2Player("Khong the nhan de tu co lev cao hon")
break
end
if tim_su(GetName())~=1 then
do_a = GetName()
break
else
PlayerIndex = pl
Msg2Player("Nhan vat ban muon nhan lam de tu da bai su !!!")
return
end
end
end
end
Msg2Player(do_a)
PlayerIndex = pl
DO[getn(DO)+1] = {GetName(),do_a}--su, do1
bien = TaoBang(DO,"DO")
LuuBang("script/sudo_sn/dsdo.lua",bien)
Msg2SubWorld("Su phu "..GetName().." nhan de tu "..do_a)
AddGlobalCountNews("Su phu "..GetName().."va Do De"..do_a.." ket bai thanh cong ",1)
else
Say("<color=green>Tien Su<color>: Nguoi hay tao do doi giua nguoi va nguoi can nhan lam de tu ta se giup cho",0)
end
else
Say("<color=green>Tien Su<color>: Hay di tim bi pho su do thiep roi den gap ta !!",0)
end
else
if num_dt() > 5 then Say("To So: Ban dang nhan vuot qua so de tu quy dinh",0) return end
if sdt_count >= 1 then
DelItem(sudothiep)
if tz == 2 then
pl = PlayerIndex
team=GetTeam()
name=GetName()
lev=GetLevel()
do_a=nil
for i=1,GetPlayerCount() do
PlayerIndex = i
if team==GetTeam() then
if name~=GetName() then
if GetLevel()>=lev then Msg2Player("Khong the nhan de tu co level cao hon") break end
if tim_su(GetName())~=1 then
do_a = GetName()
break
else
PlayerIndex = pl
Msg2Player("Nhan vat ban muon nhan lam de tu da bai su !!!")
return
end
end
end
end
PlayerIndex = pl
for k=1,getn(DO) do
if DO[k][1] == GetName() then
su_id = k
so_vl = getn(DO[k])
break
end
end
DO[su_id][so_vl+1]=do_a
bien = TaoBang(DO,"DO")
LuuBang("script/sudo_sn/dsdo.lua",bien)
for k=1,getn(SU) do
if SU[k][1] == GetName() then
su_id = k
end
end
for k=1,getn(DO) do
if DO[k][1] == GetName() then
su_id = k
so_vl = getn(DO[k])
break
end
end
xuat_su = SU[su_id][4]
SU[su_id]={GetName(),so_vl-1,floor(so_vl/2),xuat_su}
bien = TaoBang(SU,"SU")
LuuBang("script/sudo_sn/dssu.lua",bien)
Msg2SubWorld("Su phu "..GetName().." nhan de tu "..do_a)
AddGlobalCountNews("Su do "..GetName()..", "..do_a.." gan ket",1)
else
Say("<color=green>Tien Su<color>: Nguoi hay tao do doi giua nguoi va nguoi can nhan lam de tu ta se giup cho",0)
end
else
Say("<color=green>Tien Su<color>: Hay di tim bi pho su do thiep roi den gap ta !!",0)
end



end
end

function num_dt()
for i=1,getn(DO) do
if DO[i][1]==GetName() then
return getn(DO[i])-1
end
end
end

function tim_su(name)
if getn(DO) == 0 then
return 0 end
for i=1,getn(DO) do
for k=1,getn(DO[i]) do
if DO[i][k] == name then
return 1
end
end
end
return nil
end

function LEVS()
muc_luc =
{
{1,1,3,"Kien tap su phu"},
{2,2,3,"Pho thong su phu"},
{3,3,3,"Thu nghiep truyen su"},
{5,4,4,"Pho thong danh su"},
{7,5,5,"Nhat dai danh su"},
{10,6,6,"Nhat dai ton su"},
{13,7,7,"Thien co danh su"},
{17,8,8,"Khoang the luong su"},
{21,9,9,"Mon do tam thien"},
{26,10,10,"Danh do tam thien"},
}
for i=1,getn(SU) do
if SU[i][1] == GetName() then
xuat = SU[i][4]
if xuat <= 1 then
return muc_luc[1][4]
elseif xuat == 2 then
return muc_luc[2][4]
elseif xuat == 3 then
return muc_luc[3][4]
elseif xuat > 3 and xuat <= 5 then
return muc_luc[4][4]
elseif xuat > 5 and xuat <=7 then
return muc_luc[5][4]
elseif xuat > 7 and xuat <=10 then
return muc_luc[6][4]
elseif xuat > 10 and xuat <=13 then
return muc_luc[7][4]
elseif xuat > 13 and xuat <=17 then
return muc_luc[8][4]
elseif xuat > 17 and xuat <=21 then
return muc_luc[9][4]
elseif xuat > 21 and xuat <=26 then
return muc_luc[10][4]
else
return muc_luc[10][4]
end
end
end

end

function timsu()
for i=1,getn(DO) do
for k=1,getn(DO[i]) do
if DO[i][k] == GetName() then
return DO[i][1]
end
end
end
end

function bo_dt()
List_do_de2={}
List_do_de={}
so_dt=0
id_su=0
for i=1,getn(DO) do
if DO[i][1] == GetName() then
so_dt=getn(DO[i])
id_su=i
break
end
end

if so_dt==2 then
Say("<color=green>Tien Su<color>: He thong khong cho ban truc xuat de tu dich truyen",0)
return
end

for k=2,so_dt do
List_do_de[getn(List_do_de)+1]=DO[id_su][k].."/select_one"
List_do_de2[getn(List_do_de2)+1]=DO[id_su][k]
end
List_do_de2[getn(List_do_de2)+1]="Thoat./OnEx"
Say("<color=green>Tien Su<color>: Nguoi muon truc xuat de tu nao ?",getn(List_do_de),List_do_de)
end

function select_one(nSel)
Msg2Player(nSel)
num = nSel+1
do_de_bi_truc_xuat = List_do_de2[num]
Msg2Player(do_de_bi_truc_xuat)
for i=1,getn(DO) do
for k=1,getn(DO[i]) do
if DO[i][k] == do_de_bi_truc_xuat then
DO[i][k] = nil
end
end
end
bien = TaoBang(DO,"DO")
LuuBang("script/sudo_sn/dsdo.lua",bien)
Msg2Player("Truc xuat thanh cong de tu "..do_de_bi_truc_xuat)
AddGlobalCountNews("Su phu "..GetName().."truc xuat de tu "..do_de_bi_truc_xuat,1)
for i=1,getn(SU) do
if SU[i][1]==GetName() then
SU[i][2]=SU[i][2]-1
end
end
bien = TaoBang(SU,"SU")
LuuBang("script/sudo_sn/dssu.lua",bien)
List_do_de2={}
List_do_de={}
end
function helps()
Talk(3,"","He Thong Su Do Chi Moi Cap Nhat Chuc Nang Thu Nhan De Tu",
"Khi nhan Su Phu nguoi se duoc nhieu uu dai",
"Chuc ban thanh cong trong cong tac Su Do")
end;


function leave_sd()
if GetLevel() >= 80 then
Say("To So: Hien tai nguoi da du level de xuat su...?",2,"Xuat Su/dong_y","Thoat./OnEx")
else
Talk(1,"","Dang cap non kem khong dua vao su phu thi nguoi lam duoc gi co chu")
end
end
function dong_y()
if GetLevel() >= 80 then --ok
Talk(1,"","<color="..colorS()..">To Su<color>: Bay gio nguoi da du dieu kien tu minh phieu bat giang ho khong can su phu chi day gi nua.")
AddEventItem(daihongbao)
AddEventItem(daihongbao)
tensuphu = timsu()
updateSD()
for i = 1,getn(DO) do
for k = 1,getn(DO[i]) do
if DO[i][k] == GetName() then
DO[i][k] = ""
end
end
end
bien = TaoBang(DO,"DO","")
LuuBang("script/sudo_sn/dsdo.lua",bien)
Msg2SubWorld(GetName().." da duoc su phu "..timsu().." nuoi day thanh tai tro thanh mot dai hiep.")
elseif GetLevel() >= 100 then --ok
Talk(1,"","<color="..colorS()..">To Su<color>: Bay gio nguoi da du dieu kien tu minh phieu bat giang ho khong can su phu chi day gi nua.")
AddEventItem(daihongbao)
AddEventItem(daihongbao)
AddEventItem(daihongbao)
AddEventItem(daihongbao)
AddEventItem(daihongbao)
tensuphu = timsu()
updateSD()
for i = 1,getn(DO) do
for k = 1,getn(DO[i]) do
if DO[i][k] == GetName() then
DO[i][k] = ""
end
end
end
bien = TaoBang(DO,"DO","")
LuuBang("script/sudo_sn/dsdo.lua",bien)
Msg2SubWorld(GetName().." da duoc su phu "..timsu().." nuoi day thanh tai tro thanh mot dai hiep.")
end
end;

function leave2_sd()
Talk(1,"","<color="..colorS()..">Tien Su<color>: Nguoi da phan lai Su Phu cua minh!.")
tensuphu = timsu()
updateSD()
for i = 1,getn(DO) do
for k = 1,getn(DO[i]) do
if DO[i][k] == GetName() then
DO[i][k] = ""
end
end
end
bien = TaoBang(DO,"DO","")
LuuBang("script/sudo_sn/dsdo.lua",bien)
end;
function updateSD()
for i = 1,getn(SU) do
if tensuphu == timsu() then
SU[i][3] = SU[i][3] + 1
bien = TaoBang(SU,"SU")
LuuBang("script/sudo_sn/dssu.lua",bien)
end
end
end;


dssudo.lua


SUDO={}


dsdo.lua :


DO={}


dssu.lua


SU={}


TaoBang.lua


-----------------------------------------------------------------------------------------------------------------------
--Doan script sau de luu cac bang (array) duoc tao vao 1 file lua voi cau truc sau
--bang = {
--{value1,value2,...}
--}
--Ve dang nhu sau :
--bang = {}
--bang[i] = {value1,value2,....}
--Sau do thi luu bang lai vao file cau truc ham nhu sau
------------------------------------------------------------------------------------------------------------------------
--Ham TaoBang(TableIndex,TableName)
--TableIndex : table chung ta se su dung de tao ra file (type : table)
--TableName : ten cua table can tao file (type : string)
------------------------------------------------------------------------------------------------------------------------
function TaoBang(Table,TableName)
tao = TableName.."={}\n"
for i=1,getn(Table) do
if (type(Table[i])=="table") then
tao = tao..TableName.."["..i.."]".."=".."{"..Value(Table[i]).."\n"
else
tao = tao..TableName.."["..i.."]".."=".."{"..Value(Table).."\n"
break
end
end
return tao
end
----------------------------------------------Ham tao bang-----------------------------------------------------------
--ham Value(Table)
--Khong noi them vi cai nay de tao ra cac du lieu
--Cai nay hem coa dung nen hem giai thich
-----------------------------------------------------------------------------------------------------------------------
function Value(Table)
num = 0
value = ""
gia_tri = ""
for i=1,getn(Table)+1 do
if type(Table[i]) == "string" then gia_tri=format("%q",Table[i]) else gia_tri=tostring(Table[i]) end
if num < getn(Table) then
num=num+1
if i == getn(Table) then
value = value..gia_tri
else
value = value..gia_tri..","
end
elseif num == getn(Table) then
value = value.."}"
end
end
return value
end
------------------------------------------------In value cho bang------------------------------------------------------------
--ham LuuBangVaoFileLua(taptin,noidung)
--ket hop voi ham tao bang cau truc nhu sau
-- bang = TaoBang(table,"table")
-- LuuBangVaoFileLua("script/example.lua",bang)
------------------------------------------------------------------------------------------------------------------------------
function LuuBang(taptin,noidung)
mo_taptin = openfile(taptin,"w+")
write(mo_taptin,noidung)
closefile(mo_taptin)
end
-------------------------------------------------luu file lai-------------------------------------------------------------------
Hàm TaoBang tìm lại nhé , lười tìm quá , còn 1 số bug gì đó chả nhơ share xong del lun, lỗi thì post lên support cho thank :)

Tiến Đạt
18-11-10, 08:10 PM
Đọc thì nh` mà ko có ai comment( :D) ak??

Mr.Rezo™
18-11-10, 08:12 PM
Đọc thì nh` mà ko có ai commer ak??

Commer <-- Wuts da fu :-s Ur english very very **** :)>-

[S]ocola[S]an
18-11-10, 08:29 PM
Comment mới đúng . Commer .... :)) :))

Čħīċķėň
18-11-10, 08:33 PM
thanks vì post lại :D

tìm đc cái mình cần rùi :)

884363
01-03-11, 10:39 PM
Cho em hỏi là mình tạo file ở mục nào của server.thông cảm cho mình câu trả lời hẵng del nha tại newbie mà :D