s2bac95
23-11-15, 07:12 PM
Thao tác ở client:
Clear_XSCRIPT();
Set_XSCRIPT_Function_Name("GiftCode");
Set_XSCRIPT_ScriptID(id scipt);
Set_XSCRIPT_Parameter(0,xâu truyền về);
Set_XSCRIPT_ParamCount(1);
Send_XSCRIPT();
Script:
x990127_g_scriptId = 990127
x990127_g_MaxBagSize = 60
x990127_g_Key = {
1234567891,
}
--**********************************
-- ʼþ½»»¥Èë¿Ú
--**********************************
function x990127_OnDefaultEvent( sceneId, selfId )
if GetNumText() =100 then
x990127_Check(sceneId, selfId, 0,0)
end
end
--**********************************
--×°±¸¹¦ÄÜ
--**********************************
function x990127_BackToIndex( sceneId, selfId )
x399999_OnDefaultEvent( sceneId, selfId, -1 )
end
--**********************************
--Íæ¼ÒÆÁÄ»ÖмäÌáʾ
--**********************************
function x990127_Tips( sceneId, selfId, str )
BeginEvent( sceneId )
AddText( sceneId, str )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
--**********************************
--¶Ô»°´°¿ÚÐÅÏ¢Ìáʾ
--**********************************
function x990127_MsgBox( sceneId, selfId, msg )
BeginEvent( sceneId )
AddText( sceneId, msg )
EndEvent( sceneId )
DispatchEventList( sceneId, selfId, -1 )
end
--**********************************
--¹Ø±Õ¶Ô»°¿ò
--**********************************
function x990127_CloseMe(sceneId, selfId)
BeginUICommand(sceneId)
EndUICommand(sceneId)
DispatchUICommand(sceneId,selfId, 1000)
end
--**********************************
--ËæÉí¹¦ÄÜ
--**********************************
function x990127_Check(sceneId,selfId,key,isNPC)
if key==0 then
key=GetNumText()
end
if key==100 then
local strGUID = LuaFnGetGUID( sceneId, selfId )
local Is_Active = GetMissionData(sceneId, selfId, MD_ACTIVE_CODE)
BeginEvent(sceneId)
AddText(sceneId, " #GXin chào các hÕ! #r#WM¶i ch÷n nhæng chÑc nång h² trþ các hÕ c¥n.")
if (Is_Active <= 190000000) then
AddNumText(sceneId, x990127_g_scriptId,"#b#GNh§p Gift Code (C¥n 4 Ô tr¯ng)", 4, 114)
end
if isNPC==0 then
AddNumText(sceneId, x990127_g_scriptId,"Quay lÕi", 8, 8888)
else
end
EndEvent(sceneId)
DispatchEventList(sceneId,selfId,-1)
elseif key==114 then --doi gift code
BeginUICommand( sceneId )
UICommand_AddInt( sceneId, selfId )
EndUICommand( sceneId )
DispatchUICommand( sceneId, selfId, 12125185 )
end
end
--**********************************
--Gift Code
--**********************************
function x990127_GiftCode( sceneId, selfId, GiftCode)
local nam = LuaFnGetName( sceneId, selfId )
local Code=GiftCode;
local Is_Active = GetMissionData(sceneId, selfId, MD_ACTIVE_CODE)
--i=1;
local FreeSpace1 = LuaFnGetMaterialBagSpace( sceneId, selfId )
local FreeSpace2 = LuaFnGetPropertyBagSpace( sceneId, selfId )
if( FreeSpace1 < 2 ) then
x990127_NotifyFailTips( sceneId, selfId,"Khu nguyên li®u cüa bÕn không ðü ch² tr¯ng.");
x990127_CloseMe(sceneId, selfId)
elseif( FreeSpace2 < 7 ) then
x990127_NotifyFailTips( sceneId, selfId,"Khu v§t ph¦m cüa bÕn không ðü ch² tr¯ng.");
else
if(Is_Active <= 190000000) then
for i = 1,10 do
if (Code == x990127_g_Key[i]) then
local BindBagIndex1 = TryRecieveItem( sceneId, selfId, 39999901, QUALITY_CREATE_DEFAULT ) -- Vat pham
SetMissionData(sceneId, selfId, MD_ACTIVE_CODE, 200000001 )
x990127_NotifyFailTips( sceneId, selfId,"Chúc m×ng "..nam.." nh§n thß·ng thành công v¾i Code "..Code.." .");
return
end
end
x990127_NotifyFailTips( sceneId, selfId,"BÕn ðã nh§p sai Code");
else
x990127_NotifyFailTips( sceneId, selfId,"BÕn ðã nh§n thß·ng r°i!");
end
end
end
function x990127_MsgBox( sceneId, selfId, msg )
BeginEvent( sceneId )
AddText( sceneId, msg )
EndEvent( sceneId )
DispatchEventList( sceneId, selfId, -1 )
end
function x990127_NotifyFailTips( sceneId, selfId, Tip )
BeginEvent( sceneId )
AddText( sceneId, Tip )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
function x990127_Restore_hpmp( sceneId, selfId, targetId )
RestoreHp( sceneId, selfId )
RestoreMp( sceneId, selfId )
RestoreRage( sceneId, selfId )
end
nhớ khai náo hàm mới để cho client hiểu nhé !
http://i.imgur.com/YjyyvVY.png
Clear_XSCRIPT();
Set_XSCRIPT_Function_Name("GiftCode");
Set_XSCRIPT_ScriptID(id scipt);
Set_XSCRIPT_Parameter(0,xâu truyền về);
Set_XSCRIPT_ParamCount(1);
Send_XSCRIPT();
Script:
x990127_g_scriptId = 990127
x990127_g_MaxBagSize = 60
x990127_g_Key = {
1234567891,
}
--**********************************
-- ʼþ½»»¥Èë¿Ú
--**********************************
function x990127_OnDefaultEvent( sceneId, selfId )
if GetNumText() =100 then
x990127_Check(sceneId, selfId, 0,0)
end
end
--**********************************
--×°±¸¹¦ÄÜ
--**********************************
function x990127_BackToIndex( sceneId, selfId )
x399999_OnDefaultEvent( sceneId, selfId, -1 )
end
--**********************************
--Íæ¼ÒÆÁÄ»ÖмäÌáʾ
--**********************************
function x990127_Tips( sceneId, selfId, str )
BeginEvent( sceneId )
AddText( sceneId, str )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
--**********************************
--¶Ô»°´°¿ÚÐÅÏ¢Ìáʾ
--**********************************
function x990127_MsgBox( sceneId, selfId, msg )
BeginEvent( sceneId )
AddText( sceneId, msg )
EndEvent( sceneId )
DispatchEventList( sceneId, selfId, -1 )
end
--**********************************
--¹Ø±Õ¶Ô»°¿ò
--**********************************
function x990127_CloseMe(sceneId, selfId)
BeginUICommand(sceneId)
EndUICommand(sceneId)
DispatchUICommand(sceneId,selfId, 1000)
end
--**********************************
--ËæÉí¹¦ÄÜ
--**********************************
function x990127_Check(sceneId,selfId,key,isNPC)
if key==0 then
key=GetNumText()
end
if key==100 then
local strGUID = LuaFnGetGUID( sceneId, selfId )
local Is_Active = GetMissionData(sceneId, selfId, MD_ACTIVE_CODE)
BeginEvent(sceneId)
AddText(sceneId, " #GXin chào các hÕ! #r#WM¶i ch÷n nhæng chÑc nång h² trþ các hÕ c¥n.")
if (Is_Active <= 190000000) then
AddNumText(sceneId, x990127_g_scriptId,"#b#GNh§p Gift Code (C¥n 4 Ô tr¯ng)", 4, 114)
end
if isNPC==0 then
AddNumText(sceneId, x990127_g_scriptId,"Quay lÕi", 8, 8888)
else
end
EndEvent(sceneId)
DispatchEventList(sceneId,selfId,-1)
elseif key==114 then --doi gift code
BeginUICommand( sceneId )
UICommand_AddInt( sceneId, selfId )
EndUICommand( sceneId )
DispatchUICommand( sceneId, selfId, 12125185 )
end
end
--**********************************
--Gift Code
--**********************************
function x990127_GiftCode( sceneId, selfId, GiftCode)
local nam = LuaFnGetName( sceneId, selfId )
local Code=GiftCode;
local Is_Active = GetMissionData(sceneId, selfId, MD_ACTIVE_CODE)
--i=1;
local FreeSpace1 = LuaFnGetMaterialBagSpace( sceneId, selfId )
local FreeSpace2 = LuaFnGetPropertyBagSpace( sceneId, selfId )
if( FreeSpace1 < 2 ) then
x990127_NotifyFailTips( sceneId, selfId,"Khu nguyên li®u cüa bÕn không ðü ch² tr¯ng.");
x990127_CloseMe(sceneId, selfId)
elseif( FreeSpace2 < 7 ) then
x990127_NotifyFailTips( sceneId, selfId,"Khu v§t ph¦m cüa bÕn không ðü ch² tr¯ng.");
else
if(Is_Active <= 190000000) then
for i = 1,10 do
if (Code == x990127_g_Key[i]) then
local BindBagIndex1 = TryRecieveItem( sceneId, selfId, 39999901, QUALITY_CREATE_DEFAULT ) -- Vat pham
SetMissionData(sceneId, selfId, MD_ACTIVE_CODE, 200000001 )
x990127_NotifyFailTips( sceneId, selfId,"Chúc m×ng "..nam.." nh§n thß·ng thành công v¾i Code "..Code.." .");
return
end
end
x990127_NotifyFailTips( sceneId, selfId,"BÕn ðã nh§p sai Code");
else
x990127_NotifyFailTips( sceneId, selfId,"BÕn ðã nh§n thß·ng r°i!");
end
end
end
function x990127_MsgBox( sceneId, selfId, msg )
BeginEvent( sceneId )
AddText( sceneId, msg )
EndEvent( sceneId )
DispatchEventList( sceneId, selfId, -1 )
end
function x990127_NotifyFailTips( sceneId, selfId, Tip )
BeginEvent( sceneId )
AddText( sceneId, Tip )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )
end
function x990127_Restore_hpmp( sceneId, selfId, targetId )
RestoreHp( sceneId, selfId )
RestoreMp( sceneId, selfId )
RestoreRage( sceneId, selfId )
end
nhớ khai náo hàm mới để cho client hiểu nhé !
http://i.imgur.com/YjyyvVY.png