Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Integer Script doesn't work please help
Author Message
X4anco Offline
Member

Posts: 140
Joined: Apr 2011
Reputation: 0
Post: #1
Random Integer Script doesn't work please help
Hello peoples,
Is there a function that will choose a random whole number between 1-7
and set it as a variable integer?

Thank-you Big Grin

I like poop
(This post was last modified: 08-06-2011 03:09 PM by X4anco.)
08-06-2011 02:18 PM
Find all posts by this user Quote this message in a reply
Juby Away
Senior Member

Posts: 285
Joined: May 2011
Reputation: 5
Post: #2
RE: Random Variable Integer
Yes, but it's not a function.

int Example = RandInt(1, 7);

later on, you can use it in an if statement like: if(Example == 1)

Forever passing judgement compared to a fraud.
(This post was last modified: 08-06-2011 02:24 PM by Juby.)
08-06-2011 02:22 PM
Find all posts by this user Quote this message in a reply
X4anco Offline
Member

Posts: 140
Joined: Apr 2011
Reputation: 0
Post: #3
RE: Random Variable Integer
Thank-you Big Grin Big Grin Big Grin Big Grin
Now I has a problem with my script Sad


void ScarySoundsTimer(string &in asTimer)
{
int ScarySoundsVar = RandInt(1, 2, 3, 4, 5, 6, 7);
switch(GetLocalVarInt(ScarySoundsVar)){
case 1:
PlaySoundAtEntity("babycry", "scare_baby_cry.snt", "Player", 0.2, false);
AddTimer("", 20, "ScarySoundsTimer");
break;

case 2:
PlaySoundAtEntity("babycry", "scare_animal_squeal.snt", "Player", 0.2, false);
AddTimer("", 16, "ScarySoundsTimer");
break;

case 3:
PlaySoundAtEntity("babycry", "scare_male_terrified.snt", "Player", 0.2, false);
AddTimer("", 25, "ScarySoundsTimer");
break;

case 4:
PlaySoundAtEntity("babycry", "scare_wood_creak_walk.snt", "Player", 0.2, false);
AddTimer("", 13, "ScarySoundsTimer");
break;

case 5:
PlaySoundAtEntity("babycry", "scare_steps_big.snt", "Player", 0.2, false);
AddTimer("", 19, "ScarySoundsTimer");
break;

case 6:
PlaySoundAtEntity("babycry", "scare_wood_creak_scuf.snt", "Player", 0.2, false);
AddTimer("", 19, "ScarySoundsTimer");
break;

case 7:
PlaySoundAtEntity("babycry", "insanity_baby_cry.snt", "Player", 0.2, false);
AddTimer("", 19, "ScarySoundsTimer");
break;
}
}

void ScarySounds(string &in asParent, string &in asChild, int alState)
{
SetLocalVarInt("ScarySoundsVar", 0);
AddTimer("quescary", 5, "ScarySoundsTimer");
}


Can you see where I go wrong?

I like poop
(This post was last modified: 08-06-2011 02:50 PM by X4anco.)
08-06-2011 02:24 PM
Find all posts by this user Quote this message in a reply
Juby Away
Senior Member

Posts: 285
Joined: May 2011
Reputation: 5
Post: #4
RE: Random Integer Script doesn't work please help
void ScarySoundsTimer(string &in asTimer)
{
int ScarySoundsVar = RandInt(1, 7);
switch(ScarySoundsVar)
{
case 1:
PlaySoundAtEntity("babycry", "scare_baby_cry.snt", "Player", 0.2, false);
AddTimer("", 20, "ScarySoundsTimer");
break;

case 2:
PlaySoundAtEntity("babycry", "scare_animal_squeal.snt", "Player", 0.2, false);
AddTimer("", 16, "ScarySoundsTimer");
break;

case 3:
PlaySoundAtEntity("babycry", "scare_male_terrified.snt", "Player", 0.2, false);
AddTimer("", 25, "ScarySoundsTimer");
break;

case 4:
PlaySoundAtEntity("babycry", "scare_wood_creak_walk.snt", "Player", 0.2, false);
AddTimer("", 13, "ScarySoundsTimer");
break;

case 5:
PlaySoundAtEntity("babycry", "scare_steps_big.snt", "Player", 0.2, false);
AddTimer("", 19, "ScarySoundsTimer");
break;

case 6:
PlaySoundAtEntity("babycry", "scare_wood_creak_scuf.snt", "Player", 0.2, false);
AddTimer("", 19, "ScarySoundsTimer");
break;

case 7:
PlaySoundAtEntity("babycry", "insanity_baby_cry.snt", "Player", 0.2, false);
AddTimer("", 19, "ScarySoundsTimer");
break;
}
}

void ScarySounds(string &in asParent, string &in asChild, int alState)
{
SetLocalVarInt("ScarySoundsVar", 0);
AddTimer("quescary", 5, "ScarySoundsTimer");
}

The RandInt command picks a number between the two including the max and min values.
Smile

Forever passing judgement compared to a fraud.
(This post was last modified: 08-06-2011 03:20 PM by Juby.)
08-06-2011 03:19 PM
Find all posts by this user Quote this message in a reply
X4anco Offline
Member

Posts: 140
Joined: Apr 2011
Reputation: 0
Post: #5
RE: Random Integer Script doesn't work please help
Thanks Big Grin Big Grin Big Grin Big Grin

I like poop
08-06-2011 03:35 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)