Frictional Games Forum (read-only)

Full Version: function not working, is something wrong?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to make an event when the player uses a glass jar on an Area, so he leaves the jar on the ground to fill it with dripping oil.

First of all, how can I do it so the player can use an item on an Area? It just doesn't highlight the item when I come close to the area with the item equipped.

Well I couldnt figure this out so I tried out using it on a hatch just to see if the rest worked. But the rest didn't work.

this is under void OnStart:

Code:
AddUseItemCallback("", "container1", "hatch_metal01_2", "JarUsed", false);

then

Code:
void JarUsed (string &in asItem, string &in asEntity)
{
     StartPlayerLookAt("Jar1", 3, 3, "");
     RemoveItem("container1");
    
     AddTimer("111", 2, "TimerLookAtEvents");
}

Firstsly, when I used the jar on the hatch, it simply disappeared and he wouldnt even look at the Jar1 Area. Then I played around with the code and it ended up like it is above, but now when I try to use the jar on the hatch, it won't even use it, it says "Cannot use the item this way" and nothing happens.

Its weird because I used the same drill when you use a key on a door, and it works. I learned it from the video tutorial on the wiki on how to use a key on a door.

Can someone help me out? I'm lost Sad[/code]
Quote:AddUseItemCallback("", "container1", "hatch_metal01_2", "JarUsed", false);

Put this inside the onEnter instead of the onStart.
thanks Big Grin
any idea on how to make it so I can use the item on an Area instead of an entity?
Create a scriptarea in the map editor. In the settings of that area you can add item interaction.
Then add that scriptarea in your AddUseItemCallback.
Thanks, that worked. Also, another problem came up. Its the same problem I had when using the jar on the hatch, but now putting the function in OnEnter wont work either.

Code:
void LeverUsed (string &in asItem, string &in asEntity)
{
     SetPropObjectStuckState("lever_small01_1", 0);
     CreateParticleSystemAtEntity("oilused", "sh", "area_leveroil", false);
     PlaySoundAtEntity("", "16_grease_lever", "area_leveroil", 0, false);
}

Code:
void OnEnter()
     {
AddUseItemCallback("", "oiljar", "lever_small01_1", "LeverUsed", false);
}
The only thing that works in this function is the sound. Whats going on here???
Not sure about the SetPropObjectStuckState, but for the Particle System you have to specify the name of the particle system file you want to create

example :
CreateParticleSystemAtEntity ("oilused", "ps_steam.ps" "area_leveroil", false);

Oilused is the name of the particle system being created, ps_steam.ps is the name of the file for the particle system (whatever file you want to use) and area_leveroil is the name of the entity at which you are creating it.
I realised I was typing a wrong .ps file name. Oh well.

Anyway, I want the lever to be unstuck after I use the oil and it's not working