Jump to content
  • 0

Random option script won't work without error


Question

Posted (edited)
-	script	RandomWeaponOption	-1,{

 OnNPCKillEvent:
 // ตรวจสอบว่า Monster ดรอปอาวุธหรือไม่
 if (getiteminfo(killmonsterloot, 2) == 4) { // เช็คว่าของดรอปเป็นประเภทอาวุธ
 set .@weapon_id, killmonsterloot; // เก็บ Weapon ID ที่ดรอปจากมอนสเตอร์
 set .@option_rows, 1; // เริ่มต้นจำนวนแถว Option

 // สุ่มจำนวนแถว Option
 if (rand(100) < 50) set .@option_rows, 2; // โอกาส 50% สำหรับแถวที่ 2
 if (rand(100) < 30) set .@option_rows, 3; // โอกาส 30% สำหรับแถวที่ 3
 if (rand(100) < 10) set .@option_rows, 4; // โอกาส 10% สำหรับแถวที่ 4

 // ตั้งค่าตัวแปรสำหรับ Option
 setarray .@option_id[0], 0, 0, 0, 0;
 setarray .@option_value[0], 0, 0, 0, 0;

 // กำหนด Option ให้กับแถวที่มีโอกาสสำเร็จ
 for (set .@i, 1; .@i <= .@option_rows; set .@i, .@i + 1) {
 set .@option_id[.@i - 1], rand(4001, 4035);  // สุ่ม Option ID (ตัวอย่าง 4001-4035)
 set .@option_value[.@i - 1], rand(1, 10);    // สุ่มค่า Option (1-10)
 }

 // สร้างอาวุธพร้อม Option
 makeitem2 .@weapon_id, 1, getcharid(CHAR_ID_ACCOUNT), 0, 0, 
 .@option_id[0], .@option_value[0], 
 .@option_id[1], .@option_value[1], 
 .@option_id[2], .@option_value[2], 
 .@option_id[3], .@option_value[3];
 dispbottom "คุณได้รับอาวุธพร้อม Option!";
 }
 end;
}

It Dont Error and Dont work too.

Edited by Rynbef
Uninformative topic title

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

If it doesn't work and doesn't cause an error, the problem may lie in how the script handles specific game engine mechanics or how the OnNPCKillEvent trigger interacts with killmonsterloot

among us
 

Edited by AllanPfeffer
  • 0
Posted
On 1/2/2025 at 4:17 PM, AllanPfeffer said:

If it doesn't work and doesn't cause an error, the problem may lie in how the script handles specific game engine mechanics or how the OnNPCKillEvent trigger interacts with killmonsterloot

among us
 

Can you test it?

i cant fix it.

  • 0
Posted
On 12/22/2024 at 10:19 PM, ooGubAoo said:
-	script	RandomWeaponOption	-1,{

 OnNPCKillEvent:
 // ตรวจสอบว่า Monster ดรอปอาวุธหรือไม่
 if (getiteminfo(killmonsterloot, 2) == 4) { // เช็คว่าของดรอปเป็นประเภทอาวุธ
 set .@weapon_id, killmonsterloot; // เก็บ Weapon ID ที่ดรอปจากมอนสเตอร์
 set .@option_rows, 1; // เริ่มต้นจำนวนแถว Option

 // สุ่มจำนวนแถว Option
 if (rand(100) < 50) set .@option_rows, 2; // โอกาส 50% สำหรับแถวที่ 2
 if (rand(100) < 30) set .@option_rows, 3; // โอกาส 30% สำหรับแถวที่ 3
 if (rand(100) < 10) set .@option_rows, 4; // โอกาส 10% สำหรับแถวที่ 4

 // ตั้งค่าตัวแปรสำหรับ Option
 setarray .@option_id[0], 0, 0, 0, 0;
 setarray .@option_value[0], 0, 0, 0, 0;

 // กำหนด Option ให้กับแถวที่มีโอกาสสำเร็จ
 for (set .@i, 1; .@i <= .@option_rows; set .@i, .@i + 1) {
 set .@option_id[.@i - 1], rand(4001, 4035);  // สุ่ม Option ID (ตัวอย่าง 4001-4035)
 set .@option_value[.@i - 1], rand(1, 10);    // สุ่มค่า Option (1-10)
 }

 // สร้างอาวุธพร้อม Option
 makeitem2 .@weapon_id, 1, getcharid(CHAR_ID_ACCOUNT), 0, 0, 
 .@option_id[0], .@option_value[0], 
 .@option_id[1], .@option_value[1], 
 .@option_id[2], .@option_value[2], 
 .@option_id[3], .@option_value[3];
 dispbottom "คุณได้รับอาวุธพร้อม Option!";
 }
 end;
}

It Dont Error and Dont work t

 

Find: for (set .@i, 1; .@i <= .@option_rows; set .@i, .@i + 1) {

Replace: for (.@i = 1; .@i <= .@option_rows; .@i++) {

 

Find: makeitem2 .@weapon_id, 1, getcharid(CHAR_ID_ACCOUNT), 0, 0, 

Replace: makeitem2 .@weapon_id, 1, getcharid(0), 0, 0, 

 

Not tested

  • 0
Posted
23 hours ago, Mice said:

 

Find: for (set .@i, 1; .@i <= .@option_rows; set .@i, .@i + 1) {

Replace: for (.@i = 1; .@i <= .@option_rows; .@i++) {

 

Find: makeitem2 .@weapon_id, 1, getcharid(CHAR_ID_ACCOUNT), 0, 0, 

Replace: makeitem2 .@weapon_id, 1, getcharid(0), 0, 0, 

 

Not tested

Not work.

It dont have option.

screenFree2Play000.jpg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...