Need a Script
#1

Ok,Can someone give/write me a script,what open a gate with a command? And close it with a same command? And if u open a gate then it displays a text: [Name] opened a gate with a remote. Closing: [Name] closed a gate with a remote.
Thanks.
Reply
#2

I recall seeing one or two in the script showroom. Try having a search around.
Reply
#3

I want to open and close a gate with a same command. This one i didnt see :S
Reply
#4

Put this right on top of the script , with the other new's
pawn Код:
new Gate;
new GateInfo;
put this code within OnGameModeInit
pawn Код:
Gate = CreateObject (modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ);
GateInfo = 0;
put this command in OnPlayerCommandText
pawn Код:
if(strcmp(cmdtext, "/togglegate", true) == 0)
{
   if(GateInfo == 0)// if the gate is closed
   {
      MoveObject(Gate, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // then move the gate here.
      GateInfo = 1; // gate is open
      new string[128];
      new playername[360];
      GetPlayerName(playerid,playername,sizeof(playername));
      format(string,sizeof(string),"%s Opened The Gate.",playername);
      SendClientMessageToAll(COLOR_WHITE,string);
   }
   if(GateInfo == 1)// else, if the gate is open
   {
      MoveObject(Gate, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // then move the gate here.
      GateInfo = 0; // gate is closed
      new string[128];
      new playername[360];
      GetPlayerName(playerid,playername,sizeof(playername));
      format(string,sizeof(string),"%s Closed The Gate.",playername);
      SendClientMessageToAll(COLOR_WHITE,string);
   }
}
I left some comments, so you understand what your doing.
Reply
#5

Something is wrong there,when i write the command,then it displays at same time:
[Name]has opened the gate.
[Name]has closed the gate.
SERVER: UNKNOWN COMMAND.

And Nothing happens.
Reply
#6

Sorry about that. Here try this
pawn Код:
if(strcmp(cmdtext, "/togglegate", true) == 0)
{
   if(GateInfo == 0)// if the gate is closed
   {
      MoveObject(Gate, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // then move the gate here.
      GateInfo = 1; // gate is open
      new string[128];
      new playername[360];
      GetPlayerName(playerid,playername,sizeof(playername));
      format(string,sizeof(string),"%s Opened The Gate.",playername);
      SendClientMessageToAll(COLOR_WHITE,string);
   }
   else// else, if the gate is open
   {
      MoveObject(Gate, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // then move the gate here.
      GateInfo = 0; // gate is closed
      new string[128];
      new playername[360];
      GetPlayerName(playerid,playername,sizeof(playername));
      format(string,sizeof(string),"%s Closed The Gate.",playername);
      SendClientMessageToAll(COLOR_WHITE,string);
   }
return 1;
}
Reply
#7

Now it stopped spamming,but the gate still doesn't move.
Reply
#8

Because move object has these parameters
pawn Код:
MoveObject(Gate, Float:X, Float:Y, Float:Z, Float:Speed);
And have you changed the Float:X, Float:Y, Float:Z with actual coordinates or not ? And speed can be anything, but give it 10-15 or something
Reply
#9

Make speed, 2.00 for gates.
Reply
#10

If i delete the FloatR-s then the pawno will give me expected token errors.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)