Frictional Games Forum (read-only)
Help with hps script! (OnPickup) - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Help with hps script! (OnPickup) (/thread-14156.html)



Help with hps script! (OnPickup) - Fozzarn - 03-21-2012

Hi, so i saw the Activate Enemy on Item Pickup guide, but i wonder can u activate props? like statues? I tried , and no error is given when launching Amnesia, but when i pick up the key nothing happens...

I do have lots of other scripts working, so i know that i placed SetEntity, void OnPickup and dat shit on the right place. below is NOT my whole hps file, only the lines needed. I am also sure dat my key name is "key4"
Heres my Hps:

SetEntityCallbackFunc("key_4", "OnPickup");


void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("ac1", true);
SetEntityActive("ac2", true);
SetEntityActive("ac3", true);
SetEntityActive("ac4", true);
SetEntityActive("ac5", true);
SetEntityActive("ac6", true);
SetEntityActive("ac7", true);
SetEntityActive("ac8", true);
SetEntityActive("bt1", true);
SetEntityActive("bt2", true);
SetEntityActive("bt3", true);
SetEntityActive("bt4", true);
GiveSanityDamage(10.0f, true);
PlaySoundAtEntity("", "00_laugh.snt", "Player", 0, false);
}



RE: Help with hps script! (OnPickup) - Statyk - 03-21-2012

I'm not sure if this is it but a game can run a whole script without any fatal errors if a syntax is incorrect. So the game runs, but that function does not work. Try changing the callback to this:

void OnPickup(string &in asEntity, string &in asType)



RE: Help with hps script! (OnPickup) - pandasFTW - 03-21-2012

(03-21-2012, 06:01 PM)Fozzarn Wrote: Hi, so i saw the Activate Enemy on Item Pickup guide, but i wonder can u activate props? like statues? I tried , and no error is given when launching Amnesia, but when i pick up the key nothing happens...

I do have lots of other scripts working, so i know that i placed SetEntity, void OnPickup and dat shit on the right place. below is NOT my whole hps file, only the lines needed. I am also sure dat my key name is "key4"
Heres my Hps:

SetEntityCallbackFunc("key_4", "OnPickup");


void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("ac1", true);
SetEntityActive("ac2", true);
SetEntityActive("ac3", true);
SetEntityActive("ac4", true);
SetEntityActive("ac5", true);
SetEntityActive("ac6", true);
SetEntityActive("ac7", true);
SetEntityActive("ac8", true);
SetEntityActive("bt1", true);
SetEntityActive("bt2", true);
SetEntityActive("bt3", true);
SetEntityActive("bt4", true);
GiveSanityDamage(10.0f, true);
PlaySoundAtEntity("", "00_laugh.snt", "Player", 0, false);
}
this is just a wild guess... really i,ve never tried it myself.
but you could try to replace the " SetEntityCallbackFunc " with "SetEntityPlayerInteractCallback"
here is what the engine scripts page says about that


void SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
Calls a function when the player interacts with a certain entity.
Callback
syntax: void MyFunc(string &in asEntity)
asName - internal name
asCallback - function to
call
abRemoveOnInteraction - determines whether the callback should
be removed when the player interacts with the entity
good luck Smile




RE: Help with hps script! (OnPickup) - Fozzarn - 03-21-2012

Hmm, tried to replace
SetEntityCallbackFunc("key_4", "OnPickup");

with
SetEntityPlayerInteractCallback("key4", "OnPickup", false);

but same results Sad not working :/

Also tried to fix
void OnPickup(string &in asEntity, string &in asType)


but nothing Sad


RE: Help with hps script! (OnPickup) - pandasFTW - 03-21-2012

the only thing i can see wrong in that is then,,,,
you said your key name was key4 but in the script it says key_4 ... i dont know if that was a spellling mistake or??? oh and note : SCRIPTS ARE CASE SENSITIVE!!! if the key in the editor is Key4 and the name in the script is key4 with a small " k " it wont read it as a script, so make sure that is right too.



RE: Help with hps script! (OnPickup) - Fozzarn - 03-21-2012

(03-21-2012, 06:34 PM)pandasFTW Wrote: the only thing i can see wrong in that is then,,,,
you said your key name was key4 but in the script it says key_4 ... i dont know if that was a spellling mistake or??? oh and note : SCRIPTS ARE CASE SENSITIVE!!! if the key in the editor is Key4 and the name in the script is key4 with a small " k " it wont read it as a script, so make sure that is right too.
What the actual fu** ... something is messing with my scripts... some of the enteties had changed name to like ac61 and so on and now key_4 ?? yeah its working now Smile thanks lad!


RE: Help with hps script! (OnPickup) - pandasFTW - 03-21-2012

haha
you are very much welcome Smile PM me anytime if ur' in need of help