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
If player has lantern
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#1
If player has lantern

Player gets lantern on map A. In map B an entity is supposed to be active when player has the item.

My first try (I like this better cause it seems simpler)
Map B
PHP Code: (Select All)
void OnStart()
{
AddTimer("LanternChecker"0.1f"haslantern");
}

void haslantern(string &in asTimer)
{
if(
HasItem("Lantern"))
{
SetEntityActive("Entity_Name"true);
}



My second try
Map A
PHP Code: (Select All)
void OnStart()
{
SetGlobalVarInt("LanternVar"0);
SetEntityPlayerInteractCallback("Lantern""Setvar"true);
}

void Setvar(string &in asEntity)
{
    
AddGlobalVarInt("LanternVar"1);


Map B
PHP Code: (Select All)
void OnEnter()
{
if(
GetGlobalVarInt("LanternVar")==1)
SetEntityActive("Entity_Name"true);
}

But nothing changes when player has item.
08-02-2015, 02:22 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: If player has lantern

The first should work, although you really don't need that timer.

PHP Code: (Select All)
void OnStart()
{
    if(
HasItem("Lantern"))
    {
        
SetEntityActive("Entity_Name"true);
    }


Just make sure your entity actually can be scripted with. Not all types can. StaticProp does not support activating/deactivating. Also, since this is in OnStart, not OnEnter, make sure this is the first time the player enters this map, not returning.

Is your entity actually inactive when you enter the map? Check for map_caches and internal names.

(This post was last modified: 08-02-2015, 03:33 PM by Mudbill.)
08-02-2015, 03:32 PM
Find
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#3
RE: If player has lantern

Yep it works now. Thanks.
08-02-2015, 04:03 PM
Find




Users browsing this thread: 1 Guest(s)