Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Collide function issue
Radical Batz Offline
Posting Freak

Posts: 953
Threads: 145
Joined: Dec 2013
Reputation: 25
#1
Collide function issue

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: (Select All)
for(int i=1i<=28; ++iAddEntityCollideCallback("Player""ScriptArea_"+i"Diecollide"false1); 
which is for every area, and this too
PHP Code: (Select All)
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

(This post was last modified: 09-17-2014, 10:55 PM by Radical Batz.)
09-17-2014, 10:53 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#2
RE: Collide function issue

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.

(This post was last modified: 09-18-2014, 01:55 AM by Daemian.)
09-18-2014, 01:44 AM
Find
burge4150 Offline
Member

Posts: 56
Threads: 15
Joined: Feb 2014
Reputation: 0
#3
RE: Collide function issue

A little bug I've found when referencing script areas (or items) through for loop variables:

Yours:
PHP Code: (Select All)
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: (Select All)
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: (Select All)
void InitAreas()
{

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

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

}


(This post was last modified: 09-18-2014, 05:19 AM by burge4150.)
09-18-2014, 05:09 AM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#4
RE: Collide function issue

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


"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 09-18-2014, 06:20 AM by i3670.)
09-18-2014, 06:20 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: Collide function issue

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, 07:27 AM
Find
Radical Batz Offline
Posting Freak

Posts: 953
Threads: 145
Joined: Dec 2013
Reputation: 25
#6
RE: Collide function issue

(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.

(This post was last modified: 09-18-2014, 07:53 AM by Radical Batz.)
09-18-2014, 07:34 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#7
RE: Collide function issue

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.

"Veni, vidi, vici."
"I came, I saw, I conquered."
09-18-2014, 08:15 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#8
RE: Collide function issue

(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?

09-18-2014, 08:44 AM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#9
RE: Collide function issue

Did you try to just change
AddPlayerHealth(-200);
to
GivePlayerDamage(100, "BloodSplat", true, true);
?

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
09-18-2014, 08:51 AM
Find
Radical Batz Offline
Posting Freak

Posts: 953
Threads: 145
Joined: Dec 2013
Reputation: 25
#10
RE: Collide function issue

(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. :/

09-18-2014, 09:04 AM
Find




Users browsing this thread: 2 Guest(s)