Frictional Games Forum (read-only)

Full Version: Area script. Help needed !
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi all !

So let's say I have a script area ( ScriptArea_1 for example ) on map "FirstFloor"
and I want it to get activated when I pick up a key (Key_1) on map GuestRooms.

So the ScriptArea_1 and the Key_1 are both on different maps.

I have no slightest idea what I need to do to get it work.
All help would be appreciated.

Thx. Cool
(02-07-2012, 09:12 PM)SpudroSpadre Wrote: [ -> ]Hi all !

So let's say I have a script area ( ScriptArea_1 for example ) on map "FirstFloor"
and I want it to get activated when I pick up a key (Key_1) on map GuestRooms.

So the ScriptArea_1 and the Key_1 are both on different maps.

I have no slightest idea what I need to do to get it work.
All help would be appreciated.

Thx. Cool
Here's a script Smile

Code:
void OnStart()

{

    AddEntityCollideCallback("Player", "NAMEOFAREA", "HasKey_func",
false, 1); // This will activate every time the player enters the area.

}

void HasKey_func(string &in asParent, string &in asChild,  int alState)

{

    if(HasItem("NAMEOFKEY")) // Checks if the player has the key

    {

    

    SetEntityActive("NAMEOFAREA", false);// This gets rid of the area, so the script will only run once.

    }



// If the player doesn't have the key, nothing happens.

}
tee global filu mappikansioon (global.hps). lisää sinne tällasta:

void OnGameStart()
{
SetGlobalVarInt("ToActivateOrNotTo", 0);
}

sitte sillon ku se joku tapahtuu et saat sen script arean toimimaan ni laitat sinne:
SetGlobalVarInt("ToActivateOrNotTo", 1);

eli global filussa toi variaabeli muuttuu nollasta ykköseks.

Sitte se mappi missä se area on:

////
void OnEnter()
{
GetGlobalVarInt("ToActivateOrNotTo");
{
if(GetGlobalVarInt("ToActivateOrNotTo") == 1)
{
//stuff you want done here
}
if(GetGlobalVarInt("ToActivateOrNotTo") == 0)
{
//nothing
}
}
}



edit. ninja'D
(02-07-2012, 09:27 PM)Khyrpa Wrote: [ -> ]tee global filu mappikansioon (global.hps). lisää sinne tällasta:

void OnGameStart()
{
SetGlobalVarInt("ToActivateOrNotTo", 0);
}

sitte sillon ku se joku tapahtuu et saat sen script arean toimimaan ni laitat sinne:
SetGlobalVarInt("ToActivateOrNotTo", 1);

eli global filussa toi variaabeli muuttuu nollasta ykköseks.

Sitte se mappi missä se area on:

////
void OnEnter()
{
GetGlobalVarInt("ToActivateOrNotTo");
{
if(GetGlobalVarInt("ToActivateOrNotTo") == 1)
{
//stuff you want done here
}
if(GetGlobalVarInt("ToActivateOrNotTo") == 0)
{
//nothing
}
}
}



edit. ninja'D
Hi khyrpa ^^


(02-07-2012, 09:22 PM)SilentStriker Wrote: [ -> ]
(02-07-2012, 09:12 PM)SpudroSpadre Wrote: [ -> ]Hi all !

So let's say I have a script area ( ScriptArea_1 for example ) on map "FirstFloor"
and I want it to get activated when I pick up a key (Key_1) on map GuestRooms.

So the ScriptArea_1 and the Key_1 are both on different maps.

I have no slightest idea what I need to do to get it work.
All help would be appreciated.

Thx. Cool
Here's a script Smile

Code:
void OnStart()

{

    AddEntityCollideCallback("Player", "NAMEOFAREA", "HasKey_func",
false, 1); // This will activate every time the player enters the area.

}

void HasKey_func(string &in asParent, string &in asChild,  int alState)

{

    if(HasItem("NAMEOFKEY")) // Checks if the player has the key

    {

    

    SetEntityActive("NAMEOFAREA", false);// This gets rid of the area, so the script will only run once.

    }



// If the player doesn't have the key, nothing happens.

}
Thx so much. Im gonna test it in a while. Wink

I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.
(02-08-2012, 03:12 AM)Ninami Wrote: [ -> ]I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
(02-08-2012, 03:40 AM)Your Computer Wrote: [ -> ]
(02-08-2012, 03:12 AM)Ninami Wrote: [ -> ]I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
Yeah that's true. But that makes me wonder, how about buttons on one map that opens a door on a different map? Would that work?
(02-08-2012, 04:44 AM)Ninami Wrote: [ -> ]
(02-08-2012, 03:40 AM)Your Computer Wrote: [ -> ]
(02-08-2012, 03:12 AM)Ninami Wrote: [ -> ]I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
Yeah that's true. But that makes me wonder, how about buttons on one map that opens a door on a different map? Would that work?
You would need a global variable for that.
(02-08-2012, 06:03 AM)flamez3 Wrote: [ -> ]
(02-08-2012, 04:44 AM)Ninami Wrote: [ -> ]
(02-08-2012, 03:40 AM)Your Computer Wrote: [ -> ]
(02-08-2012, 03:12 AM)Ninami Wrote: [ -> ]I haven't tried this my self but does that script really work even though they are on a different map? It just felt so easy, I thought it would be more complicated when you add more maps.

Inventory items carry on to the next map, so it should work.
Yeah that's true. But that makes me wonder, how about buttons on one map that opens a door on a different map? Would that work?
You would need a global variable for that.
I guess that exists? So it's theoretically possible?

Pages: 1 2