PDA

View Full Version : [JX] nhờ các bác nào biết chỉ giùm em mới



vuduymanh
15-05-16, 01:33 PM
em có tải cái server phung hưng trong server có hàm code giftcode mà em ko biết tạo code mới để nhập
trong file code.lua

ListCode ={
[1]={'BACNAMSUMVAY009',1},
}

trong head_vip.lua

T_DONATE = 501T_LEVEL_VIP = 502
TAB_LEVEL_VIP = {20,100,200,300,500}

trong giftcodedata.lua
Include("\\script\\giftcode\\code.lua")Include("\\script\\global\\vn\\head_vip.lua")
Include("\\script\\global\\hamapi.lua")
Include("\\script\\task\\task_addplayerexp.lua")
Include("\\script\\dailogsys\\dailogsay.lua")
Include("\\script\\lib\\awardtemplet.lua");
IncludeLib("SETTING")
IncludeLib("ITEM")


T_GiftEXP = 998
T_GiftCode = 999


function main()
dofile("script/giftcode/giftcodedata.lua")
dofile("script/giftcode/code.lua")
DoiThoai()
end


function DoiThoai()
local nTransLife = ST_GetTransLifeCount()
if (nTransLife > 0) then
Say("Nh©n vËt ®· trïng sinh kh«ng thÓ nhËn th­ëng",0)
return
end

if GetLevel() < 130 then
Say("Nh©n vËt ®¹t cÊp 130 míi cã thÓ nhËp GiftCode.",0)
return
end

local EMPTY = 30
if (CalcFreeItemCellCount() < EMPTY) then
Msg2Player(""..XungHo().." h·y thu dän hµnh trang "..EMPTY.." « trèng!")
return
end

local szTitle = "<npc>"..GetPlayerSex().." t×m ta cã viÖc g×?"
local tbOpt =
{
{"NhËp GiftCode",InputCheckCode},
{"Tho¸t"},
}
CreateNewSayEx(szTitle, tbOpt)
end


function InputCheckCode()
if GetCurCamp() == 0 then
Msg2Player("Gia nhËp m«n ph¸i míi cã thÓ nhËp ®­îc code")
return
end

if GetTask(T_GiftEXP) >= 1500 then
Msg2Player("Ng­¬i ®· nhËn th­ëng råi kh«ng thÓ nhËn tiÕp ®­îc n÷a")
return
end

AskClientForString("NhapCode","",1,50,"Xin mêi nhËn GiftCode")

function NhapCode(str)
local CheckCode = 0
for i=1,1500 do
if ListCode[i][1] == str then
if ListCode[i][2] == 0 then
Msg2Player("<color=green>Chóc mõng!B¹n ®· nhËp thµnh c«ng m· Code!")
local Tab = {
{szName="Kim M· LÔ Bao", tbProp={6,1,4089}, nCount = 7, nExpiredTime = 1440, nBindState = -2},
--{szName="§¹i B¹ch CÇu Hoµn", tbProp={6,1,1766}, nCount = 2, nExpiredTime = 1440, nBindState = -2},
{szName="§¹i Thµnh BÝ KÝp CÊp 90", tbProp={6,1,2424}, nCount = 1, nExpiredTime = 1440, nBindState = -2},
{szName="BÝ KÝp 120", tbProp={6,1,1125}, nCount = 1, nExpiredTime = 1440, nBindState = -2},
{szName="ChiÕn M· cÊp 80", tbProp={0,10,5,random(6,10),0,0}, nCount = 1, nExpiredTime = 1440*7, nBindState = -2},
}
for i = 1,getn(Tab) do
tbAwardTemplet:GiveAwardByList(Tab[i], "PhÇn th­ëng t©n thñ");
end

AddGiftVip()
local LEVEL = 190
if (GetLevel() < LEVEL) then
local nCurLevel = GetLevel()
local nAddLevel = LEVEL - nCurLevel
ST_LevelUp(nAddLevel)
end
SetTask(T_GiftEXP,1501)
UpdateData(i)
return
else
CheckCode = 1
end
end
end
if CheckCode == 1 then
Msg2Player("<color=yellow>M· Code nµy ®· ®­îc sö dông , vui lßng chän m· code kh¸c!")
else
Msg2Player("<color=metal>M· Code b¹n nhËp kh«ng hîp lÖ vui lßng liªn hÖ GM ®Ó ®­îc ph¸t code.")
end
end
end


