Jump to content
  • 0

Box Announcement


Question

Posted (edited)

I want to use an announcement when someone opens a special created box:

this is my function

function script F_GiftBoxFunc {
SetArray( .@MyItems[ 0 ], 5001, 5002, 5003, 5004 ); // ..
set .@ItemID, .@MyItems[ Rand( GetArraySize( .@MyItems ) - 1 ) ];
set .@ItemCount, 1;
GetItem( .@ItemID, .@ItemCount );
Announce( "" + strcharinfo(0) + " opened a headgear box and got: " + GetItemName( .@ItemID ) + " !", BC_ALL );
end;
}

what i want to know:

is it possible to press the 5001, 5002, 5003, 5004 into sth like 5001 - 5004?

Edited by leertaste

5 answers to this question

Recommended Posts

Posted
*rand(<number>{,<number>});

This function returns a number ...

(if you specify one) ... randomly positioned between 0 and the number you specify -1.

(if you specify two) ... randomly positioned between the two numbers you specify.

rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9

rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9

rand(2,5) would result in 2,3,4 or 5

Look up commands you're unsure about in trunk/doc/script_commands.txt.

  • Upvote 2
Posted

ah, good to know!

thanks!

Okay next thing... :$

This works great:

function script F_GiftBoxFunc {
set .@ItemID, rand(5001,5004);
GetItem( .@ItemID, 1 );
Announce( "" + strcharinfo(0) + " opened a headgear box and got: " + GetItemName( .@ItemID ) + " !", BC_ALL );
end;
}

But what i want to add now is (for example) something like that:

IDs from 5001-5004 + IDs 5050-5080

Can someone help? :)

Posted
function script F_GiftBoxFunc {
set .@rand, rand(1,2);
if (.@rand == 1) {
set .@ItemID, rand(5001,5004);
}
else {
set .@ItemID, rand(5050,5080);
}
GetItem( .@ItemID, 1 );
Announce( "" + strcharinfo(0) + " opened a headgear box and got: " + GetItemName( .@ItemID ) + " !", BC_ALL );
end;
}

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...