SA-MP Forums Archive
[Tutorial] How to script a moving Gate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Tutorial] How to script a moving Gate (/showthread.php?tid=43930)

Pages: 1 2


[Tutorial] How to script a moving Gate - [18SG]Juicy_J - 18.07.2008

Tutorial about "How to script moving gates" by [CPL]Juicy_J

Step 1: Get the cords

You need to place an opened and a closed gate. You need from both the cords.
For an example with this system you can get them: Click me


Step 2: Where can i find the cords.

It saves the object cords to a file in scriptilfes directory

Step 3: Opengate and Closegate cords.

Now you have the cords for the both. Now open your Gamemode.

Step 4: Opengate

Search for "new". Add a new "gatename"
Example : new hqgate;


Search now for OnPlayerCommandText. Add somewhere in the middle of OnPlayerCommandText this section.
If you want that you cant open the gate everywhere, go ingame - to the place where you placed the gate. Type there /save - hq radius. Open your San Andreas folder and you will find the cords from the radius at "Savedpositions". if(PlayerToPoint) is the place for the radius.


With Descriptions

Код:
//-----------------------------------[Moving Gate Commands By [Jay Jones]-------------------------------------------------

if(strcmp(cmdtext,"/opengate", true) == 0)
  {
   if (gTeam[playerid] == TEAM_GROVE)                    
   {                                               x          y         z    <- | - FOR THE RADIUS
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {                                                              |
 	   MoveObject(hqgate, 289.919067, -1547.427734, 27.193420, 1.500000);     <--opened
     return 1;          |         |             |           |           |       |
     }      REMEMBER THE NAME     x             y           z     Gate Speed
  }                                                                             |
}       
                                                                                | 
if(strcmp(cmdtext,"/closegate", true) == 0)                                     
  {                                                                              \
   if (gTeam[playerid] == TEAM_GROVE)                                 
   {                                                                               \
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))  ALL HERE THE SAME
		 {
 	   MoveObject(hqgate, 283.870544, -1543.398804, 27.193420, 1.500000);     <--closed
     return 1;
     }
  }
}
The right code. Without Descriptions

Код:
if(strcmp(cmdtext,"/opengate", true) == 0)
  {
   if (gTeam[playerid] == TEAM_GROVE)
   {
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {
 	   MoveObject(hqgate, 289.919067, -1547.427734, 27.193420, 1.500000);
     return 1;
     }
  }
}

if(strcmp(cmdtext,"/closegate", true) == 0)
  {
   if (gTeam[playerid] == TEAM_GROVE)
   {
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {
 	   MoveObject(hqgate, 283.870544, -1543.398804, 27.193420, 1.500000);
     return 1;
     }
  }
}
Copy this section and edit it with your cords. Put the cords for /opengate, when the gate is opened. And put the cords for /closegate, when the gate is closed. Thats it for the "opengate" section. Now back to Closegate.

Step 5: Closegate.

Search for public OnGameModeInit
Add a line like this under public OnGameModeInit
Here an example:


Код:
hqgate = CreateObject(980, 1786.589233, -1128.866577, 24.734344, 0.0000, 0.0000, 0.0000);//closed
                       |        |           |              |
                  Object Id     x           y              z
Well thats it. I hope you understood all. If you have any questions, post them here.

Jay Jones aka [CPL]Juicy_J


Re: [Tutorial] How to script moving Gates - sebihunter - 18.07.2008

nice done


Re: [Tutorial] How to script a moving Gate - whooper - 18.07.2008

good tutorial


Re: [Tutorial] How to script a moving Gate - [18SG]Juicy_J - 18.07.2008

Thanks Sebihunter and Whooper


Re: [Tutorial] How to script a moving Gate - flakey - 18.07.2008

Good one JJ


Re: [Tutorial] How to script a moving Gate - bFe - 18.07.2008

Nice one...


Re: [Tutorial] How to script a moving Gate - [18SG]Juicy_J - 18.07.2008

Thx Pujan .


Re: [Tutorial] How to script a moving Gate - NEW_IE - 18.07.2008

Looks GOOD ima Try

Theres No turturial on how to use MTA Map Editor


Re: [Tutorial] How to script a moving Gate - Giacomand - 19.07.2008

