Frictional Games Forum (read-only)

Full Version: Randomize door message
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do i randomize a door message? When a door's locked, and i touch it, it activates the playerinteract and in that script i want it to choose between random messages to display instead of one.


For example instead of just showing "It's locked" how do i manage to make it display random ones?

For example "It's not going to open" "It's useless" etc.



Not solved, i decided it would be best not to have random messages at that door.
PHP Code:
SetMessage("Category""Entry_"+RandInt(1,3), 0); 
SetMessage("Category", "Entry_"+RandInt(1,3), 0);




What do i put after entry?
(06-27-2012, 11:28 AM)CrazyArts Wrote: [ -> ]What do i put after entry?

An int: integer; number; not a decimal.
Will this work?


void DinnerMessage(string &in entity)
{
if(GetSwingDoorLocked("DinnerDoor") == true)
{
SetMessage("DoorMessages", "Entry_"+RandInt(1,3), 0);
}
}

.lang


<CATEGORY Name="DoorMessages">
<Entry Name="DinnerMSG">It won't budge.</Entry>
<Entry Name="DinnerMSG2">It's not going to open.</Entry>
<Entry Name="DinnerMSG3">I might aswell give up on this door.</Entry>
"It won't budge." won't show up if you use that entry. You have to understand RandInt before you can work with it.
How do i do it then? I want it to pick between those 3 messages on the door by the way.
http://wiki.frictionalgames.com/hpl2/amn...ns#general

Look at the argument for minimum value and look at the argument for maximum value. RandInt generates a random number no greater than maximum value and no lesser than minimum value. Do you understand now why the entry without a number at the end won't show up in game?
Not really Huh
RandInt(1,3) means minimum value is 1 and maximum value is 3. That means the only possible values that will be returned by that call are: 1, 2 or 3.

0, 4, etc, will not be returned from that call. This means only DinnerMSG1, DinnerMSG2, and DinnerMSG3 are possible since we are appending RandInt(1,3) to the end of the entry name.