Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Need help with hazards
ooadrianoo Offline
Member

Posts: 82
Threads: 29
Joined: Apr 2012
Reputation: 0
#1
Need help with hazards

This is my first contacts with hazards.
There are 5 barrels. The barrels should be spawn randomly, and should removed randomly.
Here is my script:
PHP Code: (Select All)
void OnStart()
{
int iBarrel RandFloat(16);



AddTimer("remove_barrel"2"Remove_Barrel_Timer");

AddTimer("barrel"1"BarrelTimer");
}

void BarrelTimer(string &in asTimer)
{
SetEntityActive("barrel_" +iBarrel true);
AddTimer("barrel"3"BarrelTimer");
}



void Remove_Barrel_Timer(string &in asTimer)
{
if (
GetEntityExists("barrel_" +iBarrel) == true)
{
SetEntityActive("barrel_" +iBarrelfalse);
AddTimer("remove_barrel"5"Remove_Barrel_Timer");
}


Can anyone tell me, that I have done false?
09-22-2012, 01:55 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: Need help with hazards

Try RandInt instead of RandFloat; The game is generating a random decimal between 1 & 6, but I'm assuming the names of the barrels in the level editor (that you're trying to set active) are just integers (i.e. "barrel_1", not "barrel_1.241")

Scripting isn't my cup of tea, but I hope that helped!

I rate it 3 memes.
09-22-2012, 02:02 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#3
RE: Need help with hazards

You declared iBarrel locally, but tried to access it as if it were declared in the global scope.

Tutorials: From Noob to Pro
09-22-2012, 02:03 AM
Website Find
ooadrianoo Offline
Member

Posts: 82
Threads: 29
Joined: Apr 2012
Reputation: 0
#4
RE: Need help with hazards

Please can you post a right script?

I come from Germany so I can't understand everything you write.
09-22-2012, 02:05 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#5
RE: Need help with hazards

You don't explain much in what exactly you're trying to achieve, nor does your code allow me to make safe assumptions. Nevertheless, i'd rewrite your code like so:

PHP Code: (Select All)
void OnStart()
{
    
AddTimer("barrel_"+RandInt(16), 1"ActivateBarrel");
}

void ActivateBarrel(string &in barrel)
{
    
SetEntityActive(barreltrue);
    
AddTimer(barrel2"RemoveBarrel");
}

void RemoveBarrel(string &in barrel)
{
    
SetEntityActive(barrelfalse);


Tutorials: From Noob to Pro
(This post was last modified: 09-22-2012, 02:17 AM by Your Computer.)
09-22-2012, 02:16 AM
Website Find
ooadrianoo Offline
Member

Posts: 82
Threads: 29
Joined: Apr 2012
Reputation: 0
#6
RE: Need help with hazards

(09-22-2012, 02:16 AM)Your Computer Wrote: You don't explain much in what exactly you're trying to achieve, nor does your code allow me to make safe assumptions. Nevertheless, i'd rewrite your code like so:

PHP Code: (Select All)
void OnStart()
{
    
AddTimer("barrel_"+RandInt(16), 1"ActivateBarrel");
}

void ActivateBarrel(string &in barrel)
{
    
SetEntityActive(barreltrue);
    
AddTimer(barrel2"RemoveBarrel");
}

void RemoveBarrel(string &in barrel)
{
    
SetEntityActive(barrelfalse);



I just wanted to set random barrels active. So if they is a barrel active (checked by GetEntityExists), then this barrel should be deactivated in a few seconds.

This process should not stop.
09-22-2012, 09:44 AM
Find
WALP Offline
Posting Freak

Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation: 45
#7
RE: Need help with hazards

barrels?, I sense a pewdiepie themed custom story here.
just saying
09-22-2012, 10:24 AM
Find




Users browsing this thread: 1 Guest(s)