Frictional Games Forum (read-only)

Full Version: If player has lantern
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
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:
void OnStart()
{
SetGlobalVarInt("LanternVar"0);
SetEntityPlayerInteractCallback("Lantern""Setvar"true);
}

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


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

But nothing changes when player has item.
The first should work, although you really don't need that timer.

PHP Code:
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.
Yep it works now. Thanks.