SA-MP Forums Archive
Lock. - 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: Lock. (/showthread.php?tid=79336)



Lock. - -eXo - 27.05.2009

On my script, I use teleports with playertopoint etc for entering interiors. Is it possible to make a /lock command so when its locked the teleport is no longer functional and when you type /lock again it works?.


Re: Lock. - -eXo - 27.05.2009

Anyone know?


Re: Lock. - Backwardsman97 - 28.05.2009

pawn Код:
//At the top
new bool:Locked;

//Whenever they teleport
if(Locked)
{
   //They can't teleport
}
else
{
   //SetPlayerPos...
}

//The command
if(!strcmp(cmdtext,"/lock",true))
{
   if(Locked)
   {
      Locked = false;
      //Unlocked
   }
   else
   {
      Locked = true;
      //Locked
   }
}



Re: Lock. - -eXo - 28.05.2009

Thanks, so the command would be like?:

Код:
if(!strcmp(cmdtext,"/yaklock",true))
{
if(PlayerToPoint(1.0,playerid,2324.0361,-1143.1575,1050.4922))
		      {
	if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 )
		    {
   if(Locked)
   {
      Locked = false;
      //Unlocked
   }
   else
   {
      Locked = true;
      //Locked
	    }
			  }
			}

		return 1;
	}



Re: Lock. - -eXo - 28.05.2009

It locks but I can't unlock it. When you do /yaklock, it locks correctly but when I do /yaklock again it does nothing.
The command:
Код:
if(!strcmp(cmdtext,"/yaklock",true))
{
if(PlayerToPoint(1.0,playerid,2324.0361,-1143.1575,1050.4922))
		      {
	if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 )
		    {
		    GetPlayerName(playerid, sendername, sizeof(sendername));
			  format(string, sizeof(string), "* %s twists the key in the hole, locking the door.", sendername);
			  ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
   if(Locked)
   {
      Locked = false;
      //Unlocked
   }
   else
   {
      Locked = true;
      //Locked
	    }
			  }
			}

		return 1;
	}
The teleport part:
Код:
else if (PlayerToPointStripped(1.0, playerid,1252.2933,-980.0336,37.5556, cx,cy,cz))
	{     		//Yakuza
	if(Locked)
	{
	GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
	}
	else
	{
	SetPlayerPos(playerid,2324.0361,-1143.1575,1050.4922);
		GameTextForPlayer(playerid, "~w~Yakuza HQ", 5000, 3);
		SetPlayerInterior(playerid,12);
		PlayerInfo[playerid][pInt] = 12;
	}
	}
Also, if I added if(Locked) to all the doors, wouldn't /yaklock lock all of them rather than just one?


Re: Lock. - -eXo - 28.05.2009

Sorry for the bump, could anyone help?.