Bug with the /lock command
#1


Hey, I got a small problem.
Somewhen, when I try to /lock my house from the inside, its writes for me that I don't have the keys.. But it happenes only on few houses..
This is the /lock code:
Код:
if(strcmp(cmd, "/lock", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    for(new i = 0; i < sizeof(Houses); i++)
			{
				if (PlayerToPoint(3.0, playerid,Houses[i][EnterX], Houses[i][EnterY], Houses[i][EnterZ]) || PlayerToPoint(10.0, playerid,Houses[i][ExitX], Houses[i][ExitY], Houses[i][ExitZ]))
				{
				  if(PlayerInfo[playerid][pHouseKey] == i)
					{
						if(Houses[i][Locked] == 1)
						{
							Houses[i][Locked] = 0;
							SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
		          SaveHouses();
							return 1;
						}
						if(Houses[i][Locked] == 0)
						{
							Houses[i][Locked] = 1;
							SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
		          SaveHouses();
							return 1;
						}
					}
					else
					{
						SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this house!");
						return 1;
					}
				}
			}
			for(new i = 0; i < sizeof(bizes); i++)
			{
				if (PlayerToPoint(3.0, playerid,bizes[i][EnterX], bizes[i][EnterY], bizes[i][EnterZ]) || PlayerToPoint(3.0, playerid,bizes[i][ExitX], bizes[i][ExitY], bizes[i][ExitZ]))
				{
					new playername[MAX_PLAYER_NAME];
					GetPlayerName(playerid,playername,sizeof(playername));
					if(PlayerInfo[playerid][pBizKey] == i && strcmp(playername, bizes[PlayerInfo[playerid][pBizKey]][Owner], true) == 0)
					{
						if(bizes[i][Locked] == 1)
						{
								bizes[i][Locked] = 0;
								SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
			          Savebizes();
							   return 1;
						}
						if(bizes[i][Locked] == 0)
						{
								bizes[i][Locked] = 1;
								SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
			          Savebizes();
							  return 1;
						}
					}
					else
					{
						SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this biz!");
						return 1;
					}
				}
			}
	  }
	  return 1;
	}
Can someone help me please?
Reply
#2

Do you have some errors?
Reply
#3

Quote:
Originally Posted by Nexotronix
Do you have some errors?
It's obvious that he doesn't:
Quote:
Originally Posted by ed2ka
Hey, I got a small problem.
Somewhen, when I try to /lock my house from the inside, its writes for me that I don't have the keys.. But it happenes only on few houses..
Reply
#4

That is Carlitos I suppose. It's problem with virtual worlds and, so.

