27.05.2009, 20:16
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?.
//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
}
}
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; }
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; }
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; } }