Frictional Games Forum (read-only)

Full Version: Same issue again; Activating a script area.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It seems simple, but for-the-love-of-god I just CAN'T get it to work. It's delaying my map and pisses me off. I just want a script area set to active when I pick up a rod. Here's my script.


void OnPickup(string &in asEntity, string &in type)
{
if(asEntity == "usekey")
{
StopPlayerLookAt();
}
else if(asEntity == "rod_2")
{
SetEntityActive("spawnmonster", true);
AddEntityCollideCallback("Player", "spawnmonster", "activatethegrunt", true, 1);
}
}

void activatethegrunt(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_4", true);
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_13", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_14", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_15", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_16", 0.001, "");
AddEnemyPatrolNode("servant_grunt_4", "PathNodeArea_17", 0.001, "");
}

The rod is called rod_2, the script area is called spawnmonster and is set inactive, the monster is called servant_grunt_4 and the pathnodes have the right name. And yes, the name of the map and the .hps are the same.
Such a script should have exited with an error. You closed the OnPickup function before the else-if statement.
I left out some other pickup-items while making this post and pasted this script together to keep it short, so I accidentely added that bracket. So no, that's not the problem. Good point though, I'll edit it.
Sometimes, at least for me, re-arranging the order of things fixes it. Try putting the monster active part after the callback.
give us the part about the pick up callback too, not just the resulting function. Might be something there that doesn't work?
Or does "usekey" inside OnPickup work? If so, check again if the script area in the level editor is really named "spawnmonster"
Nope, still not working.
Did you mean himynamebob1? because I asked something you couldn't answer with "still not working"
void OnPickup(string &in asEntity, string &in type)
{
if(asEntity == "usekey")
{
StopPlayerLookAt();

}
else if(asEntity == "lantern")
{
StopPlayerLookAt();
}
else if(asEntity == "MachineNote")
{
StartPlayerLookAt("puzzleholes", 2, 3, "");
SetMessage("Messages", "puzzleholes", 0);
AddTimer("Z1", 5, "lookatfirstbox");
AddTimer("Z2", 6.5, "lookatfirstbox");
SetPlayerActive(false);
}
else if(asEntity == "rod_2")
{
AddEntityCollideCallback("Player", "spawnmonster", "activatethegrunt", true, 1);
}
}

Yeah sorry FastHunteR my first reply was indeed meant for himynamebob1. But when I posted that your post wasn't there yet, probably due to my terribad internet. But here's my whole pickup script. And I can confirm the first three are working well. And I was messing around putting SetEntityActive in the last part and setting the script area in the level editor inactive and that kinda stuff, but that still didn't work.

And it is kinda weird, because in my very first problem with this this solved it;

void OnPickup(string &in asEntity, string &in type)
{
if(asEntity == "tocarnellroomkey")
{
AddEntityCollideCallback("Player", "pusharea", "Push", true, 1);
PlaySoundAtEntity("", "scare_male_terrified5.snt", "randomatticdoor", 2, false);
}

void Push(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "react_pant.snt", "push", 0, false);
AddPlayerBodyForce(0, 0, -45000, false);
GiveSanityDamage(15, true);
}

SECOND EDIT: I've added PlayGuiSound("break_glass_bottle.snt", 1); to else if(asEntity == "rod_2") and IT DOES NOT PLAY. So it has to be a problem with the pickup, but I have no idea what to fix, I do not get an error and the script doesn't seem out of the ordinary, and the rod is called rod_2.
the script you posted should work, make sure the script area is set active, and you don't need to set them inactive as long as you place the callback where it is needed. The script area will only "work" when there is a added callback for it in any way. You can of course set the script area inactive, but it's rarely needed.
FUCK YES. I finally got it working. I just used PlayerInteractCallback on the rod in the level editor and that worked out great. Yay!