Frictional Games Forum (read-only)

Full Version: Activating a monster
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I've written a script thats supposed to allow me to activate an enemy when my player picks up a note. It hasn't been working no matter what.No error messages pop up so I scratched and starting over on that script . So could anyone help me with that code?
Copy the code and we'll help you find out what's wrong : > ?
Also, did you check that the names were the same in the script and in the level editor ?
void Onstart ()
{
SetEntityCallbackFunc ("note_generic_4", "pickup");
}
void pickup(string &in ent, string &in t)
{
If(t == "OnPickup")
{
SetEntityActive("servant_brute_1", true);
}
}
PHP Code:
void OnStart()
{
SetEntityCallbackFunc("NoteName""SetBrute");
}

void SetBrute(string &in asEntitystring &in type)
{
SetEntityActive("servant_brute_1"true);
}

//NoteName is the name of the note.
//SetBrute is the name of the callback function.
//(string &in asEntity, string &in type) is the callback syntax. Your syntax is incorrect. 
LazyHarry is da god, he answered faster than me <3. Still I agree with him, even though I usuallly don't use the callbackfunc function : ).
Okay, here is what you did wrong. Pay close attention.
Spoiler below!

PHP Code:
void Onstart () //WRONG. Should be void OnStart()
{
      
SetEntityCallbackFunc ("note_generic_4""pickup"); //Should be SetEntityCallbackFunc WITH NO SPACES.
}
void pickup(string &in entstring &in t//The callback syntax is incorrect; should be (string &in asEntity, string &in type)
{
      If(
== "OnPickup"//Can you please define what t is? Is it the note? Function? Declaring something without specifying it earlier.
       
{
              
SetEntityActive("servant_brute_1"true);
       }
}
//NOTE: Every grammar and word HAS to be correct. Any spaces or typo's will render your whole script not working. 


@daortir
Usually I use A LOT of SECF's to define OnLit and OnPickup because I can use SECF's to define the functions, rather than the hassle and extra work of finding the correct function for the scripts I want.