[Tutorial] Problem with moving object
#1

For a few month ago i were having huge problem with making Moving gates and so on.
So i will make one tutorial here for thoose who has the same problem and cant make it work
p.s My first Tutorial.


First of all you have to make 2 "new" where you have your other new lines.. Lets say I want to make a moving gate for lets say FBI...


Code:
new FBIgate; //The Gate object when its Closed!
new FBIgate1 = 0;
When you have done this go to Public OnGameModeInit and where you have your CreateObjects...
and type this:
Code:
FBIgate = CreateObject(ID,X,X,X,X,X,X,) // The gate you made when its CLOSED!!
Done!

Now we need to make the Command to open our Gate.

Lets say you want /FBIGATE.
Find Public OnPlayerCommand.. and do this.

Code:
if(strcmp(cmdtext, "/FBIGATE", true) == 0)
{
	if(IsPlayerInRangeOfPoint(playerid,9,x,x,x))// This has to be the first 3 Coordinates of the gate when its Closed!
	    { //FBI GATE
 			if(FBIGATE1==0)
    			{
     				FBIGATE1 = 1;
       				MoveObject(FBIGATE, X,X,X, 1.0);// Coordinates THIS IS WHEN ITS OPEN!
       			}
	    		else if(FBIGATE1==1)
		   	{
		       		FBIGATE1 = 0; // 
		       		MoveObject(FBIGATE,X,X,X, 1.0);//This has to be the same as "InRangeOfPoint"  AND WHEN THE GATE IS CLOSED!
			}
			return 1;
		}
	}
	return 1;
}
Explanation:
When you want your gate to move you just need the 3 first Coordinates of it. like CreateObject(objid, THIS, THIS, THIS...
Thoose 3 Co are the one you need and copy and paste where ive putted the X's.

the "1.0" is the speed for the gate to move... 0.1 is slowest you can set.

Now everyone can open this gate.. And i just want it to be for FBI(or the faction you want)
I have to add this..
Code:
		if(!(PlayerInfo[playerid][pMember] == 2)) return SendClientMessage(playerid,COLOR_GREY," You are not a FBI agent");
		{
Between where i typed {//FBI GATE And if(IsPlayerInRangeOfPoint(playerid,9,x,x,x))// This has to be the first 3 Coordinates of the gate when its Closed!.. So it will looklike this:

Code:
if(strcmp(cmdtext, "/FBIGATE", true) == 0)
{
	if(IsPlayerInRangeOfPoint(playerid,9,x,x,x))// This has to be the first 3 Coordinates of the gate when its Closed!
	    { //FBI GATE
            if(!(PlayerInfo[playerid][pMember] == 2)) return SendClientMessage(playerid,COLOR_GREY," You are not a  FBI agent");
		{
 			if(FBIGATE1==0)
    			{
     				FBIGATE1 = 1;
       				MoveObject(FBIGATE, X,X,X, 1.0);// Coordinates THIS IS WHEN ITS OPEN
       			}
	    		else if(FBIGATE1==1)
		   	{
		       		FBIGATE1 = 0; // 
		       		MoveObject(FBIGATE,X,X,X, 1.0);//This has to be the same as "InRangeOfPoint"  AND WHEN THE GATE IS CLOSED!
			}
			return 1;
		}
	}
	return 1;
}
I hope it helped for those who have had a hard time to make Moving Gates
Reply


Messages In This Thread
[TUT]with moving object - by goviscrap - 20.11.2012, 20:30
Re: Problem with moving object - by dr.lozer - 22.11.2012, 05:10
Re: Problem with moving object - by Threshold - 22.11.2012, 07:31

Forum Jump:


Users browsing this thread: 1 Guest(s)