Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
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
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 for(int i=1; i<=28; ++i) AddEntityCollideCallback("Player", "ScriptArea_"+i, "Diecollide", false, 1);
which is for every area, and this too void Diecollide(string &in asParent, string &in asChild, int 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 |
|
Daemian
Posting Freak
Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation:
49
|
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 |
|
burge4150
Member
Posts: 56
Threads: 15
Joined: Feb 2014
Reputation:
0
|
RE: Collide function issue
A little bug I've found when referencing script areas (or items) through for loop variables:
Yours:
for(int i=1; i<=28; ++i) AddEntityCollideCallback("Player", "ScriptArea_"+i, "Diecollide", false, 1);
The way that I have to do it to make it work:
for(int i=1; i<=28; ++i) AddEntityCollideCallback("Player", "ScriptArea_"+i+"", "Diecollide", false, 1);
(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:
void InitAreas() {
int x=1; for(x=1; x<=20; x++) {
AddEntityCollideCallback("Player", "NoiseArea_"+x+"", "ScareySound", true, 1);
}
}
(This post was last modified: 09-18-2014, 05:19 AM by burge4150.)
|
|
09-18-2014, 05:09 AM |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
RE: Collide function issue
Try
for(int i=1;i<=28;i++){ AddEntityCollideCallback("Player", "ScriptArea_"+i+"", "Diecollide", false, 1); }
(This post was last modified: 09-18-2014, 06:20 AM by i3670.)
|
|
09-18-2014, 06:20 AM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
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 |
|
Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
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.
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 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 |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
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 |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
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 |
|
Wapez
Senior Member
Posts: 360
Threads: 37
Joined: Mar 2012
Reputation:
19
|
RE: Collide function issue
Did you try to just change
AddPlayerHealth(-200);
to
GivePlayerDamage(100, "BloodSplat", true, true);
?
|
|
09-18-2014, 08:51 AM |
|
Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
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 |
|
|