[Tutorial #1]Made Easy(Gates)
#1

GATES
Ok alot of people need help with gates so heres a short tutorial.
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
Ok the First thing we need is the news:
You can change the name to whatever you want.
Код:
new gate1; >goes at the top
if your doing 2 gates then put another new
Код:
new gate2; >goes at the top
How can the gate open if theres no Object.
You need to have an object created for each gate.
Код:
gate1 = CreateObject(modelid,X.X,Y.Y,Z.Z,RX.RX,RY.RY,RZ.RZ); //closing gate cords
or
Код:
gate2 = CreateObject(modelid,X.X,Y.Y,Z.Z,RX.RX,RY.RY,RZ.RZ); //closing gate cords
----------------------------------------------------------
Now for your Commands
IF you just want it for were ever your at then heres a good example of a cmd with 1 gate.
Код:
if (strcmp(cmdtext, "/og1", true)==0){
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE.");
		MoveObject (gate1,0.0,0.0,0.0,SPEED); //minimun speed=3.0
		return 1;
	}if (strcmp(cmdtext, "/cg1", true)==0){
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE");
		MoveObject (gate1,0.0,0.0,0.0, SPEED);//minimun speed=3.0
		return 1;         ^
	}
The cords for that would be the cords that the object whats created
Now if you want an easyeir way for the speed then put some defines
Код:
#define speed 3.0 //change ur spead here
Gates w/ PlayerToPoint
Now for gates that will only open for a player if your in a certain area.
Every thing is the same except for the Cmd.
Ok your gonna need the forward for the public function
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z); //top of FS or GM
Now for the public
Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
Код:
if (strcmp(cmdtext, "/og1", true)==0)
{
if(PlayerToPoint(3.0, playerid,0.0,0.0,0.0)) //the cords were the player has to be to use the cmd
{
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE.");
		MoveObject (gate1,0.0,0.0,0.0,SPEED); //minimun speed=3.0
		return 1;
	}}if (strcmp(cmdtext, "/cg1", true)==0){

if(PlayerToPoint(3.0, playerid,0.0,0.0,0.0)) //the cords were the player has to be to use the cmd
{
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE");
		MoveObject (gate1,0.0,0.0,0.0, SPEED);//minimun speed=3.0
		return 1;         
	}}
Thats that.
Open & Close Gates for Players with certain team
Again every thing is still the same only your adding the team
Код:
gteam
Код:
if (strcmp(cmdtext, "/og1", true)==0)
{
if(PlayerToPoint(3.0, playerid,0.0,0.0,0.0)) //the cords were the player has to be to use the cmd
{

for(new i=0; i<MAX_PLAYERS; i++)
  {
  if(gTeam[i] == TEAM_POLICE)//change this to the team you want
{
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE.");
		MoveObject (gate1,0.0,0.0,0.0,SPEED); //minimun speed=3.0
		return 1;
	}}}}if (strcmp(cmdtext, "/cg1", true)==0){

if(PlayerToPoint(3.0, playerid,0.0,0.0,0.0)) //the cords were the player has to be to use the cmd
{

for(new i=0; i<MAX_PLAYERS; i++)
  {
  if(gTeam[i] == TEAM_POLICE)//Change this to the team you want
{
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE");
		MoveObject (gate1,0.0,0.0,0.0, SPEED);//minimun speed=3.0
		return 1;         
}}}}
------------------------------------------------------------------
Thats it.you can go on from.
The Players:
Score
Certain Ammount of Cash
a certain level or (ex: Key/licence)

You enjoy and do it safe.Lol

~Passout_IE/NEW_IE


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
Reply
#2

Good job. Actually I use a similar code for gates on my script, almost identical to this, but w/e it will come very useful to these newbie "coders".
Reply
#3

True. Well everyone noob or not has to learn someday.
Reply
#4


Well this is the way I make my gates, you can see the similarities:

Код:
new LSPDGATE1;
Код:
LSPDGATE1 = CreateObject(980, 1549.747925, -1628.123291, 15.156204, 0.0000, 0.0000, 270.0000);
Код:
	
