SA-MP Forums Archive
Need a Script - 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: Need a Script (/showthread.php?tid=83373)



Need a Script - Allu - 24.06.2009

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.


Re: Need a Script - NigNog1 - 24.06.2009

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


Re: Need a Script - Allu - 24.06.2009

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


Re: Need a Script - Stah - 24.06.2009

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.


Re: Need a Script - Allu - 24.06.2009

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.


Re: Need a Script - Stah - 24.06.2009

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;
}



Re: Need a Script - Allu - 25.06.2009

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


Re: Need a Script - dice7 - 25.06.2009

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


Re: Need a Script - Abernethy - 25.06.2009

Make speed, 2.00 for gates.


Re: Need a Script - Allu - 25.06.2009

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