|
トップ > MAP作成 > Jass Script > ライブラリ集 > メッセージ表示 ライブラリlibrary ShowMsg initializer init
globals
private sound snd_Error
private sound snd_Warning
private sound snd_Hint
integer SHOWMSG_MSGTYPE_ERROR = 1
integer SHOWMSG_MSGTYPE_WARN = 2
integer SHOWMSG_MSGTYPE_HINT = 3
endglobals
private function init takes nothing returns nothing
set snd_Error = CreateSound("Sound\\Interface\\Error.wav" , false , false , false , 10 , 10 , "")
call SetSoundParamsFromLabel(snd_Error , "InterfaceError")
call SetSoundDuration(snd_Error , 614)
set snd_Hint = CreateSound("Sound\\Interface\\Hint.wav" , false , false , false , 10 , 10 , "")
//call SetSoundParamsFromLabel(snd_Hint , "Hint")
call SetSoundDuration(snd_Hint , 2006)
set snd_Warning = CreateSound("Sound\\Interface\\Warning.wav" , false , false , false , 10 , 10 , "")
//call SetSoundParamsFromLabel(snd_Warning , "Warning")
call SetSoundDuration(snd_Warning , 1904)
endfunction
function ShowMsgToPlayer takes player p,string Message, integer msg_type returns nothing
local string colorcode = ""
if (msg_type==SHOWMSG_MSGTYPE_ERROR) then
set colorcode = "|cffffcc00"
call StartSound(snd_Error)
elseif (msg_type==SHOWMSG_MSGTYPE_WARN ) then
set colorcode = "|cffff0000"
call StartSound(snd_Warning)
elseif (msg_type==SHOWMSG_MSGTYPE_HINT ) then
set colorcode = ""
call StartSound(snd_Hint)
endif
call DisplayTextToPlayer(p , 1 , 0 , colorcode + Message + "|r")
endfunction
endlibrary
使い方これをどこかにコピペする。 使い方のサンプルプレイヤー1に、「Not enough gold.」というエラーメッセージを表示します。 call ShowMsgToPlayer(Player(0),"Not enough gold.",SHOWMSG_MSGTYPE_ERROR) 第3引数をSHOWMSG_MSGTYPE_WARNやSHOWMSG_MSGTYPE_HINTにすると、それぞれちがう音が再生されます。 |