I think mine is better.


Re: [Tutorial] How to script a moving Gate - [18SG]Juicy_J - 20.07.2008

Maybe. There are many ways for scripting a moving gate. This is just an easy way, that some newbies can understand it.


Re: [Tutorial] How to script a moving Gate - Rks25 - 21.07.2008

Quote:
Originally Posted by Giacomand
I think mine is better.
-.-, you should appreciate someone else is also trying to do something for the new guys.


Re: [Tutorial] How to script a moving Gate - mamane - 01.09.2008

nice job JJ


Re: [Tutorial] How to script a moving Gate - [18SG]Juicy_J - 03.09.2008

Thanks


Re: [Tutorial] How to script a moving Gate - Vialpando - 14.09.2008

Really a great tutorial. Helped me much. Thx Juicy


Re: [Tutorial] How to script a moving Gate - VaD - 16.09.2008

really good tutorial but 1 question, i use bread_oedd and when i go to bread_oed.txt it gives me the cords.... of the gate closed for eg but do i need to make other gate to get the cords for the gate opened?


Re: [Tutorial] How to script a moving Gate - [18SG]Juicy_J - 16.09.2008

Quote:
Originally Posted by VaD
really good tutorial but 1 question, i use bread_oedd and when i go to bread_oed.txt it gives me the cords.... of the gate closed for eg but do i need to make other gate to get the cords for the gate opened?
Yes, you need also the cords from the opened gate. Just move the closed to an opened one and save it.


Re: [Tutorial] How to script a moving Gate - Xander5270 - 16.09.2008

Why the hell does it says that don't understand hqgate? I am a new / noob scripter, please help.

Code:
	if(strcmp(cmdtext,"/opengate", true) == 0)
  	{
   if (gTeam[playerid] == TEAM_BLUE)
   {
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {
 	   MoveObject(hqgate, 2294.237060, 2499.121337, 10.422034, 0.000000, 0.000000, 270.312011, 1.500000);
     return 1;
     }
  }
}

if(strcmp(cmdtext,"/closegate", true) == 0)
  {
   if (gTeam[playerid] == TEAM_BLUE)
   {
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {
 	   MoveObject(2294.206787,2499.329101,5.770081,270.057617,1.500000);
     return 1;
     }
  }
}



Re: [Tutorial] How to script a moving Gate - [18SG]Juicy_J - 16.09.2008

Quote:
Originally Posted by Xander5270
Why the hell does it says that don't understand hqgate? I am a new / noob scripter, please help.

Code:
	if(strcmp(cmdtext,"/opengate", true) == 0)
 	{
   if (gTeam[playerid] == TEAM_BLUE)
   {
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {
 	  MoveObject(hqgate, 2294.237060, 2499.121337, 10.422034, 0.000000, 0.000000, 270.312011, 1.500000);
    return 1;
    }
 }
}

if(strcmp(cmdtext,"/closegate", true) == 0)
 {
   if (gTeam[playerid] == TEAM_BLUE)
   {
		 if(PlayerToPoint(15.0, playerid,283.2922,-1543.4369,24.7436))
		 {
 	  MoveObject(2294.206787,2499.329101,5.770081,270.057617,1.500000);
    return 1;
    }
 }
}
You forgot at the closed gate section after MoveObject(hqgate,
And you should have at the MoveObject lines on‌ly = x,y,z and the gate speed.
Btw you dont need to call it hqgate. It was just an example.




Re: [Tutorial] How to script a moving Gate - Xander5270 - 16.09.2008

Thanks, Now I only getting this errors

Code:
C:\Users\FOZZ\Downloads\samp022server.win32\gamemodes\gf.pwn(6818) : error 017: undefined symbol "hqgate"
C:\Users\FOZZ\Downloads\samp022server.win32\gamemodes\gf.pwn(8146) : error 017: undefined symbol "hqgate"
C:\Users\FOZZ\Downloads\samp022server.win32\gamemodes\gf.pwn(8158) : error 017: undefined symbol "hqgate"



Re: [Tutorial] How to script a moving Gate - zid990 - 16.09.2008

http://forum.sa-mp.com/index.php?topic=73676.0
Can some1 help please?