leertaste Posted February 6, 2013 Posted February 6, 2013 (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 February 6, 2013 by leertaste Quote
michaelsoftman Posted February 6, 2013 Posted February 6, 2013 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; } Like that you mean? 1 Quote
leertaste Posted February 6, 2013 Author Posted February 6, 2013 so are 5002 and 5003 also included? i dont think so :S i want that the item ids from 5001 - 5004 are included without typing "5001, 5002, 5003, 5004" Quote
Euphy Posted February 6, 2013 Posted February 6, 2013 *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. 2 Quote
leertaste Posted February 6, 2013 Author Posted February 6, 2013 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? Quote
michaelsoftman Posted February 6, 2013 Posted February 6, 2013 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; } Quote
Question
leertaste
I want to use an announcement when someone opens a special created box:
this is my function
what i want to know:
is it possible to press the 5001, 5002, 5003, 5004 into sth like 5001 - 5004?
Edited by leertaste5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.