Little problem with HQs.
#1

Hello. I got a little problem. I was making a HQs witch can enter just Faction members, and when I write /openhq, can enter that HQ everyone, when I write /closehq can enter just faction members... But I have problem. When I write /closehq its still opened.. Here is a code, maybe someone know what to do.

Код:
new factionhq = 1;
Код:
if(strcmp(cmd, "/openhq", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  if (PlayerToPoint(3.0, playerid,2445.5452,-1759.2820,13.5911)) //
			{
				if (PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
				{
				factionhq = 0;
				SendClientMessage(playerid, COLOR_GREEN, " HQ OPEN");
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
				}
	    }
Код:
if(strcmp(cmd, "/closehq", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  if (PlayerToPoint(3.0, playerid,2445.5452,-1759.2820,13.5911)) //
			{
				if (PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
				{
				factionhq = 0;
				BroadCast(COLOR_RED, " HQ CLOSED");
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
				}
	    }
This is on command "/enter"

Код:
else if (PlayerToPoint(3.0, playerid,2445.5452,-1759.2820,13.5911))//
			{
				if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
			  {
				  SetPlayerInterior(playerid,9);
					SetPlayerPos(playerid,82.8803,1323.3667,1083.8662);
				  GameTextForPlayer(playerid, "~w~Welcome to Faction HQ", 5000, 1);
				}
				else if(factionhq == 0)
			  {
				  SetPlayerInterior(playerid,9);
					SetPlayerPos(playerid,82.8803,1323.3667,1083.8662);
				  GameTextForPlayer(playerid, "~w~Welcome to Faction HQ", 5000, 1);
				}
			}
and this is on "/exit"

Код:
else if (PlayerToPoint(3.0, playerid,82.8803,1323.3667,1083.8662)) //
			{
			  SetPlayerInterior(playerid,0);
				SetPlayerPos(playerid,2445.5452,-1759.2820,13.5911);
			}
Reply
#2

pawn Код:
new bool:HQOpen;
pawn Код:
if(strcmp(cmd, "/openhq", true) == 0)
{
  if(IsPlayerConnected(playerid))
  {
    if(PlayerToPoint(3.0, playerid,2445.5452,-1759.2820,13.5911))
    {
      if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
      {
        if(HQOpen == true) return SendClientMessage(playerid, COLOR_GRAD1, "HQ is open already!");
        HQOpen = true;
        SendClientMessage(playerid, COLOR_GREEN, " HQ OPEN");
      }
      else
      {
        SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
      }
    }
  }
}
pawn Код:
if(strcmp(cmd, "/closehq", true) == 0)
{
  if(IsPlayerConnected(playerid))
  {
    if(PlayerToPoint(3.0, playerid,2445.5452,-1759.2820,13.5911))
    {
      if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
      {
        if(HQOpen == false) return SendClientMessage(playerid, COLOR_GRAD1, "HQ is closed already!");
        HQOpen = false;
        SendClientMessage(playerid, COLOR_GREEN, " HQ CLOSED");
      }
      else
      {
        SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
      }
    }
  }
}
pawn Код:
// Command /enter
else if (PlayerToPoint(3.0, playerid,2445.5452,-1759.2820,13.5911))//
{
  if(HQOpen == false && PlayerInfo[playerid][pMember] != 6 && PlayerInfo[playerid][pLeader] != 6) return 1;
  SetPlayerInterior(playerid, 9);
  SetPlayerPos(playerid, 82.8803, 1323.3667, 1083.8662);
  GameTextForPlayer(playerid, "~w~Welcome to Faction HQ", 5000, 1);
}
Reply
#3

And how to change it if I want add like 10 faction under one cmd?
Like... If Im member if faction1 I can /openhq at my hq, but not in others...
Reply
#4

Ehh.. I can use else if?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)