if(strcmp(cmdtext, "/LSPD1CLOSE", true)==0)
	{
	  if(gTeam[playerid] == 2 || IsACop(playerid))
			{
			MoveObject (LSPDGATE1,1549.747925, -1628.123291, 15.156204, 1.692236);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD2, "  You are not a Cop / FBI / Task Force");
			}
    		return 1;
	}
	if(strcmp(cmdtext, "/LSPD1OPEN", true)==0)
 	{
 		if(gTeam[playerid] == 2 || IsACop(playerid))
			{
   		MoveObject (LSPDGATE1,1549.747925, -1628.123291, 15.156204, 1.692236);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD2, "  You are not a Cop / FBI / Task Force");
			}
   		return 1;
   }
Well this is more ideal for the Godfather script but yeah, it's almost like yours.

Quote:
Originally Posted by NEW_IE
Now for your Commands
IF you just want it for were ever your at then heres a good example of a cmd with 1 gate.
Код:
    if (strcmp(cmdtext, "/og1", true)==0){
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE.");
		MoveObject (gate1,0.0,0.0,0.0,SPEED); //minimun speed=3.0
		return 1;
	}if (strcmp(cmdtext, "/cg1", true)==0){
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE");
		MoveObject (gate1,0.0,0.0,0.0, SPEED);//minimun speed=3.0
		return 1;          ^
	}
Well now looking at it, it's basically the same, hehe.
Reply
#5

**Delete, meant to press modify button, but pushed quote button instead**
Reply
#6

Quote:
Originally Posted by Manny_rivera
Well this is the way I make my gates, you can see the similarities:

Код:
new LSPDGATE1;
Код:
LSPDGATE1 = CreateObject(980, 1549.747925, -1628.123291, 15.156204, 0.0000, 0.0000, 270.0000);
Код:
	
if(strcmp(cmdtext, "/LSPD1CLOSE", true)==0)
	{
	  if(gTeam[playerid] == 2 || IsACop(playerid))
			{
			MoveObject (LSPDGATE1,1549.747925, -1628.123291, 15.156204, 1.692236);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD2, " You are not a Cop / FBI / Task Force");
			}
   		return 1;
	}
	if(strcmp(cmdtext, "/LSPD1OPEN", true)==0)
 	{
 		if(gTeam[playerid] == 2 || IsACop(playerid))
			{
   		MoveObject (LSPDGATE1,1549.747925, -1628.123291, 15.156204, 1.692236);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD2, " You are not a Cop / FBI / Task Force");
			}
   		return 1;
  }
Well this is more ideal for the Godfather script but yeah, it's almost like yours.

Quote:
Originally Posted by NEW_IE
Now for your Commands
IF you just want it for were ever your at then heres a good example of a cmd with 1 gate.
Код:
    if (strcmp(cmdtext, "/og1", true)==0){
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE.");
		MoveObject (gate1,0.0,0.0,0.0,SPEED); //minimun speed=3.0
		return 1;
	}if (strcmp(cmdtext, "/cg1", true)==0){
    SendClientMessage(playerid,COLOR_GREY,"YOUR TEXT HERE");
		MoveObject (gate1,0.0,0.0,0.0, SPEED);//minimun speed=3.0
		return 1;         ^
	}
Well now looking at it, it's basically the same, hehe.
I see you use the GF then. I do too.
Reply
#7

Quote:
Originally Posted by NEW_IE
You need to have an object created for each gate.

Code:
CreateObject = gate1(modelid,X.X,Y.Y,Z.Z,RX.RX,RY.RY,RZ.RZ); //closing gate cords or

Code:
CreateObject = gate2(modelid,X.X,Y.Y,Z.Z,RX.RX,RY.RY,RZ.RZ); //closing gate cords----------------------------------------------------------
gate1 = CreateObject(....

not CreateObject = gate1
Reply
#8

Hallo, ich habe ein bild gemacht schaut es euch einfach an.

Ist ganz leicht ! ! !

http://img3.imagebanana.com/view/tdg...eitung.bmp.png

:thumbsup: :thumbsup:

mfg

Mr_Al3X
Reply
#9

C:\Documents and Settings\Owner\Desktop\SA-MP SERVER 1\gamemodes\test.pwn(185) : error 017: undefined symbol "gate1"
C:\Documents and Settings\Owner\Desktop\SA-MP SERVER 1\gamemodes\test.pwn(202) : error 017: undefined symbol "gate2"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

I get those errors does that mean i have to do
#define gate1 ??
#define gate2 ??

What would i put after the gate1 gate2??
Help plz
Reply
#10

Good job, but for this to be even better, indent your code better
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)