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
Checking if the player is NOT inside an area?
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#2
RE: Checking if the player is NOT inside an area?

Well, whenever I used the GetEntitiesCollide(,) function, it didn't seem to like using the "==false" part. This is how I'd do it.

Create a AddEntityCollideCallback("Player" , "Area_Throw" , "Collide" , false , 0) in your OnStart().

Then, in your "void Collide(string&in asParent , string&in asChild , int alState)", make it so that every time it is called, a local variable is set to the alState, like this:
SetLocalVarInt("CollideState" , alState);

Finally, use this Local variable to determine whether the player is colliding with the area, like this:
if( (mon_health > 0) && (GetLocalVarInt("CollideState") == -1) )

Overall, the script should go like this.
Spoiler below!

PHP Code: (Select All)
void OnStart() {

AddEntityCollideCallback("Player" "Area_Throw" "Collide" false 0);
SetLocalVarInt("CollideState" , -1); // Sets the variable so by default the alState is -1

}
void Collide(string&in asParent string&in asChild int alState) {

SetLocalVarInt("CollideState" alState); // Sets the Local variable to the alState

}
void YourFunction(YourFunction) {
if( (
mon_health 0) && (GetLocalVarInt("CollideState") == -1) ) { // If the player has left area
// Do stuff here!
}



Or you can try this:
if( (mon_health > 0) && GetEntitiesCollide("Player", "Area_Throw") ) {// Do nothing }
else if(mon_health > 0){
// Do stuff here!

}

I don't like doing it this way because I don't really like the GetEntitiesCollide Function, but it should work.

(This post was last modified: 04-12-2012, 05:25 PM by DRedshot.)
04-12-2012, 05:16 PM
Find


Messages In This Thread
RE: Checking if the player is NOT inside an area? - by DRedshot - 04-12-2012, 05:16 PM



Users browsing this thread: 1 Guest(s)