Mysticphoenix   07-11-2012, 09:03 AM
#1
Me gusta

สคริปนี้โดยคุณ siliconHero จากเวบ rmxp.net ได้ถูกเอามาปรับปรุงโดย AgentMolder ให้ใส่รูปไอเทม และให้แสดงเงิน และเพิ่มภาษาไทยเข้าไป

ทำตามขั้นตอน

1.สร้าง script ใหม่ เหนือ main ใส่ชื่ออะไรก็ได้
2. copy script ข้างล่างไปแปะให้หมด

Quote:#==============================================================================
# ** Window_ItemAcquired By [email protected]
# Original Ver at Topic >> http://www.rmxp.net/forums/index.php?showtopic=24022
#------------------------------------------------------------------------------
#ปรับปรุงโดย AgentMolder
#วิธีใช้งาน ใน event ที่ได้รับ item ให้เรียกใช้คำสั่ง call script(เรียกใช้สคริป) แล้วพิมพ์บรรทัดด้านล่างลงไป
# Window_ItemAcquired.new(quantity, type, index)
#โดยค่าต่างๆ ตามนี้
# quantity = จำนวน item (หรือ จำนวนเงิน)
# type = ชนิดของ item ที่ได้รับ (1 = item, 2 = weapon, 3 = armor, 4 = เงิน)
# index = ตัวเลขแทน item (ดูได้จาก database โดยไม่ต้องใส่ 0 ด้านหน้า)
# **ถ้าเป็นจำนวนเงิน ให้ใส่ index เป็น 0
#==============================================================================
class Window_Base
def draw_a_name(item,x,y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x,y,bitmap, Rect.new(0,0,24, 24))
self.contents.font.color = crisis_color
self.contents.draw_text(x+28,y, 220, 32, item.name + " " + @quantity.to_s + " ชิ้น")
end
end

class Window_ItemAcquired < Window_Base
def initialize(quantity, type, index)
super(120, 200,450, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@quantity = quantity
@type = type
@index = index
self.pause = false
self.back_opacity = 127
self.contents.font.color = crisis_color
Audio.se_play("Audio/SE/056-Right02.ogg", 100, 100)
self.pause = true
while not Input.trigger?(Input::C)
Input.update
Graphics.update
self.contents.clear
case @type
# type: 1 = item, 2 = weapon, 3 = armor ,4 = เงิน
when 1
item = $data_items[@index]
self.contents.draw_text(4, 0, self.width - 40, 32, "ท่านได้รับ", 0)
draw_a_name(item,100,0)
when 2
item = $data_weapons[@index]
self.contents.draw_text(4, 0, self.width - 40, 32, "ท่านได้รับ", 0)
draw_a_name(item,100,0)
when 3
item = $data_armors[@index]
self.contents.draw_text(4, 0, self.width - 40, 32, "ท่านได้รับ", 0)
draw_a_name(item,100,0)
when 4
text = "ท่านได้รับ เงิน " + @quantity.to_s + " " + $data_system.words.gold
self.contents.draw_text(4, 0, self.width - 40, 32, text, 1)
end
end
self.dispose
end
end

วิธีใช้งาน
1. ใน event ที่เราต้องการแสดงผล เช่นหีบ หรือคุยกับคน หรืออะไรก็ตาม พอหีบเปิด หรือได้รับของดังกล่าว หรือตอนที่เราต้องการโชว์ของ ก็ให้เลือก "เรียกใช้สคริปต์" (อยู่ในหน้า event หน้าที่ 3 ตัวสุดท้าย)
2.พิมพิ์ว่า
Window_ItemAcquired.new(quantity, type, index)
โดย
-quantity = จำนวน item (หรือ จำนวนเงิน)
-type = ชนิดของ item ที่ได้รับ (1 = item, 2 = weapon, 3 = armor, 4 = เงิน)
-index = ตัวเลขแทน item (ดูได้จาก database โดยไม่ต้องใส่ 0 ด้านหน้า)
**ถ้าเป็นจำนวนเงิน ให้ใส่ index เป็น 0
เช่น เราต้องการให้เปิดหีบแล้วได้ item Potion จำนวน 2 ชิ้น ก็ให้ใส่ดังนี้

Quote:Window_ItemAcquired.new(2, 1, 1)

2 คือจำนวน potion ที่ได้รับ
1 แสดงถึงสิ่งนั้นเป็น item
1 แสดงถึง ไอเทม Potion ที่อยู่ในลำดับที่ 1 ใน database

หรือ เราต้องการให้ได้เงิน 100 ก็ใส่ไปว่า
Quote:Window_ItemAcquired.new(100,4,0)

ลองเอาไปใช้ดูนะครับ

Credit : siliconHero, AgentMolder
This post was last modified: 07-11-2012, 09:04 AM by Mysticphoenix.

[Image: webboard%20signature1_zpskhtut2jg.png]
การทำอาหารที่อร่อยที่สุด และเดือดร้อนชาวบ้านมากที่สุด กำลังจะเริ่มขึ้น
  
Users browsing this thread: 1 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.