Frictional Games Forum (read-only)

Full Version: Collide function issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello everybody on the forum, this is me Badcat with another stupid problem that never works.

So the problem here is that I made tons of script areas which goes active in a certian timer, every 1 second a script area appears one after another. Like so
[Image: YxPys81.png?1]

Now when the player collides with the area, it should kill him instantly but ofc everything bad happens to me so it doesn't work.

I also made this in void OnStart
PHP Code:
for(int i=1i<=28; ++iAddEntityCollideCallback("Player""ScriptArea_"+i"Diecollide"false1); 
which is for every area, and this too
PHP Code:
void Diecollide(string &in asParentstring &in asChildint alState
{    
    
AddPlayerHealth(-200);


Of what will happen when the player collides with the certain area.
I also added a debug message to the script but still nothin, guess what??

The debug message doesn't appear cause hpl2 hates me.

So if you guys could help me solve the problem or not then thnx, idk and I can't find a problem like always.

I tried help from Flawless, Neelke, Lazzer but we couldn't find it so if you guys do then peace and thnx :p
Hey. I think you can't declare a collide callback on a disabled area.
They are sad because you disabled them, so they won't take any code from you. :D
Try that, if that's the problem, you should declare the callback along with the timer after it enables the area.

edit: By 'along with the timer', I mean to include that portion of code into the function that is called by the timer you mentioned.
A little bug I've found when referencing script areas (or items) through for loop variables:

Yours:
PHP Code:
for(int i=1i<=28; ++iAddEntityCollideCallback("Player""ScriptArea_"+i"Diecollide"false1); 

The way that I have to do it to make it work:
PHP Code:
for(int i=1i<=28; ++iAddEntityCollideCallback("Player""ScriptArea_"+i+"""Diecollide"false1); 

(One other thing - I've never included the "int" in the for loop declaration. Not sure if that's the issue or not because I'm not familiar with it.)


Note the change in ScriptArea"+i, adding the second + and empty quotes "" has fixed this same issue for me multiple times.

Give it a shot and let me know. I'm pretty sure this will fix things for you.

For further reference, one of my own functions to do something exactly the same:
PHP Code:
void InitAreas()
{

int x=1;
for(
x=1x<=20x++)
{

AddEntityCollideCallback("Player""NoiseArea_"+x+"""ScareySound"true1);

}


Try
PHP Code:
for(int i=1;i<=28;i++){
AddEntityCollideCallback("Player""ScriptArea_"+i+"""Diecollide"false1);

I don't think this is necessarily a bug, as you guys have put it. It might just be the fact that the callback is triggered "OnEnter" of the area (state 1). If you're already in the area when it activates, I don't think it counts as entering it.

Also, why not just use GivePlayerDamage? I don't see why you add a negative value instead. Of course it might work, but I expect this script to be favorable.
(09-18-2014, 01:44 AM)Daemian Wrote: [ -> ]Hey. I think you can't declare a collide callback on a disabled area.
They are sad because you disabled them, so they won't take any code from you. Big Grin
Try that, if that's the problem, you should declare the callback along with the timer after it enables the area.

edit: By 'along with the timer', I mean to include that portion of code into the function that is called by the timer you mentioned.

As I said the areas goes active one after another by a loop timer.

Both i3670 and Burge's scripts doesn't work Confused Well I don't know what to do, I guess instead of that function I can add like 35 addentitiycollide callbacks in OnStart and maybe something will happen.
Can't you just make a big area that covers the whole hallway, then use a script to check if the Player is in them, use GivePlayerDamage with timer so that the Player would be given damage per second.

If Player is in the area, GivePlayerDamage 10, with a looping timer until he dies.
(09-18-2014, 08:15 AM)First Captain Wrote: [ -> ]Can't you just make a big area that covers the whole hallway, then use a script to check if the Player is in them, use GivePlayerDamage with timer so that the Player would be given damage per second.

If Player is in the area, GivePlayerDamage 10, with a looping timer until he dies.

GetEntitiesCollide doesn't support Player. How do you propose this can be done?
Did you try to just change
AddPlayerHealth(-200);
to
GivePlayerDamage(100, "BloodSplat", true, true);
?
(09-18-2014, 08:51 AM)Wapez Wrote: [ -> ]Did you try to just change
AddPlayerHealth(-200);
to
GivePlayerDamage(100, "BloodSplat", true, true);
?

Yup, i really don't know how to fix this, the debug message ain't even appearing so something ain't right, the health system is not the problem. :/
Pages: 1 2