function InputCheckCodeVip()
if GetCurCamp() == 0 then
Msg2Player("Gia nhËp m«n ph¸i míi cã thÓ nhËp ®­îc code")
return
end

if GetTask(T_GiftCode) >= 1500 then
Msg2Player("Ng­¬i ®· nhËn th­ëng råi kh«ng thÓ nhËn tiÕp ®­îc n÷a")
return
end

AskClientForString("NhapCodeVip","",1,50,"Xin mêi nhËn GiftCode")

function NhapCodeVip(str)
local CheckCode = 0
for i=501,getn(ListCode) do
if ListCode[i][1] == str then
if ListCode[i][2] == 0 then
Msg2Player("<color=green>Chóc mõng!B¹n ®· nhËp thµnh c«ng m· Code!")
local nTransLife = ST_GetTransLifeCount()
if (nTransLife > 0) then
SetTask(T_GiftCode,1501)
AddItemS1()
local nItemIdx = AddItem(0,10,18,1,0,0)
ITEM_SetExpiredTime(nItemIdx,3000)
SyncItem(nItemIdx)
SetItemBindState(nItemIdx,-2)
else
local levelVip = GetTask(T_LEVEL_VIP)
if (levelVip > 0) then
SetTask(T_GiftCode,1501)
AddGiftVip()
else
Say("§èi víi nh©n sü ch­a trïng sinh ph¶i quy ®æi Ýt nhÊt 20xu vµo game kÓ tõ ngµy 14/8 míi cã thÓ nhËn th­ëng",0)
return
end
end
UpdateData(i)
return
else
CheckCode = 1
end
end
end
if CheckCode == 1 then
Msg2Player("<color=yellow>M· Code nµy ®· ®­îc sö dông , vui lßng chän m· code kh¸c!")
else
Msg2Player("<color=metal>M· Code b¹n nhËp kh«ng hîp lÖ vui lßng liªn hÖ GM ®Ó ®­îc ph¸t code.")
end
end
end


function UpdateData(iViTri)
local sTmp = {}
ClearData("script/giftcode/code.lua","")
SaveData("script/giftcode/code.lua","ListCode =\n{")
for i=1,getn(ListCode) do
if i == iViTri then
ListCode[i][2] = 1
SaveData("script/giftcode/code.lua","\n\t["..i.."]={")
SaveData("script/giftcode/code.lua","'"..ListCode[i][1].."',")
SaveData("script/giftcode/code.lua",ListCode[i][2].."},")
else
SaveData("script/giftcode/code.lua","\n\t["..i.."]={")
SaveData("script/giftcode/code.lua","'"..ListCode[i][1].."',")
SaveData("script/giftcode/code.lua",ListCode[i][2].."},")
end
end
SaveData("script/giftcode/code.lua","\n}")
return sTmp
end


function AddGift()
local nMP = GetLastFactionNumber()
if (nMP == 0) then --ThiÕu L©m
for i=1,2 do
local ran = random(1,15)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 1) then --TVB
for i=1,2 do
local ran = random(16,30)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 2) then -- §M
for i=1,2 do
local ran = random(71,90)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 3) then -- 5 §éc
for i=1,2 do
local ran = random(56,70)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 4) then --Nga Mi
for i=1,2 do
local ran = random(31,46)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 5) then --Thóy Yªn
for i=1,2 do
local ran = random(46,55)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 6) then --C¸i Bang
for i=1,2 do
local ran = random(91,100)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 7) then --Thiªn NhÉn
for i=1,2 do
local ran = random(101,115)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 8) then --Vâ §ang
for i=1,2 do
local ran = random(116,125)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 9) then --C«n L«n
for i=1,2 do
local ran = random(126,140)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
elseif (nMP == 10) then --Hoa S¬n
for i=1,2 do
local ran = random(4643,4652)
local nIndex = AddGoldItem(0,ran)
SetItemBindState(nIndex,-2)
end
end
end


