Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_module_name()
- return "Mohamad512_System"
- end
- function Mohamad512_System()
- getAttemptsFight()
- Special_Card_Fight()
- CheckOnlineFight(1)
- RemoveFightPunish()
- name = gv("name")
- WarIsOn = get_global_variable("FightStarted")
- Attempt = get_global_variable("FightAttempt_"..name)
- if Attempt == "" then Attempt = 0 end
- P_Attempt = get_global_variable("P_FightAttempt_"..name)
- if P_Attempt == "" then P_Attempt = 0 end
- IsInFight = get_global_variable("IsInFight_"..name)
- dlg_title("Duelling system")
- ptime = get_global_variable('FightPunish_'..name)
- if ptime == "" then ptime =0 end
- if ptime == 0 or ptime <= get_os_time() then
- if WarIsOn ~=1 then
- if IsInFight == "" then -- Not registered
- dlg_text("Welcome to the duelling system..!!")
- if Attempt == 0 and P_Attempt == 0 then
- dlg_menu("Apply for duelling","NoAttemptFight()")
- else
- dlg_menu("Apply for duelling","GetInFight()")
- end
- dlg_menu("Who applied for duelling?","WhoRegInFight()")
- else -- Registered
- dlg_text("Welcome to the duelling system")--When registered !!
- dlg_menu("Leave duel","dlg_special('confirm_window','GetOutFight()','Do you want to leave the duel?')")
- dlg_menu("Who applied for duelling?","WhoRegInFight()")
- end
- else
- dlg_text("There is already a battle going on, please try again later...")--Registering during battle
- --dlg_menu("How many people left?","HowMany()")
- dlg_menu("Who is fighting right now?","WhoRegInFight()")
- end
- else
- --dlg_text(get_os_date("لقد تمت معاقبتك لمخالفة قوانين الحرب تنتهي عقوبتك في تاريخ %x الساعة %M : %H",ptime))
- dlg_text(get_os_date("You have been punished for breaking the battle rules, your punishment will expire in %H:%M \nYou can remove this part %x",ptime)) --Can't really see the format properly since it's RTL(Right to left) and I threw %x(character class for hexadecimal digits) in since it was there
- dlg_menu("Punishment reason and expiration date?","")
- end
- dlg_menu("Check your fight attempts","CheckFightAttempts()")
- --dlg_menu("Copyrights","mohamad512_informatin()")--Please don't remove it!
- dlg_menu("Bye!","")
- dlg_show()
- end
- function CheckFightAttempts()
- name = gv("name")
- dlg_title("Fight System")
- Attempt = get_global_variable("FightAttempt_"..name)
- P_Attempt = get_global_variable("P_FightAttempt_"..name)
- if Attempt == "" then Attempt = 0 end
- if P_Attempt == "" then P_Attempt = 0 end
- dlg_text("You have"..Attempt.." Attempts and "..P_Attempt.." Golden Attempts")
- dlg_menu("Exit","")
- dlg_show()
- end
- function mohamad512_informatin()
- private_notice('<#00FF00>All rights reserved to ')
- private_notice('<b><#00FF00>Mohamad512')
- end
- function getAttemptsFight()
- name = gv("name")
- tval = get_flag("FightTimeFight")
- h = tonumber(get_os_date("%H",get_os_time()))
- m = tonumber(get_os_date("%M",get_os_time()))
- ha = 0
- if tval == "" then tval = get_os_time()-50 end
- if get_os_time() > tval then
- if h < 8 then ha = 8 - h else ha = 24 - h + 8 end
- flag = get_os_time()+3600*ha-m*60
- set_global_variable("FightAttempt_"..name,3)
- set_flag("FightTimeFight",flag)
- message("<#FF0000>Fight attempts received")
- return 1
- else
- if h < 8 then ha = 8 - h else ha = 24 - h + 8 end
- ma = 60-m
- remain = get_os_time() +3600*ha -3600 +ma*60 -m*60
- return remain
- end
- end
- function ReadyAgainFight()
- dlg_title("Duelling System")
- name = gv("name")
- timeval = getAttemptsFight()
- if timeval == 1 then
- dlg_text("You received your attempts")
- else
- remain = timeval
- --dlg_text(get_os_date("تبقى %H ساعة و %M دقيقة و %S ثانية",remain))
- dlg_text(get_os_date("Remaining time: %H:%M:%S",remain))
- end
- dlg_menu("Bye!" ,'' )
- dlg_show()
- end
- function NoAttemptFight()
- dlg_title("Duelling System")
- dlg_text("You have used up all of your fighting attempts for today, you need to wait until tomorrow to receive more attempts.")
- dlg_menu("When will I receive my fight attempts?","ReadyAgainFight()")
- dlg_menu("Bye!" ,'' )
- dlg_show()
- end
- function FightKick(name)
- --name = gv("name")
- countFighters = get_global_variable("FightSCount")
- guild = gv("guild_id")
- guild_variable =get_global_variable("FightGuildMem_"..guild)
- RegOutFight(name)
- del_global_variable("IsInFight_"..name)
- del_global_variable("FightLife_"..name)
- if countFighters =="" then countFighters =1 end
- set_global_variable("FightSCount",countFighters-1)
- warp_to_revive_position(name)
- if guild_variable ~= "" then
- if guild_variable == 1 then
- del_global_variable("FightGuildMem_"..guild)
- else
- guild_mem_c = get_global_variable("FightGuildMem_"..guild)
- set_global_variable("FightGuildMem_"..guild , guild_mem_c-1)
- end
- end
- CheckFightWinner()
- end
- function FightPunish(Type,name)
- tval = get_os_time()
- if Type == 1 then
- flag = get_os_time()+3600*24*2
- elseif Type == 2 then
- flag = get_os_time()+3600*24*1
- elseif Type == 3 then
- --flag = get_os_time()+3600*12
- flag = 0
- elseif Type == 4 then
- flag = get_os_time()+3600*24*3
- end
- set_global_variable('FightPunish_'..name,flag)
- set_global_variable('FightPunishType_'..name,Type)
- whisper(name,"<b><FF0000>You have been punished for breaking the rules!")
- end
- function IsPunishedFight()
- name = gv("name")
- ptime = get_global_variable('FightPunish_'..name)
- if ptime ~= "" and ptime < get_os_time() then
- t = {}
- at = ptime - get_os_time()
- da = math.floor(at /86400)--/3600 / 24)
- ha = math.floor(at /3600 - da * 24)
- ma = math.floor(at /60 - ha*60 - da *1440)--*24*60)
- t[1] = da
- t[2] = ha
- t[3] = ma
- return t
- else return 0
- end
- end
- function Check_Each_Fight_Party()
- name = gv("name")
- party = gv("party_id")
- for i = 1 ,2 do
- pname = get_global_variable('FightSMem_'..i)
- if gv("party_id",pname) ~= 0 then
- FightKick(pname)
- FightPunish(2,pname)
- end
- end
- end
- function Check_Target()
- if get_target_value("name") ~= 0 then
- do_something()
- end
- end
- function Special_Card_Fight()
- x=gv("x")
- y=gv("y")
- layer=gv("layer")
- if get_global_variable("FightStarted") ==1 then --and x >= 203567 and x <= 209067 and y >= 115300 and y <= 121700 and layer == 3 then
- Check_Each_Fight_Party()
- Check_Each_Fight_Position()
- --Check_Target()
- CheckFightWinner()
- --else
- --delete_item(get_item_handle(1234),1)
- end
- end
- function GetInFight()
- if get_global_variable("FightStarted") ~= 1 then
- party = gv("party_id")
- name = gv("name")
- guild = gv("guild_id")
- guild_mem_c = get_global_variable("FightGuildMem_"..guild)
- if guild_mem_c == "" then guild_mem_c = 0 end
- if party == 0 then
- if guild_mem_c < 1 or guild == 0 then
- set_global_variable("IsInFight_"..name,1)
- if guild ~= 0 then
- set_global_variable("FightGuildMem_"..guild , guild_mem_c+1)
- Set_Guild_Variable()
- end
- countFighters = get_global_variable("FightSCount")
- set_global_variable("FightSCount",countFighters+1)
- RegInFight()
- --insert_item(1234,1)
- --do_for_each_Fight(1,private_notice,name..'قد قام بالتسجيل تبقى'..CheckOnlineFight(1)..'متنافس حتى البداية . !')
- do_for_each_Fight(25,whisper,'<b><#FFFF00>'..name..' has registered for the battle!\n'..CheckOnlineFight(1)..' applicants until the start of the battle!')
- -- notice('<b><#FFFF00>'..name..' قد قآم بآلتسجيل للمبآرزة تبقى'..CheckOnlineFight(1)..' متنافس حتى البداية . !') --Same thing as above but this one sends a notice instead
- if CheckOnlineFight(1) == 0 then
- FightGo()
- else
- Offline = CheckOnlineFight(1)
- dlg_general("You have been successfully registered for the battle "..Offline.." applicants left until battle start!")
- end
- else dlg_general("Only 1 member of the same guild is allowed!") end
- else private_notice("<#FF0000>Teaming up is forbidden, if you team up with anyone you'll lose and get punished!")
- end
- end
- end
- function RegInFight()
- name = gv("name")
- for i = 1 ,2 do
- if get_global_variable("FightSMem_"..i) == "" and i <= 2 then
- set_global_variable("FightSMem_"..i,name)
- set_flag("FightNum",i)
- break
- end
- end
- end
- function FightRandomWarp()
- X = {213225,213208}
- Y = {144360,142945}
- Ran = math.random(1,2)
- warp(X[Ran],Y[Ran],3)
- end
- function CheckGuildWinnerFight()
- CO1 = CheckOnlineFight(1)
- if CO1 == 17 then
- if gv("guild_id",GetOnline()[1]) == gv("guild_id",GetOnline()[2]) and gv("guild_id",GetOnline()[3]) == gv("guild_id",GetOnline()[2])
- then return 3
- end
- elseif CO1 == 18 then
- if gv("guild_id",GetOnline()[1]) == gv("guild_id",GetOnline()[2])
- then return 2
- end
- else return 0
- end
- end
- -------------------------------------------------------------------------
- function CheckOnlineFight(num)
- if num == 1 then
- Offline = 0
- for i = 1 ,2 do
- p = get_global_variable('FightSMem_'..i)
- if gv("name",p) == 0 then
- del_global_variable('FightSMem_'..i)
- del_global_variable('IsInFight_'..p)
- countFighters = get_global_variable("FightSCount")
- guild = gv("guild_id")
- if countFighters =="" then countFighters=0 end
- set_global_variable("FightSCount",countFighters-1)
- if guild ~= 0 then
- if get_global_variable("FightGuildMem_"..guild) == 1 then
- del_global_variable("FightGuildMem_"..guild)
- else
- guild_mem_c = get_global_variable("FightGuildMem_"..guild)
- if guild_mem_c == "" then guild_mem_c = 1 end
- set_global_variable("FightGuildMem_"..guild , guild_mem_c-1)
- end
- end
- Offline = Offline + 1
- if Offline==2 then set_global_variable("FightStarted",0) end
- elseif get_global_variable('FightSMem_'..i) == "" then
- Offline = Offline + 1
- end
- end
- --if Offline ==19 and get_global_variable("FightStarted") == 1 then FightWin() end
- return Offline
- elseif num == 2 then
- Online =""
- c = 0
- for i = 1 ,2 do
- p=get_global_variable('FightSMem_'..i)
- if gv("name",p) ~= 0 then
- c = c+1
- if c == 1 then
- Online = get_global_variable('FightSMem_'..i)
- else
- Online = Online..' - '..get_global_variable('FightSMem_'..i)
- end
- end
- end
- return Online
- end
- end
- function FightGo()
- if get_global_variable("FightStarted") ~= 1 then
- notice("<#FF0000>Registration complete, battle started!")
- do_for_each_Fight(1,set_pk_mode,1)
- FightWarp()
- set_global_variable("FightStarted",1)
- SetFightLife()
- Check_Each_Fight_Party()
- FightWarrning()
- UpdateAttemptsFight()
- end
- end
- function UpdateAttemptsFight()
- for i = 1,3 do
- name = get_global_variable('FightSMem_'..i)
- if gv("name",name) ~= 0 then
- Attempt = get_global_variable("FightAttempt_"..name)
- P_Attempt = get_global_variable("P_FightAttempt_"..name)
- if P_Attempt == "" then P_Attempt = 0 end
- if Attempt == "" then Attempt = 0 end
- if Attempt ~= 0 and P_Attempt == 0 then
- set_global_variable("FightAttempt_"..name,Attempt-1)
- elseif Attempt == 0 and P_Attempt ~= 0 then
- set_global_variable("P_FightAttempt_"..name,P_Attempt-1)
- elseif Attempt ~= 0 and P_Attempt ~= 0 then
- set_global_variable("FightAttempt_"..name,Attempt-1)
- end
- end
- end
- end
- function SetFightLife()
- for i = 1 ,2 do
- d=get_global_variable('FightSMem_'..i)
- if gv('name',d) ~= 0 then
- set_global_variable("FightLife_"..d,9) ---Sets participants's life, if they die 10 times they lose
- end
- end
- end
- function WhoRegInFight()
- Online = CheckOnlineFight(2)
- private_notice(Online)
- end
- function FightWin()
- CheckOnlineFight(1)
- WinnerName =CheckOnlineFight(2)
- if WinnerName ~= "" then
- warp_to_revive_position(WinnerName)
- P_Attempt = get_global_variable("P_FightAttempt_"..WinnerName)
- if P_Attempt =="" then P_Attempt=0 end
- set_global_variable("P_FightAttempt_"..WinnerName,P_Attempt+1)
- --add_state(145720,10,1080000,WinnerName)
- --r = math.random(1,2)
- --if r == 1 then
- --add_state(4502,1,1080000,WinnerName)
- --else
- --add_state(9003,1,1080000,WinnerName)
- --end
- ---sv("ap",+1000,WinnerName)
- notice('<#F0000> Congrajulations <#FF0000>'..WinnerName..'</#FF0000> for winning the battle ..!')
- set_value( "ap", tonumber(get_value( "ap" )) + 300,WinnerName)
- delete_all_variableFight()
- Del_Guild_VariableFight()
- set_global_variable("FightStarted",0)
- end
- end
- function FightLost()
- name = gv("name")
- countFighters = get_global_variable("FightSCount")
- guild = gv("guild_id")
- guild_variable =get_global_variable("FightGuildMem_"..guild)
- RegOutFight(name)
- del_global_variable("IsInFight_"..name)
- del_global_variable("FightLife_"..name)
- set_global_variable("FightSCount",countFighters-1)
- if guild_variable ~= "" then
- if guild_variable == 1 then
- del_global_variable("FightGuildMem_"..guild)
- else
- guild_mem_c = get_global_variable("FightGuildMem_"..guild)
- set_global_variable("FightGuildMem_"..guild , guild_mem_c-1)
- end
- end
- --delete_item(get_item_handle(1234),1)
- warp_to_revive_position()
- CO1 =CheckOnlineFight(1)
- if CO1 == 1 then
- notice('<#FF0000>~~Battle System~~')
- notice('<#FF0000>'..name..' has lost.. !')
- end
- Special_Card_Fight()
- end
- function CheckFightWinner()
- WarIsOn = get_global_variable("FightStarted")
- if WarIsOn == 1 then
- CO1 =CheckOnlineFight(1)
- if CO1 == 1 then
- FightWin()
- elseif CO1 == 17 then
- if gv("guild_id",GetOnline()[1]) == gv("guild_id",GetOnline()[2]) and gv("guild_id",GetOnline()[3]) == gv("guild_id",GetOnline()[2])
- then GuildWinFight()
- end
- elseif CO1 == 18 then
- if gv("guild_id",GetOnline()[1]) == gv("guild_id",GetOnline()[2])
- then GuildWinFight()
- end
- end
- end
- end
- function GetOutFight()
- name = gv("name")
- guild = gv("guild_id")
- del_global_variable("IsInFight_"..name)
- if guild ~= 0 then
- if get_global_variable("FightGuildMem_"..guild) == 1 then
- del_global_variable("FightGuildMem_"..guild)
- else
- guild_mem_c = get_global_variable("FightGuildMem_"..guild)
- if guild_mem_c == "" then guild_mem_c = 1 end
- set_global_variable("FightGuildMem_"..guild , guild_mem_c-1)
- end
- end
- countFighters = get_global_variable("FightSCount")
- set_global_variable("FightSCount",countFighters-1)
- RegOutFight(name)
- end
- function RegOutFight(name)
- -- name = gv("name")
- for i = 1 , 3 do
- if get_global_variable('FightSMem_'..i) == name then
- del_global_variable('FightSMem_'..i)
- end
- end
- end
- function RemoveFightPunish()
- name = gv("name")
- ptime = get_global_variable('FightPunish_'..name)
- if ptime ~="" then
- if ptime <= get_os_time() or ptime >= get_os_time() or ptime == get_os_time() then
- del_global_variable('FightPunish_'..name)
- del_global_variable('FightPunishType_'..name)
- end
- end
- del_global_variable('FightPunish_'..name)
- del_global_variable('FightPunishType_'..name)
- end
- function Check_Each_Fight_Position()
- name = gv("name")
- for i = 1 ,2 do
- pname = get_global_variable('FightSMem_'..i)
- if gv("name",pname) ~= "" then
- x = gv("x",pname)
- y=gv("y",pname)
- layer=gv("layer",pname)
- --if x <= 203567 or x >= 209067 or y <= 115300 or y >= 121700 and layer ~= 3 then
- if x >= 212270 and x <= 214105 and y >= 142899 and y <= 144518 and layer ==3 then do_nothing() else
- if x ~= 0 and y ~=0 then
- FightKick(pname)
- FightPunish(1,pname)
- end
- end
- end
- end
- end
- function do_nothing()
- end
- function CheckInFight()
- x=gv("x")
- y=gv("y")
- c = get_flag("FightNum")
- name = gv("name")
- layer = gv("layer")
- if get_global_variable("FightSMem_"..c) == gv("name")
- and get_global_variable("IsInFight_"..name) == 1
- and get_global_variable("FightLife_"..name) ~= "" then
- if x >= 212270 and x <= 214105 and y >= 142899 and y <= 144518 and layer ==3 then
- return 1 else return 2
- end
- elseif x <= 212270 and x >= 214105 and y <= 142899 and y >= 144518 and layer ~= 3 then return 3
- else return 0
- end
- end
- function FightWarrning()
- do_for_each_Fight(25,whisper,',<b><#00FF00>Welcome to the battle system')
- do_for_each_Fight(25,whisper,'<#FF0000>Rules :-')
- do_for_each_Fight(25,whisper,'<#FF0000>1. Teams are forbidden .')
- do_for_each_Fight(25,whisper,'<#FF0000>2. You are not allowed to leave the battleground using a recall scroll or any other item .')
- do_for_each_Fight(25,whisper,'<#FF0000>If you break any of these rules you will be punished')
- do_for_each_Fight(25,whisper,'<#FF0000>We\'re not responsible in the case of losing experience or items. You may use God Mother Fairy\'s Bottles and/or Fairy\'s Locks')
- end
- function do_for_each_Fight(countFighters,command,x,y,z)
- for i = 1 ,2 do
- d=get_global_variable('FightSMem_'..i)
- if gv('name',d) ~= 0 then
- if countFighters == 3 then
- command(x,y,z,get_global_variable('FightSMem_'..i))
- elseif countFighters == 1 then
- command(x,get_global_variable('FightSMem_'..i))
- elseif countFighters == 2 then
- command(x,y,get_global_variable('FightSMem_'..i))
- elseif countFighters== 25 then
- command(get_global_variable('FightSMem_'..i),x)
- end
- end
- end
- end
- function delete_all_variableFight()
- del_global_variable("FightSCount")
- for i = 1 ,2 do
- if get_global_variable('FightSMem_'..i) ~= "" then
- name = get_global_variable('FightSMem_'..i)
- del_global_variable("FightLife_"..name)
- del_global_variable("IsInFight_"..name)
- del_global_variable("WarGuildLight_"..name)
- del_global_variable('FightSMem_'..i)
- end
- end
- end
- function Del_Guild_VariableFight()
- for i = 1 ,2 do
- if get_global_variable("WarGuildId_"..i) ~= "" then
- GuildId = get_global_variable("WarGuildId_"..i)
- del_global_variable("FightGuildMem_"..GuildId)
- del_global_variable("WarGuildId_"..i)
- end
- end
- end
- function FightWarp()
- X = {213225,213208}
- Y = {144360,142945}
- for i = 1,3 do
- d=get_global_variable('FightSMem_'..i)
- if gv('name',d) ~= 0 then
- warp(X[i],Y[i],3,d)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement