SA-MP Forums Archive
Automatic Gate with Command? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Automatic Gate with Command? (/showthread.php?tid=267999)



Automatic Gate with Command? - ServerScripter - 10.07.2011

I need somebody who can help me.
I want to create automatic Gates with command:
whene a player do /starsgate:
it verifies if the player belongs to the S.T.A.RS(if he is STARS it opens the gate) if no, it Says:You are not S.T.A.R.S ! Thank you for helping me


Re: Automatic Gate with Command? - xXGaryXx - 10.07.2011

First you need the Object Gate which is Closed. You link this object with a variable. For an example starsgate.
First add this at the top of the script.

pawn Код:
new starsgate; //This is the variable
Now link the Variable with the Object:

pawn Код:
starsgate = CreateObject(...); //This is the Gate which is CLOSED
Next we have to create the command under OnPlayerCommandText:
pawn Код:
if(strcmp(cmd, "/starsgate", true) == 0) //This is the Command
Next we have to ask if he is in the gang "stars" ( I think its something like a Gang ). For this step you need to get the number of the gang. I chose 3. BUT: This Step depends on the script...
pawn Код:
if(strcmp(cmd, "/starsgate", true) == 0)
{
      if(PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3)
      //Asks if playerid is in gang 3
Now we have to add the function with MoveObject:
pawn Код:
if(strcmp(cmd, "/starsgate", true) == 0)
{
      if(PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3)
      {
            MoveObject(starsgate,x-pos,y-pos,z-pos,The speed of which the object will be moved with);
            //Moves the Object
      }
      else
      {
            SendClientMessage(playerid,COLOR,"You are not in the Stars");
            //If playerid is NOT in gang 3 send the message
      }
}
Now the Gate will open if you type in /starsgate, but just if you are in Stars. To close it you can do the same thing again:
pawn Код:
if(strcmp(cmd, "/closestarsgate", true) == 0)
{
      if(PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3)
      {
            MoveObject(starsgate,x-pos,y-pos,z-pos,The speed of which the object will be moved with);
      }
      else
      {
            SendClientMessage(playerid,COLOR,"You are not in the Stars");
      }
}
But when you do not have "PlayerInfo" then try this:

pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
enum pInfo
{
      pLeader
      pMember
}
And now script this: if playerid is in the stars set [pMember] = 3 and if playerid is the leader of the stars set [pLeader] = 3.


Re : Automatic Gate with Command? - ServerScripter - 10.07.2011

Thank you xXGaryXx ! i gonna try it


Re : Automatic Gate with Command? - ServerScripter - 10.07.2011

euh it is a screen of the position of the Gate:

and this is the position:
85.1272,-222.7333,1.5781,354.7394,0,0,0,0,0,0);


Re: Automatic Gate with Command? - xXGaryXx - 10.07.2011

You have to map a gate, i think you know how to do this ( with mta for an example ). You must have the positions for Closed and for Opened. Now if the position for CLOSED is 85.1272,-222.7333,1.5781,354.7394,0,0 you have to do it like this:
pawn Код:
starsgate = CreateObject(ObjectID,85.1272,-222.7333,1.5781,354.7394,0,0);
The Objectid can for an example be 980.

And now at the Moveobject Part enter the position for OPENED, like that:
pawn Код:
MoveObject(starsgate,x-pos,y-pos,z-pos,speed); //The speed can for an example be 1.5
And then it have to work


Re : Automatic Gate with Command? - ServerScripter - 11.07.2011

Euuh can you help me?
1/ tell me whene i put codes .
2/ this is the positon of Gate Closed:CreateObject(980,84.88814545,-222.60382080,3.35151625,0.00000000,0.00000000,0.00 000000);
3/ and the gate opened:
CreateObject(980,84.78124237,-222.55807495,8.74094391,0.00000000,0.00000000,0.00 000000);
Help me please because it makes Errors...


Re : Automatic Gate with Command? - ServerScripter - 11.07.2011

Help please.


Re: Automatic Gate with Command? - Noner - 11.07.2011

Код:
MoveObject(starsgate,84.88814545,-222.55807495,8.74094391
You need x-pos,y-pos,z-pos


Re : Automatic Gate with Command? - ServerScripter - 11.07.2011

where i put :
Код:
starsgate = CreateObject(...); //This is the Gate which is CLOSED
and this:
Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
enum pInfo
{
      pLeader
      pMember
}



Re: Re : Automatic Gate with Command? - Noner - 11.07.2011

[quote=ServerScripter;1287488]where i put :
Код:
starsgate = CreateObject(...); //This is the Gate which is CLOSED
OnGameModeInit (ctrl+f)
and this:

Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
enum pInfo
{
      pLeader
      pMember
On the top of your gm.