pawn Код:
if(strcmp(cmd, "/lock", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        for(new i = 0; i < sizeof(Houses); i++)
            {
                if (PlayerToPoint(3.0, playerid,Houses[i][EnterX], Houses[i][EnterY], Houses[i][EnterZ]))
                {
                    if(GetPlayerVirtualWorld(playerid) == Houses[i][EnterWorld])
                  {
                        if(PlayerInfo[playerid][pHouseKey] == i || AdminDuty[playerid] == 1)
                        {
                            if(Houses[i][Locked] == 1)
                            {
                                Houses[i][Locked] = 0;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and opens the door.");
                      SaveHouses();
                                return 1;
                            }
                            if(Houses[i][Locked] == 0)
                            {
                                Houses[i][Locked] = 1;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and locks the door.");
                      SaveHouses();
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this house!");
                            return 1;
                        }
                    }
                }
                else if (PlayerToPoint(3.0, playerid,Houses[i][ExitX], Houses[i][ExitY], Houses[i][ExitZ]))
                {
                  if(GetPlayerVirtualWorld(playerid) == i)
                  {
                        if(PlayerInfo[playerid][pHouseKey] == i || AdminDuty[playerid] == 1)
                        {
                            if(Houses[i][Locked] == 1)
                            {
                                Houses[i][Locked] = 0;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and opens the door.");
                      SaveHouses();
                                return 1;
                            }
                            if(Houses[i][Locked] == 0)
                            {
                                Houses[i][Locked] = 1;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and locks the door.");
                      SaveHouses();
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this house!");
                            return 1;
                        }
                    }
                }
            }
            for(new i = 0; i < sizeof(Businesses); i++)
            {
                if (PlayerToPoint(3.0, playerid,Businesses[i][EnterX], Businesses[i][EnterY], Businesses[i][EnterZ]))
                {
                    if(GetPlayerVirtualWorld(playerid) == Businesses[i][EnterWorld])
                  {
                        new playername[MAX_PLAYER_NAME];
                        GetPlayerName(playerid,playername,sizeof(playername));
                        if(PlayerInfo[playerid][pBizKey] == i && strcmp(playername, Businesses[PlayerInfo[playerid][pBizKey]][Owner], true) == 0 || AdminDuty[playerid] == 1)
                        {
                            if(Businesses[i][Locked] == 1)
                            {
                            if(PlayerInfo[playerid][pSex] == 1)
                              {
                                    Businesses[i][Locked] = 0;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                          PlayerActionMessage(playerid,15.0,"puts in his key and opens the door.");
                          SaveBusinesses();
                      }
                      else
                              {
                                    Businesses[i][Locked] = 0;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                          PlayerActionMessage(playerid,15.0,"puts in her key and opens the door.");
                          SaveBusinesses();
                      }
                                return 1;
                            }
                            if(Businesses[i][Locked] == 0)
                            {
                              if(PlayerInfo[playerid][pSex] == 1)
                              {
                                    Businesses[i][Locked] = 1;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                          PlayerActionMessage(playerid,15.0,"puts in his key and locks the door.");
                          SaveBusinesses();
                      }
                      else
                              {
                                    Businesses[i][Locked] = 1;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                          PlayerActionMessage(playerid,15.0,"puts in her key and locks the door.");
                          SaveBusinesses();
                      }
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this business!");
                            return 1;
                        }
                    }
                }
                else if (PlayerToPoint(3.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
                {
                  if(GetPlayerVirtualWorld(playerid) == i)
                  {
                        new playername[MAX_PLAYER_NAME];
                        GetPlayerName(playerid,playername,sizeof(playername));
                        if(PlayerInfo[playerid][pBizKey] == i && strcmp(playername, Businesses[PlayerInfo[playerid][pBizKey]][Owner], true) == 0 || AdminDuty[playerid] == 1)
                        {
                            if(Businesses[i][Locked] == 1)
                            {
                            if(PlayerInfo[playerid][pSex] == 1)
                              {
                                    Businesses[i][Locked] = 0;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                          PlayerActionMessage(playerid,15.0,"puts in his key and opens the door.");
                          SaveBusinesses();
                      }
                      else
                              {
                                    Businesses[i][Locked] = 0;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                          PlayerActionMessage(playerid,15.0,"puts in her key and opens the door.");
                          SaveBusinesses();
                      }
                                return 1;
                            }
                            if(Businesses[i][Locked] == 0)
                            {
                              if(PlayerInfo[playerid][pSex] == 1)
                              {
                                    Businesses[i][Locked] = 1;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                          PlayerActionMessage(playerid,15.0,"puts in his key and locks the door.");
                          SaveBusinesses();
                      }
                      else
                              {
                                    Businesses[i][Locked] = 1;
                                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                          PlayerActionMessage(playerid,15.0,"puts in her key and locks the door.");
                          SaveBusinesses();
                      }
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this business!");
                            return 1;
                        }
                    }
                }
            }
            for(new i = 0; i < sizeof(Building); i++)
            {
                if (PlayerToPoint(3.0, playerid,Building[i][EnterX], Building[i][EnterY], Building[i][EnterZ]))
                {
                  if(GetPlayerVirtualWorld(playerid) == Building[i][EnterWorld])
                  {
                        if((PlayerInfo[playerid][pFaction] == Building[i][Faction]) || AdminDuty[playerid] == 1)
                        {
                            if(Building[i][Locked] == 1)
                            {
                                Building[i][Locked] = 0;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and opens the door.");
                      SaveBuildings();
                                return 1;
                            }
                            if(Building[i][Locked] == 0)
                            {
                                Building[i][Locked] = 1;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and locks the door.");
                      SaveBuildings();
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this building!");
                            return 1;
                        }
                    }
                }
                else if (PlayerToPoint(3.0, playerid,Building[i][ExitX], Building[i][ExitY], Building[i][ExitZ]))
                {
                  if(GetPlayerVirtualWorld(playerid) == i)
                  {
                        if((PlayerInfo[playerid][pFaction] == Building[i][Faction]) || AdminDuty[playerid] == 1)
                        {
                            if(Building[i][Locked] == 1)
                            {
                                Building[i][Locked] = 0;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Unlocked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and opens the door.");
                      SaveBuildings();
                                return 1;
                            }
                            if(Building[i][Locked] == 0)
                            {
                                Building[i][Locked] = 1;
                                SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[INFO:] Door Locked.");
                      PlayerActionMessage(playerid,15.0,"puts in there key and locks the door.");
                      SaveBuildings();
                                return 1;
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_LIGHTYELLOW2,"[ERROR:] You don't have a key for this building!");
                            return 1;
                        }
                    }
                }
            }
      }
      return 1;
    }
This one works, but it's a bit edited, so take a look and use parts which you need to use.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)