function AddGiftVip()
local nMP = GetLastFactionNumber()
if (nMP == 0) then --ThiÕu L©m
local tab_Content = {
"ThiÕu L©m QuyÒn/#SelectCode(1)",
"ThiÕu L©m Bæng/#SelectCode(2)",
"ThiÕu L©m §ao/#SelectCode(3)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 1) then --TVB
local tab_Content = {
"Thiªn V­¬ng Chïy/#SelectCode(4)",
"Thiªn V­¬ng Th­¬ng/#SelectCode(5)",
"Thiªn V­¬ng §ao/#SelectCode(6)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 2) then -- §M
local tab_Content = {
"§­êng M«n phi ®ao/#SelectCode(15)",
"§­êng M«n tô tiÔn/#SelectCode(16)",
"§­êng M«n phi tiªu/#SelectCode(17)",
"§­êng M«n bÉy/#SelectCode(18)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 3) then -- 5 §éc
local tab_Content = {
"Ngò §éc Ch­ëng/#SelectCode(12)",
"Ngò §éc §ao/#SelectCode(13)",
"Ngò §éc Bïa/#SelectCode(14)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 4) then --Nga Mi
local tab_Content = {
"Nga My KiÕm/#SelectCode(7)",
"Nga My Ch­ëng/#SelectCode(8)",
"Nga My Buff/#SelectCode(9)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 5) then --Thóy Yªn
local tab_Content = {
"Thóy Yªn §ao/#SelectCode(10)",
"Thóy Yªn Song §ao/#SelectCode(11)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 6) then --C¸i Bang
local tab_Content = {
"C¸i Bang rång/#SelectCode(19)",
"C¸i Bang bæng/#SelectCode(20)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 7) then --Thiªn NhÉn
local tab_Content = {
"Thiªn NhÉn kÝch/#SelectCode(21)",
"Thiªn NhÉn ®ao/#SelectCode(23)",
"Thiªn NhÉn bïa/#SelectCode(22)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 8) then --Vâ §ang
local tab_Content = {
"Vâ §ang khÝ/#SelectCode(24)",
"Vâ §ang kiÕm/#SelectCode(25)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 9) then --C«n L«n
local tab_Content = {
"C«n L«n ®ao/#SelectCode(26)",
"C«n L«n kiÕm/#SelectCode(27)",
"C«n L«n bïa/#SelectCode(28)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
elseif (nMP == 10) then --Hoa S¬n
for i=1,2 do
local ran = random(4643,4652)
local nItemIdx = AddGoldItem(0,ran)
ITEM_SetExpiredTime(nItemIdx,1440*7)
SyncItem(nItemIdx)
SetItemBindState(nItemIdx,-2)
end
end
end


function SelectCode(nId)
for i=1,2 do
local mp = GetLastFactionNumber()
--local ran = random(nId*5+1-5,nId*5)
local ran = (nId*5+i-5)
AddGoldItemLimit(ran,1440*7)
end
end


function AddItemS1(sel)
local tab_Content = {
"[H¹n chÕ]ThiÕu L©m QuyÒn/#SelectS1(1)",
"[H¹n chÕ]ThiÕu L©m Bæng/#SelectS1(2)",
"[H¹n chÕ]ThiÕu L©m §ao/#SelectS1(3)",
"[H¹n chÕ]Thiªn V­¬ng §ao/#SelectS1(4)",
"[H¹n chÕ]§­êng M«n Ná/#SelectS1(5)",
"[H¹n chÕ]Ngò §éc §ao/#SelectS1(6)",
"[H¹n chÕ]Nga My KiÕm/#SelectS1(7)",
"[H¹n chÕ]Nga My Ch­ëng/#SelectS1(8)",
"[H¹n chÕ]Thóy Yªn §ao/#SelectS1(9)",
"[H¹n chÕ]Thóy Yªn Song §ao/#SelectS1(10)",
"[H¹n chÕ]C¸i Bang Rång/#SelectS1(11)",
"[H¹n chÕ]Thiªn NhÉn KÝch/#SelectS1(12)",
"[H¹n chÕ]Thiªn NhÉn §ao/#SelectS1(13)",
"[H¹n chÕ]Vâ §ang KhÝ/#SelectS1(14)",
"[H¹n chÕ]Vâ §ang KiÕm/#SelectS1(15)",
"[H¹n chÕ]C«n L«n §ao/#SelectS1(16)",
"[H¹n chÕ]C«n L«n KiÕm/#SelectS1(17)",
}
Say("Xin chµo <color=yellow>"..GetName().."<color>, h·y chän trang bÞ mµ b¹n muèn",getn(tab_Content),tab_Content)
end


function SelectS1(sel)
local n = sel + 1
local tab_GoldItem = {769,771,776,793,843,829,796,801,811,816,855,868,8 76,881,888,891,898}
local ItemIndex = AddGoldItem(0,tab_GoldItem[n])
ITEM_SetExpiredTime(ItemIndex, 1440 * 2)
SyncItem(ItemIndex)
SetItemBindState(ItemIndex,-2)
end

mong các bác chỉ em làm sao để có code mới nhập vào để nhận thưởng vậy