int isInRange(void self,int dir,void target,int Rx, int Rz,int Ra,float x,float z,float a,float angle)
{
	if (getentityproperty(target,"animationid")==openborconstant("ANI_GRABBED")){
		return 0;
	}else{
	}

	float Tx = getentityproperty(target, "x");
	float Sx = Tx - openborvariant("xpos");
	int type=getentityproperty(target,"type");
	if (type==openborconstant("TYPE_PLAYER")){
		if(Sx<=10){
			return 0;
		}else{
			if (Sx>=310){
				return 0;
			}else{}
		}
	}else{}


	float Tz = getentityproperty(target, "z");
	float Ta = getentityproperty(target, "a");
	float Disx = Tx - x;
	float Disz = z - Tz;
	float Disa = Ta - a;
	
	if (Disz<0){
		return 0;
	}

	/*if (dir){
		Disx = Tx - x;
	}else{
		Disx = x - Tx;
	}*/


	if (dir){
		Disx+=(Disz*angle);
	}else{
		Disx-=(Disz*angle);
	}

	if(Disa < 0){
		Disa = -Disa;
	}
	

	if( Disx <= Rx && Disx>0 && Disz <= Rz && Disz>0 && Disa<=Ra)
	{
		return 1;
	}else{
		return 0;
	}
}

void movePlatform(int Rx, int Rz,int Ra,int speed,float angle)
{
	int iECnt = openborvariant("ent_max");
	float xx;
	int iEnt;
	void vEnt;
	void self = getlocalvar("self");
	float x = getentityproperty(self, "x");
	float z = getentityproperty(self, "z");
	float a = getentityproperty(self, "a");
	int dir=getentityproperty(self,"direction");
	for(iEnt=0; iEnt<iECnt; iEnt++)
	{
		vEnt = getentity(iEnt);
		if (
		getentityproperty(vEnt,"exists")
		&& vEnt
		){
			if (isInRange(self,dir,vEnt,Rx,Rz,Ra,x,z,a,angle)){
				xx = getentityproperty(vEnt, "x");
				if (getentityproperty(vEnt,"animationid")==openborconstant("ANI_GRAB")){
					void grabbing=getentityproperty(vEnt,"grabbing");
					if (dir){
						changeentityproperty(grabbing,"position",getentityproperty(grabbing, "x")+speed);
					}else{
						changeentityproperty(grabbing,"position",getentityproperty(grabbing, "x")-speed);
					}
				}

				if (dir){
					changeentityproperty(vEnt,"position",xx+speed);
				}else{
					changeentityproperty(vEnt,"position",xx-speed);
				}
			}
		}
	}
	return NULL();
}